@Test public void shouldReturnDecreaseReplicas() { DeployableService airlineService = models1.getAirlineService(); DeployableServiceSpec newAirlineSpec = models2.getAirlineSpec(); newAirlineSpec.setNumberOfInstances(1); UpdateActionFactory fac = new UpdateActionFactory(); List<UpdateAction> actions = fac.getActions(airlineService, newAirlineSpec); assertEquals(1, actions.size()); UpdateAction action = actions.get(0); assertEquals(DecreaseNumberOfReplicas.class, action.getClass()); }
public List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec) { DeployableServiceSpec currentServiceSpec = currentService.getSpec(); List<UpdateAction> actions = new ArrayList<UpdateAction>(); logger.info("Calculating changes on service spec \nOld = " + currentServiceSpec + "\nNew = " + newServiceSpec); if (currentServiceSpec.getNumberOfInstances() < newServiceSpec.getNumberOfInstances()) { UpdateAction action = new IncreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } else if (currentServiceSpec.getNumberOfInstances() > newServiceSpec.getNumberOfInstances()) { UpdateAction action = new DecreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } if (!(currentServiceSpec.getResourceImpact() == null || currentServiceSpec.getResourceImpact().getMemory() == null)) { if (!(currentServiceSpec.getResourceImpact().getMemory().ordinal() == newServiceSpec.getResourceImpact() .getMemory().ordinal())) { UpdateAction action = new Migrate(currentService, newServiceSpec); actions.add(action); } } logger.info("Detected changes: " + actions); return actions; }
UpdateActionFactory { public List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec) { DeployableServiceSpec currentServiceSpec = currentService.getSpec(); List<UpdateAction> actions = new ArrayList<UpdateAction>(); logger.info("Calculating changes on service spec \nOld = " + currentServiceSpec + "\nNew = " + newServiceSpec); if (currentServiceSpec.getNumberOfInstances() < newServiceSpec.getNumberOfInstances()) { UpdateAction action = new IncreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } else if (currentServiceSpec.getNumberOfInstances() > newServiceSpec.getNumberOfInstances()) { UpdateAction action = new DecreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } if (!(currentServiceSpec.getResourceImpact() == null || currentServiceSpec.getResourceImpact().getMemory() == null)) { if (!(currentServiceSpec.getResourceImpact().getMemory().ordinal() == newServiceSpec.getResourceImpact() .getMemory().ordinal())) { UpdateAction action = new Migrate(currentService, newServiceSpec); actions.add(action); } } logger.info("Detected changes: " + actions); return actions; } }
UpdateActionFactory { public List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec) { DeployableServiceSpec currentServiceSpec = currentService.getSpec(); List<UpdateAction> actions = new ArrayList<UpdateAction>(); logger.info("Calculating changes on service spec \nOld = " + currentServiceSpec + "\nNew = " + newServiceSpec); if (currentServiceSpec.getNumberOfInstances() < newServiceSpec.getNumberOfInstances()) { UpdateAction action = new IncreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } else if (currentServiceSpec.getNumberOfInstances() > newServiceSpec.getNumberOfInstances()) { UpdateAction action = new DecreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } if (!(currentServiceSpec.getResourceImpact() == null || currentServiceSpec.getResourceImpact().getMemory() == null)) { if (!(currentServiceSpec.getResourceImpact().getMemory().ordinal() == newServiceSpec.getResourceImpact() .getMemory().ordinal())) { UpdateAction action = new Migrate(currentService, newServiceSpec); actions.add(action); } } logger.info("Detected changes: " + actions); return actions; }  }
UpdateActionFactory { public List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec) { DeployableServiceSpec currentServiceSpec = currentService.getSpec(); List<UpdateAction> actions = new ArrayList<UpdateAction>(); logger.info("Calculating changes on service spec \nOld = " + currentServiceSpec + "\nNew = " + newServiceSpec); if (currentServiceSpec.getNumberOfInstances() < newServiceSpec.getNumberOfInstances()) { UpdateAction action = new IncreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } else if (currentServiceSpec.getNumberOfInstances() > newServiceSpec.getNumberOfInstances()) { UpdateAction action = new DecreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } if (!(currentServiceSpec.getResourceImpact() == null || currentServiceSpec.getResourceImpact().getMemory() == null)) { if (!(currentServiceSpec.getResourceImpact().getMemory().ordinal() == newServiceSpec.getResourceImpact() .getMemory().ordinal())) { UpdateAction action = new Migrate(currentService, newServiceSpec); actions.add(action); } } logger.info("Detected changes: " + actions); return actions; }  List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec); }
UpdateActionFactory { public List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec) { DeployableServiceSpec currentServiceSpec = currentService.getSpec(); List<UpdateAction> actions = new ArrayList<UpdateAction>(); logger.info("Calculating changes on service spec \nOld = " + currentServiceSpec + "\nNew = " + newServiceSpec); if (currentServiceSpec.getNumberOfInstances() < newServiceSpec.getNumberOfInstances()) { UpdateAction action = new IncreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } else if (currentServiceSpec.getNumberOfInstances() > newServiceSpec.getNumberOfInstances()) { UpdateAction action = new DecreaseNumberOfReplicas(currentService, newServiceSpec); actions.add(action); } if (!(currentServiceSpec.getResourceImpact() == null || currentServiceSpec.getResourceImpact().getMemory() == null)) { if (!(currentServiceSpec.getResourceImpact().getMemory().ordinal() == newServiceSpec.getResourceImpact() .getMemory().ordinal())) { UpdateAction action = new Migrate(currentService, newServiceSpec); actions.add(action); } } logger.info("Detected changes: " + actions); return actions; }  List<UpdateAction> getActions(DeployableService currentService, DeployableServiceSpec newServiceSpec);  }