@Test public void testStartJvm() { Jvm mockJvm = mock(Jvm.class); when(mockJvm.getJvmName()).thenReturn("test-jvm-command-factory"); when(Config.mockRemoteCommandExecutorService.executeCommand(any(RemoteExecCommand.class))).thenReturn(SUCCESS_REMOTE_COMMAND_INFO); when(Config.mockBinaryDistributionControlService.checkFileExists(anyString(), anyString())).thenReturn(new CommandOutput(new ExecReturnCode(0), "File exists", "")); RemoteCommandReturnInfo commandReturnInfo = jvmCommandFactory.executeCommand(mockJvm, JvmControlOperation.START); assertEquals(SUCCESS_REMOTE_COMMAND_INFO, commandReturnInfo); verify(Config.mockSshConfig, times(1)).getEncryptedPassword(); verify(Config.mockSshConfig, times(1)).getUserName(); }
public RemoteCommandReturnInfo executeCommand(Jvm jvm, JvmControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).execute(jvm); } throw new ApplicationServiceException("JvmCommand not implemented: " + operation.getExternalValue()); }
JvmCommandFactory { public RemoteCommandReturnInfo executeCommand(Jvm jvm, JvmControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).execute(jvm); } throw new ApplicationServiceException("JvmCommand not implemented: " + operation.getExternalValue()); } }
JvmCommandFactory { public RemoteCommandReturnInfo executeCommand(Jvm jvm, JvmControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).execute(jvm); } throw new ApplicationServiceException("JvmCommand not implemented: " + operation.getExternalValue()); }  }
JvmCommandFactory { public RemoteCommandReturnInfo executeCommand(Jvm jvm, JvmControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).execute(jvm); } throw new ApplicationServiceException("JvmCommand not implemented: " + operation.getExternalValue()); }  RemoteCommandReturnInfo executeCommand(Jvm jvm, JvmControlOperation operation); @PostConstruct void initJvmCommands(); }
JvmCommandFactory { public RemoteCommandReturnInfo executeCommand(Jvm jvm, JvmControlOperation operation) throws ApplicationServiceException { if (commands.containsKey(operation.getExternalValue())) { return commands.get(operation.getExternalValue()).execute(jvm); } throw new ApplicationServiceException("JvmCommand not implemented: " + operation.getExternalValue()); }  RemoteCommandReturnInfo executeCommand(Jvm jvm, JvmControlOperation operation); @PostConstruct void initJvmCommands();  }