@Test public void testCreatePayload() { CreateServerRequestBinder binder = new CreateServerRequestBinder(); Server.Request.CreatePayload payload = Server.Request.creatingBuilder() .name("jclouds-node") .cores(4) .ram(4 * 1024) .dataCenterId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .build(); String actual = binder.createPayload(payload); assertNotNull(actual, "Binder returned null payload"); assertEquals(actual, expectedPayload); }
@Override protected String createPayload(Server.Request.CreatePayload payload) { requestBuilder.append("<ws:createServer>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.dataCenterId())) .append(format("<cores>%s</cores>", payload.cores())) .append(format("<ram>%s</ram>", payload.ram())) .append(formatIfNotEmpty("<serverName>%s</serverName>", payload.name())) .append(formatIfNotEmpty("<bootFromStorageId>%s</bootFromStorageId>", payload.bootFromStorageId())) .append(formatIfNotEmpty("<bootFromImageId>%s</bootFromImageId>", payload.bootFromImageId())) .append(formatIfNotEmpty("<internetAccess>%s</internetAccess>", payload.hasInternetAccess())) .append(formatIfNotEmpty("<lanId>%s</lanId>", payload.lanId())) .append(formatIfNotEmpty("<osType>%s</osType>", payload.osType())) .append(formatIfNotEmpty("<availabilityZone>%s</availabilityZone>", payload.availabilityZone())) .append(formatIfNotEmpty("<cpuHotPlug>%s</cpuHotPlug>", payload.isCpuHotPlug())) .append(formatIfNotEmpty("<ramHotPlug>%s</ramHotPlug>", payload.isRamHotPlug())) .append(formatIfNotEmpty("<nicHotPlug>%s</nicHotPlug>", payload.isNicHotPlug())) .append(formatIfNotEmpty("<nicHotUnPlug>%s</nicHotUnPlug>", payload.isNicHotUnPlug())) .append(formatIfNotEmpty("<discVirtioHotPlug>%s</discVirtioHotPlug>", payload.isDiscVirtioHotPlug())) .append(formatIfNotEmpty("<discVirtioHotUnPlug>%s</discVirtioHotUnPlug>", payload.isDiscVirtioHotUnPlug())) .append("</request>") .append("</ws:createServer>"); return requestBuilder.toString(); }
CreateServerRequestBinder extends BaseProfitBricksRequestBinder<Server.Request.CreatePayload> { @Override protected String createPayload(Server.Request.CreatePayload payload) { requestBuilder.append("<ws:createServer>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.dataCenterId())) .append(format("<cores>%s</cores>", payload.cores())) .append(format("<ram>%s</ram>", payload.ram())) .append(formatIfNotEmpty("<serverName>%s</serverName>", payload.name())) .append(formatIfNotEmpty("<bootFromStorageId>%s</bootFromStorageId>", payload.bootFromStorageId())) .append(formatIfNotEmpty("<bootFromImageId>%s</bootFromImageId>", payload.bootFromImageId())) .append(formatIfNotEmpty("<internetAccess>%s</internetAccess>", payload.hasInternetAccess())) .append(formatIfNotEmpty("<lanId>%s</lanId>", payload.lanId())) .append(formatIfNotEmpty("<osType>%s</osType>", payload.osType())) .append(formatIfNotEmpty("<availabilityZone>%s</availabilityZone>", payload.availabilityZone())) .append(formatIfNotEmpty("<cpuHotPlug>%s</cpuHotPlug>", payload.isCpuHotPlug())) .append(formatIfNotEmpty("<ramHotPlug>%s</ramHotPlug>", payload.isRamHotPlug())) .append(formatIfNotEmpty("<nicHotPlug>%s</nicHotPlug>", payload.isNicHotPlug())) .append(formatIfNotEmpty("<nicHotUnPlug>%s</nicHotUnPlug>", payload.isNicHotUnPlug())) .append(formatIfNotEmpty("<discVirtioHotPlug>%s</discVirtioHotPlug>", payload.isDiscVirtioHotPlug())) .append(formatIfNotEmpty("<discVirtioHotUnPlug>%s</discVirtioHotUnPlug>", payload.isDiscVirtioHotUnPlug())) .append("</request>") .append("</ws:createServer>"); return requestBuilder.toString(); } }
CreateServerRequestBinder extends BaseProfitBricksRequestBinder<Server.Request.CreatePayload> { @Override protected String createPayload(Server.Request.CreatePayload payload) { requestBuilder.append("<ws:createServer>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.dataCenterId())) .append(format("<cores>%s</cores>", payload.cores())) .append(format("<ram>%s</ram>", payload.ram())) .append(formatIfNotEmpty("<serverName>%s</serverName>", payload.name())) .append(formatIfNotEmpty("<bootFromStorageId>%s</bootFromStorageId>", payload.bootFromStorageId())) .append(formatIfNotEmpty("<bootFromImageId>%s</bootFromImageId>", payload.bootFromImageId())) .append(formatIfNotEmpty("<internetAccess>%s</internetAccess>", payload.hasInternetAccess())) .append(formatIfNotEmpty("<lanId>%s</lanId>", payload.lanId())) .append(formatIfNotEmpty("<osType>%s</osType>", payload.osType())) .append(formatIfNotEmpty("<availabilityZone>%s</availabilityZone>", payload.availabilityZone())) .append(formatIfNotEmpty("<cpuHotPlug>%s</cpuHotPlug>", payload.isCpuHotPlug())) .append(formatIfNotEmpty("<ramHotPlug>%s</ramHotPlug>", payload.isRamHotPlug())) .append(formatIfNotEmpty("<nicHotPlug>%s</nicHotPlug>", payload.isNicHotPlug())) .append(formatIfNotEmpty("<nicHotUnPlug>%s</nicHotUnPlug>", payload.isNicHotUnPlug())) .append(formatIfNotEmpty("<discVirtioHotPlug>%s</discVirtioHotPlug>", payload.isDiscVirtioHotPlug())) .append(formatIfNotEmpty("<discVirtioHotUnPlug>%s</discVirtioHotUnPlug>", payload.isDiscVirtioHotUnPlug())) .append("</request>") .append("</ws:createServer>"); return requestBuilder.toString(); } CreateServerRequestBinder(); }
CreateServerRequestBinder extends BaseProfitBricksRequestBinder<Server.Request.CreatePayload> { @Override protected String createPayload(Server.Request.CreatePayload payload) { requestBuilder.append("<ws:createServer>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.dataCenterId())) .append(format("<cores>%s</cores>", payload.cores())) .append(format("<ram>%s</ram>", payload.ram())) .append(formatIfNotEmpty("<serverName>%s</serverName>", payload.name())) .append(formatIfNotEmpty("<bootFromStorageId>%s</bootFromStorageId>", payload.bootFromStorageId())) .append(formatIfNotEmpty("<bootFromImageId>%s</bootFromImageId>", payload.bootFromImageId())) .append(formatIfNotEmpty("<internetAccess>%s</internetAccess>", payload.hasInternetAccess())) .append(formatIfNotEmpty("<lanId>%s</lanId>", payload.lanId())) .append(formatIfNotEmpty("<osType>%s</osType>", payload.osType())) .append(formatIfNotEmpty("<availabilityZone>%s</availabilityZone>", payload.availabilityZone())) .append(formatIfNotEmpty("<cpuHotPlug>%s</cpuHotPlug>", payload.isCpuHotPlug())) .append(formatIfNotEmpty("<ramHotPlug>%s</ramHotPlug>", payload.isRamHotPlug())) .append(formatIfNotEmpty("<nicHotPlug>%s</nicHotPlug>", payload.isNicHotPlug())) .append(formatIfNotEmpty("<nicHotUnPlug>%s</nicHotUnPlug>", payload.isNicHotUnPlug())) .append(formatIfNotEmpty("<discVirtioHotPlug>%s</discVirtioHotPlug>", payload.isDiscVirtioHotPlug())) .append(formatIfNotEmpty("<discVirtioHotUnPlug>%s</discVirtioHotUnPlug>", payload.isDiscVirtioHotUnPlug())) .append("</request>") .append("</ws:createServer>"); return requestBuilder.toString(); } CreateServerRequestBinder();  }
CreateServerRequestBinder extends BaseProfitBricksRequestBinder<Server.Request.CreatePayload> { @Override protected String createPayload(Server.Request.CreatePayload payload) { requestBuilder.append("<ws:createServer>") .append("<request>") .append(format("<dataCenterId>%s</dataCenterId>", payload.dataCenterId())) .append(format("<cores>%s</cores>", payload.cores())) .append(format("<ram>%s</ram>", payload.ram())) .append(formatIfNotEmpty("<serverName>%s</serverName>", payload.name())) .append(formatIfNotEmpty("<bootFromStorageId>%s</bootFromStorageId>", payload.bootFromStorageId())) .append(formatIfNotEmpty("<bootFromImageId>%s</bootFromImageId>", payload.bootFromImageId())) .append(formatIfNotEmpty("<internetAccess>%s</internetAccess>", payload.hasInternetAccess())) .append(formatIfNotEmpty("<lanId>%s</lanId>", payload.lanId())) .append(formatIfNotEmpty("<osType>%s</osType>", payload.osType())) .append(formatIfNotEmpty("<availabilityZone>%s</availabilityZone>", payload.availabilityZone())) .append(formatIfNotEmpty("<cpuHotPlug>%s</cpuHotPlug>", payload.isCpuHotPlug())) .append(formatIfNotEmpty("<ramHotPlug>%s</ramHotPlug>", payload.isRamHotPlug())) .append(formatIfNotEmpty("<nicHotPlug>%s</nicHotPlug>", payload.isNicHotPlug())) .append(formatIfNotEmpty("<nicHotUnPlug>%s</nicHotUnPlug>", payload.isNicHotUnPlug())) .append(formatIfNotEmpty("<discVirtioHotPlug>%s</discVirtioHotPlug>", payload.isDiscVirtioHotPlug())) .append(formatIfNotEmpty("<discVirtioHotUnPlug>%s</discVirtioHotUnPlug>", payload.isDiscVirtioHotUnPlug())) .append("</request>") .append("</ws:createServer>"); return requestBuilder.toString(); } CreateServerRequestBinder();   }