how to achieve min 75% code coverage

everyone, I have an apex class, in that installation and unit is custom objects. In Apex code, the first method logic is when intstallation__c status(picklist field) changes to 2-installed, then Unit__c status will be updated with 2-Deployed and also Mark_Unit_Complete__c (formula checkbox) field on installation__c object will be enabled. In the Apex, I am using custom settings(Unit_Installed_Status_Name__c field value is 2-Deployed). I am unable to cover some particular lines of code and the percentage is 48%. I don’t understand where I am missing can anyone help me out.

Apex Class:

public class InstallationHelper {  private static Case_Installation_Settings__c settings;      public static void markUnitComplete( List<Installation__c> newInstalls, Map<Id, Installation__c> oldInstalls)     {         Set<Id> completedInstallUnitIds = new Set<Id>();         List<Unit__c> updateUnits = new List<Unit__c>();          if ( settings == null ) settings = Case_Installation_Settings__c.getInstance();          if ( newInstalls != null && newInstalls.size() > 0 )         {             for ( Installation__c inst : newInstalls )             {                 Installation__c oldInst;                 if (oldInstalls != null && oldInstalls.containsKey(inst.Id))                 {                     oldInst = oldInstalls.get(inst.Id);                 }                  if ( DisplayUtils.hasChanged(oldInst, inst, 'Status__c') && inst.Mark_Unit_Complete__c )                 {                     if ( inst.Unit__c != null )                     {                         completedInstallUnitIds.add( inst.Unit__c );                     }                 }             }             List<Unit__c> unitList =  [SELECT id, name, status__c FROM Unit__c WHERE Id IN :completedInstallUnitIds];             if ( completedInstallUnitIds != null && completedInstallUnitIds.size() > 0 )             {                 for ( Unit__c u :unitList)                 {                     u.Status__c = settings.Unit_Installed_Status_Name__c;                     updateUnits.add( u );                 }             }             if ( updateUnits != null && updateUnits.size() > 0 )             {                 update updateUnits;             }          }     }        public static void updateScheduleIds(list<Installation__c> newList, map<id,Installation__c> oldlist)     {         set<id> accountids = new set<id>();         map<id,Installation__c> compInst = new map<id,Installation__c>();         list<Installation__c> updateInstallations = new list<Installation__c>();         List<Installation__c> insList = [Select id,Site__c,After_PSA_Schedule_created__c FROM Installation__c WHERE Site__c IN:accountids];         for(Installation__c inst : newList)         {             if(inst.Monitoring_hours_changed__c == false && oldlist.get(inst.id).Monitoring_hours_changed__c== true)             {                 accountids.add(inst.Site__c);                 compInst.put(inst.Site__c,inst);             }             else if(inst.After_PSA_Schedule_created__c == true && oldlist.get(inst.id).After_PSA_Schedule_created__c == false)             {                 accountids.add(inst.Site__c);                 compInst.put(inst.Site__c,inst);             }             if(!accountids.isEmpty())             {                 for(Installation__c ins : insList)                 {                     if(compInst.get(ins.Site__c).id != ins.id)                     {                         Installation__c temp = compInst.get(ins.Site__c);                         ins.Monday_ScheduleID__c = temp.Monday_ScheduleID__c;                         ins.Tuesday_ScheduleID__c = temp.Tuesday_ScheduleID__c;                         ins.Wednesday_ScheduleID__c = temp.Wednesday_ScheduleID__c;                         ins.Thursday_ScheduleID__c = temp.Thursday_ScheduleID__c;                         ins.Friday_ScheduleID__c = temp.Friday_ScheduleID__c;                         ins.Saturday_ScheduleID__c = temp.Saturday_ScheduleID__c;                         ins.Sunday_ScheduleID__c = temp.Sunday_ScheduleID__c;                         updateInstallations.add(ins);                     }                     else if(ins.After_PSA_Schedule_created__c == true && compInst.get(ins.Site__c).id == ins.id)                     {                         ins.After_PSA_Schedule_created__c = false;                         updateInstallations.add(ins);                     }                 }             }         }          if(!updateInstallations.isEmpty())             update updateInstallations;     }  } 

enter image description here enter image description here enter image description here

My test class: @isTest(SeeAllData=True) public class InstallationHelperTestClass {     public static testMethod void testing(){                 Test.startTest();          Account a1 = new Account();         a1.Name = 'test';         a1.Type = 'customer';         a1.Channel__c = 'Direct';         a1.Industry = 'Agriculture';         a1.Suspend__c = true;         insert a1;            Profile p = [SELECT Id FROM Profile WHERE Name = 'Standard User'];         User u = new User(             Alias = 'testn',             Email = 'testn@unitingambition.com',             EmailEncodingKey = 'UTF-8',             LastName = 'Test',             LanguageLocaleKey = 'en_US',             LocaleSidKey = 'en_US',             TimeZoneSidKey='America/Los_Angeles',             ProfileId = p.Id,             UserName='testn@unitingambition.com'         );                insert u;             User u1 = new User(             Alias = 'testmn',             Email = 'testmn@unitingambition.com',             EmailEncodingKey = 'UTF-8',             LastName = 'Test',             LanguageLocaleKey = 'en_US',             LocaleSidKey = 'en_US',             TimeZoneSidKey='America/Los_Angeles',             ProfileId = p.Id,             UserName='testmn@unitingambition.com'         );         insert u1;          List<AccountTeamMember> members = new List<AccountTeamMember>();         List<Id> accIds = new List<Id>();          List<Account> accList = [select id, Name, Suspend__c from Account where Id=:a1.id];         for ( Account a : accList )         {              AccountTeamMember member1 = new AccountTeamMember();             member1.AccountId = a.Id;             member1.UserId = u.id;             member1.TeamMemberRole = 'Account Manager';             members.add(member1);              AccountTeamMember member4 = new AccountTeamMember();             member4.AccountId = a1.Id;             member4.UserId = u1.id;             member4.TeamMemberRole = 'Field Services';             members.add(member4);          }         insert members;          Contact con = new Contact();         con.LastName = 'Vgs';         //con.id = a1.Id;         insert con;              Case ca = new Case();         ca.Type ='Account Change';         ca.Status ='01-New';         ca.Subject ='test new';         ca.Description = 'new Description';         ca.AccountId= a1.id;         ca.ContactId = con.id;           insert ca;          Opportunity opp = new Opportunity();         opp.Name = 'test1';         opp.Type = 'Existing Business';         opp.CloseDate = system.today();         opp.StageName = '01-Discovery';         opp.Prospect_Level__c = 'A';         opp.LeadSource = 'web';         opp.AccountId = a1.id;                  insert opp;          Unit__c uni = new Unit__c();              uni.Name = 'test';              uni.Status__c = '2-Deployed';              insert uni;              //uni.Status__c = '2-Deployed';              //update uni;          Installation__c inst = new Installation__c();         inst.Name__c ='instal';         inst.Status__c = '0-New';         inst.Monitoring_Service__c = 'Live';            inst.Site__c = a1.Id;         inst.prior_status__c = 'Suspend';         inst.prior_monitoring_service__c = 'Client';         inst.Install_Case__c = ca.id;         inst.Opportunity__c = opp.id;          inst.Unit__c = uni.id;        inst.Monday_ScheduleID__c = 'AM_Start_Mon_Hour__c';         insert inst;         /*   Case_Installation_Settings__c setting = new Case_Installation_Settings__c();             setting.Unit_Installed_Status_Name__c = '2-Deployed';             insert setting;*/        /*  Unit__c unitList =  [SELECT id, name, status__c FROM Unit__c limit 1];         unitList.Status__c = '2-Deployed';          update unitList;         system.assertEquals('2-Deployed',unitList.Status__c);*/          List<Installation__c> newInstalls=[Select Id,Name__c,Status__c,Monitoring_Service__c,After_PSA_Schedule_created__c,Unit__c,                                            Monitoring_hours_changed__c,Site__c,prior_status__c,                                            prior_monitoring_service__c,Install_Case__c,Opportunity__c from Installation__c];         Map<Id,Installation__c> oldInstalls=new Map<Id,Installation__c>([Select Id,Name__c,Unit__c,After_PSA_Schedule_created__c,Monitoring_hours_changed__c,Status__c,Monitoring_Service__c,Site__c,prior_status__c,prior_monitoring_service__c,Install_Case__c,Opportunity__c from Installation__c]);         InstallationHelper.markUnitComplete(newInstalls,oldInstalls);        InstallationHelper.updateScheduleIds(newInstalls,oldInstalls);            Test.stopTest();      }  } 

RabbitMQ: how to achieve scalable one-to-one communication?

I’m trying to use RabbitMQ for two-way one-to-one communication between clients and servers. So, Client 1 should be able to communicate only with Server 1, and vice versa:

enter image description here

The servers stay always connected to RabbitMQ, whereas the clients are started up and shut down on demand. This is because a server should receive all the messages from its client, but if a server sends a message to its client when the client is not present, it’s ok if the message is just lost.

Furthermore, there must be a client-server pair for each user of the system.

My first idea to implement this was to create a new RabbitMQ user and vhost for each client-server pair, and two queues in each vhost (one consumed by the server and one consumed by the client).

However, is this scalable? For example, if there are 10k users of the system, there would be 10k RabbitMQ users, 10k vhosts, and 10k permanent queues, connections, channels, and consumers (from the servers).

Can these large numbers of queues and connections be a performance problem for RabbitMQ?

And what would be the best way to implement this behaviour with RabbitMQ? Or is a different technology than AMQP and RabbitMQ better suited for this use case?

How to achieve Host-and-Internet-Only networking within a Debian host and Windows Server guest using KVM/QEMU?

I have a physical/dedicated server which is running Debian 9 (Stretch). The server has enough resources to support its own load and the load of some virtual machines (in this question: Windows Server 2016 Standard edition).

To simplify this question, I will use Debian host to refer to the physical/dedicated server which is running Debian 9 (Stretch), and Windows VM to refer to the (currently not implemented) Windows Server 2016 Standard edition virtual machine that runs on the Debian host.

The Debian host uses KVM/QEMU/virsh to provide virtualization capability and its configuration. The Debian host currently does not have any virtual machines (or networks) configured. The Debian host only has one physical network card (NIC) which is mapped to the network interface eth0. The Debian host itself provides various services that the Debian host also should provide, when it’s hosting additional virtual machines.

The Debian host should (scope of this question) host one Windows VM. The Debian host and its services should be able to access the Windows VM via a private IPv4 network/address. The Windows VM should be able to access the Debian host by the same IPv4 network (private IPv4 address of the Debian host). The Windows VM should not be accessible via a public IPv4 or IPv6 network/address. The Windows VM should be able to access the Internet (outgoing connections). The Windows VM should not have a public IPv4 or IPv6 network/address assigned to it. A proxy on the Debian host should proxy specific incoming connections to the private IPv4 address of the Windows VM.

The Debian host should further (relevant for this question) be able to host further virtual machines (other Debian instances). All the virtual machines on the Debian host should be isolated from each other. Meaning Debian host can reach all of the VMs, all VMs can reach Debian host and Internet, but the VMs cannot reach each other (directly).

I found some concepts about VM networking. However, I could not find a solution that matches my needs. The closest (but not matching) concept I could find was: Bridge networking. With this, the Windows VM would be connected “to the Internet”. This is not desired. The other concepts (NAT, Host-only) either don’t allow Host -> Guest or Guest -> Internet access.

My question is: Is my planned network design possible with one virtual NIC? How to implement such network design with KVM/QEMU on the Debian host and Windows VM?

Due to networking restrictions on the Hosters’ side, I cannot use a public IP address inside a virtual machine (IP to MAC filters). Also: I don’t the VMs to be directly accessible from the Internet.

Is it good practise to use javascript template literals to achieve more DRY code?

If we follow the DRY principle, then we should avoid repeating things like identifiers and class names etc.

If we have a condition that checks a boolean so to hide or unhide an element by altering elements class:

if (isVisible) {   $  ('#btn-stop').removeClass('hidden'); } else {   $  ('#btn-stop').addClass('hidden'); } 

we can shorten things a little bit by using the ternary operator like this:

isVisible ?   $  ('#btn-stop').removeClass('hidden') :   $  ('#btn-stop').addClass('hidden'); 

but again element id and the class name we want to alter are duplicated, which can both be eliminated if we use Template literals to compose the method name for each case:

$  ('#btn-stop')[`$  {isVisible ? 'add' : 'remove'}Class`]('hidden'); 

Is it a good practise to write something like this to achieve DRY, or is it better and human readable to avoid it and write whole expressions?

What is the biggest/smallest range the same character can achieve?

Just for fun, I want to create a character who can vary from really tiny or smaller to huge or big.

Which is the bigger/smaller combination to create that “Ant Man” style char?

It can:

  • Be from any race.
  • Be from any class.
  • Use any magical-item combination.
  • Use temporary buffs/magic, but only if can use it himself. (Don’t need another player/NPC)
  • Be level 20.

The more vanilla, the better

Can I achieve a similar power usage to the i5-7500T with an i5-7500 by underclocking?

I’m upgrading my aging NAS hardware to something more recent, and I’ve decided that I will either buy an i5-7500 (3.4 base, 3.8 boost, 65W) or an i5-7500T  (2.7 base, 3.3 boost, 35W). Given that the two CPUs are so similar in price, I don’t want to miss out on potential performance, but right now I am more keenly interested in lower energy consumption.

1) Will the CPUs use similar amounts of energy when at low utilization?

2) Can I underclock the i5-7500?

3) Would that achieve a similar power consumption to the i5-7500T?

Is it possible to achieve greater than perfect compression using machine learning and big data?

Imagine Google wanted to make their chrome browser faster. Let “database” be all the machines which serve content from Google’s servers, including Search and Google cloud services. Google begins using machine learning to analyze thousands of petabytes of data on their database to extract a dictionary of the most redundant file sequences. Lets say the most redundant hexadecimal found was the sequence:

“64 65 63 69 6d 61 6c 20 66 6f 72 6d 61 74 2e 20 43 6f 6d 70 75 74 65 72 73 20 73 74 6f 72 65 20 74 65 78 74 20 61 73 20 6e 75 6d 62 65 72 73 2c 20 61 6e 64 20 77 69 74 68 20 68 65 78 20 79 6f 75 20 64 69 73 70 6c 61 79 20 74 68 65 20 6e 75 6d 62 65 72 73 20 6e 6f 74 20 61 73 20 61 20 64 65 63 69 6d 61 6c 20 6e 75 6d 62 65 72 2c 20 62 75 74 20 69 6e 20 62 61 73 65 20 31 36 2e 20 48 65 78 20 6f 72 20 62 61 73 65 20 31 36 20 6f 72 20 68 65 78 61 64 65 63 69 6d 61 6c 20 69 73 20 61 20 6e 75 6d 65 72 61 6c 20 73 79 73 74 65 6d”

They stored this sequence in their dictionary at index 1 and included this dictionary file in their Chrome update. For every user that had the latest Chrome update if they requested a file that had this sequence Google’s server would return a flag and the index 1 (e.g. “D 1”) such that the Chrome browser could lookup the bytes locally without the need of transferring them over the network. In essence the file being transferred would become something like “data data data D 1 data data”

Furthermore, they did this for gigabytes of sequences causing a larger Chrome update but faster file transfer times.

And to make things more interesting they used machine learning to analyze end-user behavior to predict which sequences were more likely to be requested.

After adding this functionality they achieved faster load times and decreased network congestion and possibly saved in electricity costs by removing redundancy across their entire network.

Questions:

What would this be called? Distributed Cached file transfer? Would this be practical or desirable? I imagine it could save money in terms of electricity for a large company like google.

Magento 2 best methodologies to achieve a load time of less than 2.5 seconds

Please elaborate the best methodologies and strategies to achieve a lesser load time in both server side and Magento side. Tried out various strategies but couldnot achieve a load time of less than 4 seconds consistently. In some cases if I achieve 3.2seconds or more it is not consistent. Please suggest the techniques you have employed to achieve lesser load time.

Thanks.

How can I achieve this brownish look?

I’ve been trying to achieve this look for some time, but I’m stuck :(. Starting with the camera, I heard that maybe adjusting the WB to cloudy? And the metering to spot metering?

I mainly use Lightroom and I just can’t get it right. I see they use a very brownish tone, taking down a lot of saturation in the greens but the skin colors look really good. I would be very happy for any kind of tips.

examples of the brown-tinted look (wedding images) more examples of the brown-tinted look (wedding images)