Code example for ImmutableMap.Builder

Methods: build, put, putAll

0
                           .createTime(dateService.iso8601DateParse("2009-12-28T05:42:53.000Z")) 
                           .build(); 
    
   public void testCreateVolumeInAvailabilityZone() { 
      Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse>builder();
      builder.put(describeRegionsRequest, describeRegionsResponse);
      builder.putAll(describeAvailabilityZonesRequestResponse);
      builder.put(
            HttpRequest.builder()
                       .method("POST") 
                       .endpoint("https://ec2.us-east-1.amazonaws.com/") 
                       .addHeader("Host", "ec2.us-east-1.amazonaws.com") 
                       .payload(payloadFromStringWithContentType("Action=CreateVolume&AvailabilityZone=us-east-1a&Signature=FB5hTZHKSAuiygoafIdJh1EnfTu0ogC2VfRQOar85mg%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Size=4&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2010-06-15&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(), 
            HttpResponse.builder()
                        .statusCode(200) 
                        .payload(payloadFromResource("/created_volume.xml")).build()); 
       
      ElasticBlockStoreClient client = requestsSendResponses(builder.build()).getElasticBlockStoreServices();
 
      assertEquals(client.createVolumeInAvailabilityZone("us-east-1a", 4), creating);
   } 
    
   public void testCreateVolumeFromSnapshotInAvailabilityZoneEuSetsCorrectEndpoint() { 
      String region = "eu-west-1";
       
      Builder<HttpRequest, HttpResponse> builder = ImmutableMap.<HttpRequest, HttpResponse>builder();
      builder.put(describeRegionsRequest, describeRegionsResponse);
      builder.putAll(describeAvailabilityZonesRequestResponse);
      builder.put(
            formSigner.filter(HttpRequest.builder()
                                         .method("POST") 
                                         .endpoint("https://ec2." + region + ".amazonaws.com/")
                                         .addHeader("Host", "ec2." + region + ".amazonaws.com")
                                         .addFormParam("Action", "CreateVolume") 
                                         .addFormParam("AvailabilityZone", "eu-west-1a") 
                                         .addFormParam("Size", "1") 
                                         .addFormParam("SnapshotId", "snap-8b7ffbdd").build()), 
            HttpResponse.builder()
                        .statusCode(200) 
                        .payload(payloadFromResource("/created_volume.xml")).build()); 
       
      ElasticBlockStoreClient client = requestsSendResponses(builder.build()).getElasticBlockStoreServices();
 
      assertEquals(client.createVolumeFromSnapshotInAvailabilityZone(region + "a", 1, "snap-8b7ffbdd"), creating.toBuilder().region(region).build());
   } 
}