OffHeapConfigValidator implements ConfigValidator { protected boolean compareOffHeapResources(Map<String, ResourceType> oneMap, Map<String, ResourceType> otherMap) { Set<String> oneNameSet = oneMap.keySet(); Set<String> otherNameSet = otherMap.keySet(); if (!oneNameSet.equals(otherNameSet)) { return false; } for (ResourceType one : oneMap.values()) { if (!(compareOffHeapResourceSizes(one, otherMap.get(one.getName())))) { return false; } } return true; } OffHeapConfigValidator(Function<Element, OffheapResourcesType> resourcesTypeSupplier); void validateAgainst(Element oneFragment, Element otherFragment);  }
@Test public void testCompareOffHeapResources() { Function<Element, OffheapResourcesType> OffheapResourcesType = mock(Function.class); OffHeapConfigValidator validator = new OffHeapConfigValidator(OffheapResourcesType); ResourceType resourceType1 = new ResourceType(); resourceType1.setUnit(MemoryUnit.MB); resourceType1.setValue(BigInteger.valueOf(64L)); resourceType1.setName("resource1"); ResourceType resourceType2 = new ResourceType(); resourceType2.setUnit(MemoryUnit.MB); resourceType2.setValue(BigInteger.valueOf(128L)); resourceType2.setName("resource2"); ResourceType resourceType3 = new ResourceType(); resourceType3.setUnit(MemoryUnit.GB); resourceType3.setValue(BigInteger.valueOf(64L)); resourceType3.setName("resource3"); Map<String, ResourceType> input1 = new HashMap<>(); input1.put(resourceType1.getName(), resourceType1); input1.put(resourceType2.getName(), resourceType2); input1.put(resourceType3.getName(), resourceType3); ResourceType resourceType4 = new ResourceType(); resourceType4.setUnit(MemoryUnit.MB); resourceType4.setValue(BigInteger.valueOf(64L)); resourceType4.setName("resource1"); ResourceType resourceType5 = new ResourceType(); resourceType5.setUnit(MemoryUnit.MB); resourceType5.setValue(BigInteger.valueOf(128L)); resourceType5.setName("resource2"); ResourceType resourceType6 = new ResourceType(); resourceType6.setUnit(MemoryUnit.GB); resourceType6.setValue(BigInteger.valueOf(64L)); resourceType6.setName("resource3"); Map<String, ResourceType> input2 = new HashMap<>(); input2.put(resourceType4.getName(), resourceType4); input2.put(resourceType5.getName(), resourceType5); input2.put(resourceType6.getName(), resourceType6); boolean retValue = validator.compareOffHeapResources(input1, input2); assertThat(retValue, is(true)); resourceType6 = new ResourceType(); resourceType6.setUnit(MemoryUnit.GB); resourceType6.setValue(BigInteger.valueOf(64L)); resourceType6.setName("resource33"); input2.put(resourceType6.getName(), resourceType6); retValue = validator.compareOffHeapResources(input1, input2); assertThat(retValue, is(false)); }