OffHeapConfigValidator implements ConfigValidator { protected boolean compareOffHeapResourceSizes(ResourceType oneResourceType, ResourceType otherResourceType) { return longValueExact(convert(oneResourceType.getValue(), oneResourceType.getUnit())) == longValueExact(convert(otherResourceType.getValue(), otherResourceType.getUnit())); } OffHeapConfigValidator(Function<Element, OffheapResourcesType> resourcesTypeSupplier); void validateAgainst(Element oneFragment, Element otherFragment);  }
@Test public void testCompareOffHeapResourceSizes() { ResourceType node11 = new ResourceType(); node11.setName("offHeap1"); node11.setValue(BigInteger.valueOf(1024L)); node11.setUnit(MemoryUnit.MB); ResourceType node12 = new ResourceType(); node12.setName("offHeap2"); node12.setValue(BigInteger.valueOf(512L)); node12.setUnit(MemoryUnit.MB); Function<Element, OffheapResourcesType> OffheapResourcesType = mock(Function.class); OffHeapConfigValidator validator = new OffHeapConfigValidator(OffheapResourcesType); boolean retValue = validator.compareOffHeapResourceSizes(node11, node12); assertThat(retValue, is(false)); node12 = new ResourceType(); node12.setName("offHeap2"); node12.setValue(BigInteger.valueOf(1024L)); for (MemoryUnit memoryUnit : MemoryUnit.values()) { node12.setUnit(memoryUnit); retValue = validator.compareOffHeapResourceSizes(node11, node12); if (memoryUnit == MemoryUnit.MB) { assertThat(retValue, is(true)); } else { assertThat(retValue, is(false)); } } }