Code example for ImmutableMap.Builder

Methods: build, put

0
 
      BindCloneVAppTemplateParamsToXmlPayload binder = injector
            .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); 
 
      Builder<String, Object> map = ImmutableMap.builder();
      map.put("name", "new-linux-server"); 
      map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"); 
 
      assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
   } 
 
   public void testWithDescriptionSourceDelete() throws IOException {
      String expected = toStringAndClose(getClass().getResourceAsStream("/moveVAppTemplate.xml"));
 
      CloneVAppTemplateOptions options = new CloneVAppTemplateOptions()
            .description("The description of the new vAppTemplate"); 
      GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(options));
 
      BindCloneVAppTemplateParamsToXmlPayload binder = injector
            .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); 
 
      Builder<String, Object> map = ImmutableMap.builder();
      map.put("name", "new-linux-server"); 
      map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"); 
      map.put("IsSourceDelete", "true"); 
 
      assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
   } 
 
   public void testDefault() throws IOException {
      String expected = toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate-default.xml"));
 
      GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of());
 
      BindCloneVAppTemplateParamsToXmlPayload binder = injector
            .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); 
 
      Builder<String, Object> map = ImmutableMap.builder();
      map.put("name", "my-vapptemplate"); 
      map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"); 
 
      assertEquals(binder.bindToRequest(request, map.build()).getPayload().getRawContent(), expected);
   } 
}