@Test public void testPopulateInstanceTypesForSelectedRegion_whenDescriptionIsEmpty() throws Exception { List<String> productDescriptions = new ArrayList<>(); PowerMockito.doReturn( productDescriptions ).when( pricingClient, "getProductDescriptions" ); List<String> instanceTypes = pricingClient.populateInstanceTypesForSelectedRegion(); Assert.assertNull( instanceTypes ); }
@Override public List<String> populateInstanceTypesForSelectedRegion() throws AWSPricingException, IOException { List<String> productDescriptions = getProductDescriptions(); if ( productDescriptions == null || productDescriptions.size() == 0 ) { return instanceTypes; } List<InstanceType> tmpInstanceTypes = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); String instanceTypeName; String instanceFamily; for ( String description : productDescriptions ) { instanceTypeName = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceType" ).asText(); instanceFamily = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceFamily" ).asText(); tmpInstanceTypes.add( new InstanceType( instanceTypeName, instanceFamily ) ); } instanceTypes = InstanceType.sortInstanceTypes( tmpInstanceTypes ); return instanceTypes; }
PricingClientImpl implements PricingClient { @Override public List<String> populateInstanceTypesForSelectedRegion() throws AWSPricingException, IOException { List<String> productDescriptions = getProductDescriptions(); if ( productDescriptions == null || productDescriptions.size() == 0 ) { return instanceTypes; } List<InstanceType> tmpInstanceTypes = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); String instanceTypeName; String instanceFamily; for ( String description : productDescriptions ) { instanceTypeName = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceType" ).asText(); instanceFamily = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceFamily" ).asText(); tmpInstanceTypes.add( new InstanceType( instanceTypeName, instanceFamily ) ); } instanceTypes = InstanceType.sortInstanceTypes( tmpInstanceTypes ); return instanceTypes; } }
PricingClientImpl implements PricingClient { @Override public List<String> populateInstanceTypesForSelectedRegion() throws AWSPricingException, IOException { List<String> productDescriptions = getProductDescriptions(); if ( productDescriptions == null || productDescriptions.size() == 0 ) { return instanceTypes; } List<InstanceType> tmpInstanceTypes = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); String instanceTypeName; String instanceFamily; for ( String description : productDescriptions ) { instanceTypeName = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceType" ).asText(); instanceFamily = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceFamily" ).asText(); tmpInstanceTypes.add( new InstanceType( instanceTypeName, instanceFamily ) ); } instanceTypes = InstanceType.sortInstanceTypes( tmpInstanceTypes ); return instanceTypes; } PricingClientImpl( AWSPricing pricing, String humanReadableRegion ); }
PricingClientImpl implements PricingClient { @Override public List<String> populateInstanceTypesForSelectedRegion() throws AWSPricingException, IOException { List<String> productDescriptions = getProductDescriptions(); if ( productDescriptions == null || productDescriptions.size() == 0 ) { return instanceTypes; } List<InstanceType> tmpInstanceTypes = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); String instanceTypeName; String instanceFamily; for ( String description : productDescriptions ) { instanceTypeName = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceType" ).asText(); instanceFamily = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceFamily" ).asText(); tmpInstanceTypes.add( new InstanceType( instanceTypeName, instanceFamily ) ); } instanceTypes = InstanceType.sortInstanceTypes( tmpInstanceTypes ); return instanceTypes; } PricingClientImpl( AWSPricing pricing, String humanReadableRegion ); @Override List<String> populateInstanceTypesForSelectedRegion(); }
PricingClientImpl implements PricingClient { @Override public List<String> populateInstanceTypesForSelectedRegion() throws AWSPricingException, IOException { List<String> productDescriptions = getProductDescriptions(); if ( productDescriptions == null || productDescriptions.size() == 0 ) { return instanceTypes; } List<InstanceType> tmpInstanceTypes = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); String instanceTypeName; String instanceFamily; for ( String description : productDescriptions ) { instanceTypeName = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceType" ).asText(); instanceFamily = mapper.readTree( description ).path( "product" ).get( "attributes" ).get( "instanceFamily" ).asText(); tmpInstanceTypes.add( new InstanceType( instanceTypeName, instanceFamily ) ); } instanceTypes = InstanceType.sortInstanceTypes( tmpInstanceTypes ); return instanceTypes; } PricingClientImpl( AWSPricing pricing, String humanReadableRegion ); @Override List<String> populateInstanceTypesForSelectedRegion();  }