### Question:
ResourceSpec implements Serializable { public boolean lessThanOrEqual(@Nonnull ResourceSpec other) { int cmp1 = Double.compare(this.cpuCores, other.cpuCores); int cmp2 = Integer.compare(this.heapMemoryInMB, other.heapMemoryInMB); int cmp3 = Integer.compare(this.directMemoryInMB, other.directMemoryInMB); int cmp4 = Integer.compare(this.nativeMemoryInMB, other.nativeMemoryInMB); int cmp5 = Integer.compare(this.stateSizeInMB, other.stateSizeInMB); if (cmp1 <= 0 && cmp2 <= 0 && cmp3 <= 0 && cmp4 <= 0 && cmp5 <= 0) { for (Resource resource : extendedResources.values()) { if (!other.extendedResources.containsKey(resource.getName()) || other.extendedResources.get(resource.getName()).getResourceAggregateType() != resource.getResourceAggregateType() || other.extendedResources.get(resource.getName()).getValue() < resource.getValue()) { return false; } } return true; } return false; } protected  ResourceSpec(
			double cpuCores,
			int heapMemoryInMB,
			int directMemoryInMB,
			int nativeMemoryInMB,
			int stateSizeInMB,
			Resource... extendedResources); ResourceSpec merge(ResourceSpec other); double getCpuCores(); int getHeapMemory(); int getDirectMemory(); int getNativeMemory(); int getStateSize(); double getGPUResource(); Map<String, Resource> getExtendedResources(); boolean isValid(); boolean lessThanOrEqual(@Nonnull ResourceSpec other); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static Builder newBuilder(); static final ResourceSpec DEFAULT; static final String GPU_NAME; }### Answer:
@Test public void testLessThanOrEqual() throws Exception { ResourceSpec rs1 = ResourceSpec.newBuilder().setCpuCores(1.0).setHeapMemoryInMB(100).build(); ResourceSpec rs2 = ResourceSpec.newBuilder().setCpuCores(1.0).setHeapMemoryInMB(100).build(); assertTrue(rs1.lessThanOrEqual(rs2)); assertTrue(rs2.lessThanOrEqual(rs1)); ResourceSpec rs3 = ResourceSpec.newBuilder(). setCpuCores(1.0). setHeapMemoryInMB(100). setGPUResource(1.1). build(); assertTrue(rs1.lessThanOrEqual(rs3)); assertFalse(rs3.lessThanOrEqual(rs1)); ResourceSpec rs4 = ResourceSpec.newBuilder(). setCpuCores(1.0). setHeapMemoryInMB(100). setGPUResource(2.2). build(); assertFalse(rs4.lessThanOrEqual(rs3)); assertTrue(rs3.lessThanOrEqual(rs4)); }