@Test public void testChanges() { List<ServiceType> oldServices = Arrays.asList(random1, random); List<ServiceType> newServices = Arrays.asList(foo1, random1); ServiceChangeChecker.ServiceChanges changes = serviceChangeChecker.check(oldServices, newServices); assertFalse(changes.isEmpty()); assertEquals(Arrays.asList("fooService.v1"), changes.getAddedFullServiceCodes()); assertEquals(Arrays.asList("getRandom"), changes.getRemovedFullServiceCodes()); List<ServiceType> allServices = Arrays.asList(random1, random, random2, foo1); List<String> allCodes = Arrays.asList("getRandom", "getRandom.v1", "getRandom.v2", "fooService.v1"); List<ServiceType> noServices = new ArrayList<>(); changes = serviceChangeChecker.check(noServices, allServices); assertFalse(changes.isEmpty()); assertEquals(new HashSet<>(allCodes), new HashSet<>(changes.getAddedFullServiceCodes())); assertEquals(new HashSet<>(), new HashSet<>(changes.getRemovedFullServiceCodes())); changes = serviceChangeChecker.check(allServices, noServices); assertFalse(changes.isEmpty()); assertEquals(new HashSet<>(), new HashSet<>(changes.getAddedFullServiceCodes())); assertEquals(new HashSet<>(allCodes), new HashSet<>(changes.getRemovedFullServiceCodes())); }
public ServiceChanges check(List<ServiceType> oldServices, List<ServiceType> newServices) { List<String> oldFullServiceCodes = toFullServiceCodes(oldServices); List<String> newFullServiceCodes = toFullServiceCodes(newServices); List<ServiceType> addedServices = new ArrayList<>(newServices); addedServices.removeIf(serviceType -> oldFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); List<ServiceType> removedServices = new ArrayList<>(oldServices); removedServices.removeIf(serviceType -> newFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); return new ServiceChanges(addedServices, removedServices); }
ServiceChangeChecker { public ServiceChanges check(List<ServiceType> oldServices, List<ServiceType> newServices) { List<String> oldFullServiceCodes = toFullServiceCodes(oldServices); List<String> newFullServiceCodes = toFullServiceCodes(newServices); List<ServiceType> addedServices = new ArrayList<>(newServices); addedServices.removeIf(serviceType -> oldFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); List<ServiceType> removedServices = new ArrayList<>(oldServices); removedServices.removeIf(serviceType -> newFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); return new ServiceChanges(addedServices, removedServices); } }
ServiceChangeChecker { public ServiceChanges check(List<ServiceType> oldServices, List<ServiceType> newServices) { List<String> oldFullServiceCodes = toFullServiceCodes(oldServices); List<String> newFullServiceCodes = toFullServiceCodes(newServices); List<ServiceType> addedServices = new ArrayList<>(newServices); addedServices.removeIf(serviceType -> oldFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); List<ServiceType> removedServices = new ArrayList<>(oldServices); removedServices.removeIf(serviceType -> newFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); return new ServiceChanges(addedServices, removedServices); }  }
ServiceChangeChecker { public ServiceChanges check(List<ServiceType> oldServices, List<ServiceType> newServices) { List<String> oldFullServiceCodes = toFullServiceCodes(oldServices); List<String> newFullServiceCodes = toFullServiceCodes(newServices); List<ServiceType> addedServices = new ArrayList<>(newServices); addedServices.removeIf(serviceType -> oldFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); List<ServiceType> removedServices = new ArrayList<>(oldServices); removedServices.removeIf(serviceType -> newFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); return new ServiceChanges(addedServices, removedServices); }  ServiceChanges check(List<ServiceType> oldServices, List<ServiceType> newServices); }
ServiceChangeChecker { public ServiceChanges check(List<ServiceType> oldServices, List<ServiceType> newServices) { List<String> oldFullServiceCodes = toFullServiceCodes(oldServices); List<String> newFullServiceCodes = toFullServiceCodes(newServices); List<ServiceType> addedServices = new ArrayList<>(newServices); addedServices.removeIf(serviceType -> oldFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); List<ServiceType> removedServices = new ArrayList<>(oldServices); removedServices.removeIf(serviceType -> newFullServiceCodes .contains(FormatUtils.getServiceFullName(serviceType))); return new ServiceChanges(addedServices, removedServices); }  ServiceChanges check(List<ServiceType> oldServices, List<ServiceType> newServices);  }