@Test public void testVirtualGuestWithVirtualGuestBlockDeviceTemplateGroup() { HttpRequest request = HttpRequest.builder().method("POST").endpoint("https: VirtualGuestToJson binder = new VirtualGuestToJson(json); VirtualGuest virtualGuestWithVirtualGuestBlockDeviceTemplateGroup = VirtualGuest.builder() .hostname("hostname") .domain("domain") .startCpus(1) .maxMemory(1024) .datacenter(Datacenter.builder() .name("datacenterName") .build()) .blockDeviceTemplateGroup(VirtualGuestBlockDeviceTemplateGroup.builder() .globalIdentifier("ffaafa98-4b4a-4fa7-b9f7-b1bad5ec50f0") .build()) .localDiskFlag(true) .networkComponents(ImmutableSet.<VirtualGuestNetworkComponent>of()) .build(); request = binder.bindToRequest(request, virtualGuestWithVirtualGuestBlockDeviceTemplateGroup); assertEquals(request.getPayload().getRawContent(), "{" + "\"parameters\":[{" + "\"hostname\":\"hostname\"," + "\"domain\":\"domain\"," + "\"startCpus\":1," + "\"maxMemory\":1024," + "\"hourlyBillingFlag\":false," + "\"localDiskFlag\":true," + "\"dedicatedAccountHostOnlyFlag\":false," + "\"privateNetworkOnlyFlag\":false," + "\"blockDeviceTemplateGroup\":{\"globalIdentifier\":\"ffaafa98-4b4a-4fa7-b9f7-b1bad5ec50f0\"}," + "\"datacenter\":{\"name\":\"datacenterName\"}}]}"); }
@Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(input instanceof VirtualGuest); VirtualGuest virtualGuest = VirtualGuest.class.cast(checkNotNull(input, "input")); request.setPayload(buildJson(virtualGuest)); return request; }
VirtualGuestToJson implements Binder { @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(input instanceof VirtualGuest); VirtualGuest virtualGuest = VirtualGuest.class.cast(checkNotNull(input, "input")); request.setPayload(buildJson(virtualGuest)); return request; } }
VirtualGuestToJson implements Binder { @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(input instanceof VirtualGuest); VirtualGuest virtualGuest = VirtualGuest.class.cast(checkNotNull(input, "input")); request.setPayload(buildJson(virtualGuest)); return request; } @Inject  VirtualGuestToJson(Json json); }
VirtualGuestToJson implements Binder { @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(input instanceof VirtualGuest); VirtualGuest virtualGuest = VirtualGuest.class.cast(checkNotNull(input, "input")); request.setPayload(buildJson(virtualGuest)); return request; } @Inject  VirtualGuestToJson(Json json); @Override R bindToRequest(R request, Object input); }
VirtualGuestToJson implements Binder { @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) { checkArgument(input instanceof VirtualGuest); VirtualGuest virtualGuest = VirtualGuest.class.cast(checkNotNull(input, "input")); request.setPayload(buildJson(virtualGuest)); return request; } @Inject  VirtualGuestToJson(Json json); @Override R bindToRequest(R request, Object input); static final String USER_DATA_KEY; }