ResourceProfile implements Serializable, Comparable<ResourceProfile> { public boolean isMatching(ResourceProfile required) { return cpuCores >= required.getCpuCores() && heapMemoryInMB >= required.getHeapMemoryInMB() && directMemoryInMB >= required.getDirectMemoryInMB() && nativeMemoryInMB >= required.getNativeMemoryInMB(); } ResourceProfile(
			double cpuCores,
			int heapMemoryInMB,
			int directMemoryInMB,
			int nativeMemoryInMB);  ResourceProfile(double cpuCores, int heapMemoryInMB);  ResourceProfile(ResourceProfile other); double getCpuCores(); long getHeapMemoryInMB(); int getDirectMemoryInMB(); int getNativeMemoryInMB(); int getMemoryInMB(); boolean isMatching(ResourceProfile required); @Override int compareTo(@Nonnull ResourceProfile other); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static final ResourceProfile UNKNOWN; }
@Test public void testMatchRequirement() throws Exception { ResourceProfile rp1 = new ResourceProfile(1.0, 100, 100, 100); ResourceProfile rp2 = new ResourceProfile(1.0, 200, 200, 200); ResourceProfile rp3 = new ResourceProfile(2.0, 100, 100, 100); ResourceProfile rp4 = new ResourceProfile(2.0, 200, 200, 200); assertFalse(rp1.isMatching(rp2)); assertTrue(rp2.isMatching(rp1)); assertFalse(rp1.isMatching(rp3)); assertTrue(rp3.isMatching(rp1)); assertFalse(rp2.isMatching(rp3)); assertFalse(rp3.isMatching(rp2)); assertTrue(rp4.isMatching(rp1)); assertTrue(rp4.isMatching(rp2)); assertTrue(rp4.isMatching(rp3)); assertTrue(rp4.isMatching(rp4)); }
@Test public void testUnknownMatchesUnknown() { assertTrue(ResourceProfile.UNKNOWN.isMatching(ResourceProfile.UNKNOWN)); }