@Test public void testCreatesVM() throws Exception { Map<String, String> resultMap = new HashMap<>(); whenNew(VmService.class).withNoArguments().thenReturn(vmServiceMock); when(vmServiceMock.createVM(any(HttpInputs.class), any(VmInputs.class))).thenReturn(resultMap); resultMap = createVM.createVM("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", null); verify(vmServiceMock, times(1)).createVM(any(HttpInputs.class), any(VmInputs.class)); assertNotNull(resultMap); }
@Action(name = "Create Virtual Machine", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createVM(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = DATA_CENTER_NAME, required = true) String dataCenterName, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME, required = true) String virtualMachineName, @Param(value = DATA_STORE, required = true) String dataStore, @Param(value = GUEST_OS_ID, required = true) String guestOsId, @Param(value = FOLDER_NAME) String folderName, @Param(value = RESOURCE_POOL) String resourcePool, @Param(value = VM_DESCRIPTION) String description, @Param(value = VM_CPU_COUNT) String numCPUs, @Param(value = VM_DISK_SIZE) String vmDiskSize, @Param(value = VM_MEMORY_SIZE) String vmMemorySize, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withDataCenterName(dataCenterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withDescription(description) .withDataStore(dataStore) .withGuestOsId(guestOsId) .withFolderName(folderName) .withResourcePool(resourcePool) .withDescription(description) .withGuestOsId(guestOsId) .withDescription(description) .withIntNumCPUs(numCPUs) .withLongVmDiskSize(vmDiskSize) .withLongVmMemorySize(vmMemorySize) .build(); return new VmService().createVM(httpInputs, vmInputs); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }
CreateVM { @Action(name = "Create Virtual Machine", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createVM(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = DATA_CENTER_NAME, required = true) String dataCenterName, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME, required = true) String virtualMachineName, @Param(value = DATA_STORE, required = true) String dataStore, @Param(value = GUEST_OS_ID, required = true) String guestOsId, @Param(value = FOLDER_NAME) String folderName, @Param(value = RESOURCE_POOL) String resourcePool, @Param(value = VM_DESCRIPTION) String description, @Param(value = VM_CPU_COUNT) String numCPUs, @Param(value = VM_DISK_SIZE) String vmDiskSize, @Param(value = VM_MEMORY_SIZE) String vmMemorySize, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withDataCenterName(dataCenterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withDescription(description) .withDataStore(dataStore) .withGuestOsId(guestOsId) .withFolderName(folderName) .withResourcePool(resourcePool) .withDescription(description) .withGuestOsId(guestOsId) .withDescription(description) .withIntNumCPUs(numCPUs) .withLongVmDiskSize(vmDiskSize) .withLongVmMemorySize(vmMemorySize) .build(); return new VmService().createVM(httpInputs, vmInputs); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } } }
CreateVM { @Action(name = "Create Virtual Machine", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createVM(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = DATA_CENTER_NAME, required = true) String dataCenterName, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME, required = true) String virtualMachineName, @Param(value = DATA_STORE, required = true) String dataStore, @Param(value = GUEST_OS_ID, required = true) String guestOsId, @Param(value = FOLDER_NAME) String folderName, @Param(value = RESOURCE_POOL) String resourcePool, @Param(value = VM_DESCRIPTION) String description, @Param(value = VM_CPU_COUNT) String numCPUs, @Param(value = VM_DISK_SIZE) String vmDiskSize, @Param(value = VM_MEMORY_SIZE) String vmMemorySize, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withDataCenterName(dataCenterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withDescription(description) .withDataStore(dataStore) .withGuestOsId(guestOsId) .withFolderName(folderName) .withResourcePool(resourcePool) .withDescription(description) .withGuestOsId(guestOsId) .withDescription(description) .withIntNumCPUs(numCPUs) .withLongVmDiskSize(vmDiskSize) .withLongVmMemorySize(vmMemorySize) .build(); return new VmService().createVM(httpInputs, vmInputs); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }  }
CreateVM { @Action(name = "Create Virtual Machine", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createVM(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = DATA_CENTER_NAME, required = true) String dataCenterName, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME, required = true) String virtualMachineName, @Param(value = DATA_STORE, required = true) String dataStore, @Param(value = GUEST_OS_ID, required = true) String guestOsId, @Param(value = FOLDER_NAME) String folderName, @Param(value = RESOURCE_POOL) String resourcePool, @Param(value = VM_DESCRIPTION) String description, @Param(value = VM_CPU_COUNT) String numCPUs, @Param(value = VM_DISK_SIZE) String vmDiskSize, @Param(value = VM_MEMORY_SIZE) String vmMemorySize, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withDataCenterName(dataCenterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withDescription(description) .withDataStore(dataStore) .withGuestOsId(guestOsId) .withFolderName(folderName) .withResourcePool(resourcePool) .withDescription(description) .withGuestOsId(guestOsId) .withDescription(description) .withIntNumCPUs(numCPUs) .withLongVmDiskSize(vmDiskSize) .withLongVmMemorySize(vmMemorySize) .build(); return new VmService().createVM(httpInputs, vmInputs); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }  @Action(name = "Create Virtual Machine", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) Map<String, String> createVM(@Param(value = HOST, required = true) String host,
                                        @Param(value = PORT) String port,
                                        @Param(value = PROTOCOL) String protocol,
                                        @Param(value = USERNAME, required = true) String username,
                                        @Param(value = PASSWORD, encrypted = true) String password,
                                        @Param(value = TRUST_EVERYONE) String trustEveryone,
                                        @Param(value = CLOSE_SESSION) String closeSession,

                                        @Param(value = DATA_CENTER_NAME, required = true) String dataCenterName,
                                        @Param(value = HOSTNAME, required = true) String hostname,
                                        @Param(value = VM_NAME, required = true) String virtualMachineName,
                                        @Param(value = DATA_STORE, required = true) String dataStore,
                                        @Param(value = GUEST_OS_ID, required = true) String guestOsId,
                                        @Param(value = FOLDER_NAME) String folderName,
                                        @Param(value = RESOURCE_POOL) String resourcePool,
                                        @Param(value = VM_DESCRIPTION) String description,
                                        @Param(value = VM_CPU_COUNT) String numCPUs,
                                        @Param(value = VM_DISK_SIZE) String vmDiskSize,
                                        @Param(value = VM_MEMORY_SIZE) String vmMemorySize,
                                        @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject); }
CreateVM { @Action(name = "Create Virtual Machine", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) public Map<String, String> createVM(@Param(value = HOST, required = true) String host, @Param(value = PORT) String port, @Param(value = PROTOCOL) String protocol, @Param(value = USERNAME, required = true) String username, @Param(value = PASSWORD, encrypted = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = DATA_CENTER_NAME, required = true) String dataCenterName, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME, required = true) String virtualMachineName, @Param(value = DATA_STORE, required = true) String dataStore, @Param(value = GUEST_OS_ID, required = true) String guestOsId, @Param(value = FOLDER_NAME) String folderName, @Param(value = RESOURCE_POOL) String resourcePool, @Param(value = VM_DESCRIPTION) String description, @Param(value = VM_CPU_COUNT) String numCPUs, @Param(value = VM_DISK_SIZE) String vmDiskSize, @Param(value = VM_MEMORY_SIZE) String vmMemorySize, @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject) { try { final HttpInputs httpInputs = new HttpInputs.HttpInputsBuilder() .withHost(host) .withPort(port) .withProtocol(protocol) .withUsername(username) .withPassword(password) .withTrustEveryone(defaultIfEmpty(trustEveryone, FALSE)) .withCloseSession(defaultIfEmpty(closeSession, TRUE)) .withGlobalSessionObject(globalSessionObject) .build(); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withDataCenterName(dataCenterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withDescription(description) .withDataStore(dataStore) .withGuestOsId(guestOsId) .withFolderName(folderName) .withResourcePool(resourcePool) .withDescription(description) .withGuestOsId(guestOsId) .withDescription(description) .withIntNumCPUs(numCPUs) .withLongVmDiskSize(vmDiskSize) .withLongVmMemorySize(vmMemorySize) .build(); return new VmService().createVM(httpInputs, vmInputs); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }  @Action(name = "Create Virtual Machine", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.RETURN_CODE_FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) }) Map<String, String> createVM(@Param(value = HOST, required = true) String host,
                                        @Param(value = PORT) String port,
                                        @Param(value = PROTOCOL) String protocol,
                                        @Param(value = USERNAME, required = true) String username,
                                        @Param(value = PASSWORD, encrypted = true) String password,
                                        @Param(value = TRUST_EVERYONE) String trustEveryone,
                                        @Param(value = CLOSE_SESSION) String closeSession,

                                        @Param(value = DATA_CENTER_NAME, required = true) String dataCenterName,
                                        @Param(value = HOSTNAME, required = true) String hostname,
                                        @Param(value = VM_NAME, required = true) String virtualMachineName,
                                        @Param(value = DATA_STORE, required = true) String dataStore,
                                        @Param(value = GUEST_OS_ID, required = true) String guestOsId,
                                        @Param(value = FOLDER_NAME) String folderName,
                                        @Param(value = RESOURCE_POOL) String resourcePool,
                                        @Param(value = VM_DESCRIPTION) String description,
                                        @Param(value = VM_CPU_COUNT) String numCPUs,
                                        @Param(value = VM_DISK_SIZE) String vmDiskSize,
                                        @Param(value = VM_MEMORY_SIZE) String vmMemorySize,
                                        @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject);  }