ContainerQuota { public Quota get( ContainerResourceType containerResourceType ) { return getResources().get( containerResourceType ); } ContainerQuota( @JsonProperty( value = "containerSize" ) final ContainerSize containerSize,
                           @JsonProperty( value = "resources" ) final Map<ContainerResourceType, Quota> resources );  ContainerQuota( ContainerSize containerSize );  ContainerQuota( ContainerSize containerSize, Quota quota );  ContainerQuota( ContainerSize containerSize, Quota... quotas ); void add( Quota quota ); void addAll( final List<Quota> quota ); void copyValues( final ContainerQuota containerQuota ); Quota get( ContainerResourceType containerResourceType ); ContainerSize getContainerSize(); @JsonIgnore Collection<Quota> getAll(); @Override String toString();  }
@Test public void testQuota() throws IOException { String json = "{\"resources\":{\"RAM\":{\"resource\":{\"type\":\"ram\",\"value\":\"512.000MiB\"}," + "\"threshold\":0},\"DISK\":{\"resource\":{\"type\":\"disk\",\"value\":\"1024.00000KiB\"}," + "\"threshold\":0},\"CPU\":{\"resource\":{\"type\":\"cpu\",\"value\":\"25%\"},\"threshold\":0}}}"; ObjectMapper mapper = new ObjectMapper(); ContainerQuota quota = mapper.readValue( json, ContainerQuota.class ); assertEquals( 512.0, quota.get( ContainerResourceType.RAM ).getAsRamResource().getResource().getValue( ByteUnit.MB ) .doubleValue() ); assertEquals( 25.0, quota.get( ContainerResourceType.CPU ).getAsCpuResource().getResource().getValue().doubleValue() ); assertEquals( 1.0, quota.get( ContainerResourceType.DISK ).getAsDiskResource().getResource().getValue( ByteUnit.MB ) .doubleValue() ); }
@Test public void testQuota1() throws IOException { String json = "{\"containerSize\":\"SMALL\",\"resources\":{\"RAM\":{\"resource\":{\"type\":\"ram\"," + "\"value\":\"512.000MiB\"},\"threshold\":0},\"DISK\":{\"resource\":{\"type\":\"disk\"," + "\"value\":\"1.00000GiB\"},\"threshold\":0},\"CPU\":{\"resource\":{\"type\":\"cpu\"," + "\"value\":\"25%\"},\"threshold\":0},\"NET\":{\"resource\":{\"type\":\"net\"," + "\"value\":\"100.000000Kbps\"},\"threshold\":0},\"CPUSET\":{\"resource\":{\"type\":\"cpuset\"," + "\"value\":\"0-7\"},\"threshold\":0}}}"; ObjectMapper mapper = new ObjectMapper(); ContainerQuota quota = mapper.readValue( json, ContainerQuota.class ); assertEquals( 512.0, quota.get( ContainerResourceType.RAM ).getAsRamResource().getResource().getValue( ByteUnit.MB ) .doubleValue() ); assertEquals( 25.0, quota.get( ContainerResourceType.CPU ).getAsCpuResource().getResource().getValue().doubleValue() ); assertEquals( 1.0, quota.get( ContainerResourceType.DISK ).getAsDiskResource().getResource().getValue( ByteUnit.GB ) .doubleValue() ); assertEquals( "0-7", quota.get( ContainerResourceType.CPUSET ).getAsCpuSetResource().getResource().getValue() ); assertEquals( 100.0D, quota.get( ContainerResourceType.NET ).getAsNetResource().getResource().getValue().doubleValue() ); }