@Test(expected = JvmServiceException.class) public void testJvmDeleteServiceFailsMakeDirectory() { Jvm mockJvm = mock(Jvm.class); when(mockJvm.getJvmName()).thenReturn("test-jvm-command-factory"); when(Config.mockBinaryDistributionControlService.checkFileExists(anyString(), anyString())).thenReturn(new CommandOutput(new ExecReturnCode(1), "File doesn't exist - create directory, copy script, and make executable", "")); when(Config.mockBinaryDistributionControlService.createDirectory(anyString(), anyString())).thenReturn(new CommandOutput(new ExecReturnCode(1), "", "Failed to create directory")); RemoteCommandReturnInfo commandReturnInfo = jvmCommandFactory.executeCommand(mockJvm, JvmControlOperation.DELETE_SERVICE); assertEquals(SUCCESS_REMOTE_COMMAND_INFO, commandReturnInfo); verify(Config.mockSshConfig, times(1)).getEncryptedPassword(); verify(Config.mockSshConfig, times(1)).getUserName(); verify(Config.mockBinaryDistributionControlService, never()).secureCopyFile(anyString(), anyString(), anyString()); verify(Config.mockBinaryDistributionControlService, never()).changeFileMode(anyString(), anyString(), anyString(), anyString()); verify(Config.mockRemoteCommandExecutorService, never()).executeCommand(any(RemoteExecCommand.class)); }
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();  }