### Question:
AllocationIdUtil { public static Set<Allocation> getOutdatedAllocations(final TestDefinition previous, final TestDefinition current) { final boolean hasAllocId = current.getAllocations().stream().anyMatch( x -> !StringUtils.isEmpty(x.getId()) ); final Set<Allocation> outdatedAllocations = new HashSet<>(); if (!hasAllocId) { return outdatedAllocations; } final int updateFrom = getSegmentationChangeStartIndex(previous, current); if (updateFrom > -1) { for (int i = updateFrom; i < current.getAllocations().size(); i++) { if (!StringUtils.isEmpty(current.getAllocations().get(i).getId())) { outdatedAllocations.add(current.getAllocations().get(i)); } } } final int ratioCheckTo = updateFrom > -1 ? updateFrom : Math.min(previous.getAllocations().size(), current.getAllocations().size()); for (int i = 0; i < ratioCheckTo; i++) { if (isUnbalancedRatioChange(previous.getAllocations().get(i), current.getAllocations().get(i))) { outdatedAllocations.add(current.getAllocations().get(i)); } } return outdatedAllocations; }  static String getAllocationName(final String allocId); static Set<Allocation> getOutdatedAllocations(final TestDefinition previous, final TestDefinition current); static String getNextVersionOfAllocationId(final String allocId); static String generateAllocationId(final int index, final int version); static int convertBase26ToDecimal(final char[] chars); static final Comparator<String> ALLOCATION_ID_COMPARATOR; }### Answer:
@Test public void testGetOutdatedAllocations() { final TestDefinition previous = createSampleTestDefinition(); TestDefinition current = createSampleTestDefinition(); assertEquals(new HashSet<>(), AllocationIdUtil.getOutdatedAllocations(previous, current)); current = createSampleTestDefinition(); current.setRule("${lang=en}"); assertEquals(new HashSet<>(Lists.newArrayList(current.getAllocations().get(0), current.getAllocations().get(1))), AllocationIdUtil.getOutdatedAllocations(previous, current)); current = createSampleTestDefinition(); current.setSalt("newSalt"); assertEquals(new HashSet<>(Lists.newArrayList(current.getAllocations().get(0), current.getAllocations().get(1))), AllocationIdUtil.getOutdatedAllocations(previous, current)); current = createSampleTestDefinition(); current.getAllocations().get(0).setRule("newRule"); assertEquals(new HashSet<>(Lists.newArrayList(current.getAllocations().get(0), current.getAllocations().get(1))), AllocationIdUtil.getOutdatedAllocations(previous, current)); current = createSampleTestDefinition(); current.getAllocations().add(1, new Allocation()); assertEquals(new HashSet<>(Lists.newArrayList(current.getAllocations().get(2))), AllocationIdUtil.getOutdatedAllocations(previous, current)); current = createSampleTestDefinition(); current.getAllocations().remove(0); assertEquals(new HashSet<>(Lists.newArrayList(current.getAllocations().get(0))), AllocationIdUtil.getOutdatedAllocations(previous, current)); current = createSampleTestDefinition(); current.getAllocations().get(0).setRanges(Lists.newArrayList(new Range(0, 0.2d), new Range(1, 0.8d))); assertEquals(new HashSet<>(Lists.newArrayList(current.getAllocations().get(0))), AllocationIdUtil.getOutdatedAllocations(previous, current)); current = createSampleTestDefinition(); current.getAllocations().add(new Allocation()); assertEquals(new HashSet<>(), AllocationIdUtil.getOutdatedAllocations(previous, current)); current = createSampleTestDefinition(); current.getAllocations().remove(1); assertEquals(new HashSet<>(), AllocationIdUtil.getOutdatedAllocations(previous, current)); }