@Test public void testSuccessModifyVmOverridesWithNoVmDetails() throws Exception { String expectedReturnResult = "expectMe2"; Map<String, String> expectedResult = new HashMap<>(); expectedResult.put("returnResult", expectedReturnResult); expectedResult.put("returnCode", "0"); whenNew(ClusterComputeResourceService.class).withNoArguments().thenReturn(service); doReturn(expectedReturnResult).when(service).getVmOverride(any(HttpInputs.class), any(VmInputs.class)); Map<String, String> actual = action.getVmOverrides("", "", "", "", "", "", "", "", "", "", "", null); verifyNew(ClusterComputeResourceService.class).withNoArguments(); verify(service).getVmOverride(any(HttpInputs.class), any(VmInputs.class)); assertEquals(expectedResult, actual); }
@Action(name = "Get VM Overrides Priority", 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> getVmOverrides(@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, required = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME) String virtualMachineName, @Param(value = VM_ID) String virtualMachineId, @Param(value = CLUSTER_NAME, required = true) String clusterName, @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(); InputUtils.checkOptionalMutuallyExclusiveInputs(virtualMachineName, virtualMachineId, PROVIDE_VM_NAME_OR_ID_OR_NONE); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withVirtualMachineId(virtualMachineId) .build(); return OutputUtilities.getSuccessResultsMap(new ClusterComputeResourceService().getVmOverride(httpInputs, vmInputs)); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }
GetVmOverrides { @Action(name = "Get VM Overrides Priority", 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> getVmOverrides(@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, required = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME) String virtualMachineName, @Param(value = VM_ID) String virtualMachineId, @Param(value = CLUSTER_NAME, required = true) String clusterName, @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(); InputUtils.checkOptionalMutuallyExclusiveInputs(virtualMachineName, virtualMachineId, PROVIDE_VM_NAME_OR_ID_OR_NONE); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withVirtualMachineId(virtualMachineId) .build(); return OutputUtilities.getSuccessResultsMap(new ClusterComputeResourceService().getVmOverride(httpInputs, vmInputs)); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } } }
GetVmOverrides { @Action(name = "Get VM Overrides Priority", 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> getVmOverrides(@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, required = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME) String virtualMachineName, @Param(value = VM_ID) String virtualMachineId, @Param(value = CLUSTER_NAME, required = true) String clusterName, @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(); InputUtils.checkOptionalMutuallyExclusiveInputs(virtualMachineName, virtualMachineId, PROVIDE_VM_NAME_OR_ID_OR_NONE); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withVirtualMachineId(virtualMachineId) .build(); return OutputUtilities.getSuccessResultsMap(new ClusterComputeResourceService().getVmOverride(httpInputs, vmInputs)); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }  }
GetVmOverrides { @Action(name = "Get VM Overrides Priority", 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> getVmOverrides(@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, required = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME) String virtualMachineName, @Param(value = VM_ID) String virtualMachineId, @Param(value = CLUSTER_NAME, required = true) String clusterName, @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(); InputUtils.checkOptionalMutuallyExclusiveInputs(virtualMachineName, virtualMachineId, PROVIDE_VM_NAME_OR_ID_OR_NONE); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withVirtualMachineId(virtualMachineId) .build(); return OutputUtilities.getSuccessResultsMap(new ClusterComputeResourceService().getVmOverride(httpInputs, vmInputs)); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }  @Action(name = "Get VM Overrides Priority", 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> getVmOverrides(@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, required = true) String password,
                                              @Param(value = TRUST_EVERYONE) String trustEveryone,
                                              @Param(value = CLOSE_SESSION) String closeSession,
                                              @Param(value = HOSTNAME, required = true) String hostname,
                                              @Param(value = VM_NAME) String virtualMachineName,
                                              @Param(value = VM_ID) String virtualMachineId,
                                              @Param(value = CLUSTER_NAME, required = true) String clusterName,
                                              @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject); }
GetVmOverrides { @Action(name = "Get VM Overrides Priority", 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> getVmOverrides(@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, required = true) String password, @Param(value = TRUST_EVERYONE) String trustEveryone, @Param(value = CLOSE_SESSION) String closeSession, @Param(value = HOSTNAME, required = true) String hostname, @Param(value = VM_NAME) String virtualMachineName, @Param(value = VM_ID) String virtualMachineId, @Param(value = CLUSTER_NAME, required = true) String clusterName, @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(); InputUtils.checkOptionalMutuallyExclusiveInputs(virtualMachineName, virtualMachineId, PROVIDE_VM_NAME_OR_ID_OR_NONE); final VmInputs vmInputs = new VmInputs.VmInputsBuilder() .withClusterName(clusterName) .withHostname(hostname) .withVirtualMachineName(virtualMachineName) .withVirtualMachineId(virtualMachineId) .build(); return OutputUtilities.getSuccessResultsMap(new ClusterComputeResourceService().getVmOverride(httpInputs, vmInputs)); } catch (Exception ex) { return OutputUtilities.getFailureResultsMap(ex); } }  @Action(name = "Get VM Overrides Priority", 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> getVmOverrides(@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, required = true) String password,
                                              @Param(value = TRUST_EVERYONE) String trustEveryone,
                                              @Param(value = CLOSE_SESSION) String closeSession,
                                              @Param(value = HOSTNAME, required = true) String hostname,
                                              @Param(value = VM_NAME) String virtualMachineName,
                                              @Param(value = VM_ID) String virtualMachineId,
                                              @Param(value = CLUSTER_NAME, required = true) String clusterName,
                                              @Param(value = VMWARE_GLOBAL_SESSION_OBJECT) GlobalSessionObject<Map<String, Connection>> globalSessionObject);  }