CommandExecutor { public Object execute(GfshParseResult parseResult) { return execute(null, parseResult); } CommandExecutor(DistributedLockService cmsDlockService); Object execute(GfshParseResult parseResult); @VisibleForTesting @SuppressWarnings("deprecation") Object execute(Object command, GfshParseResult parseResult); static final String RUN_ON_MEMBER_CHANGE_NOT_PERSISTED; static final String SERVICE_NOT_RUNNING_CHANGE_NOT_PERSISTED; }
@Test public void executeWhenGivenDummyParseResult() { Object result = executor.execute(parseResult); assertThat(result).isInstanceOf(ResultModel.class); assertThat(result.toString()).contains("Error while processing command"); }
@Test public void verifyLockUnlockIsCalledWhenCommandUpdatesCC() throws Exception { when(testCommand.getConfigurationPersistenceService()).thenReturn(ccService); when(testCommand.affectsClusterConfiguration()).thenReturn(true); executor.execute(testCommand, parseResult); verify(dlockService).lock(any(), eq(-1L), eq(-1L)); verify(dlockService).unlock(any()); }
@Test public void verifyLockUnlockIsNotCalledWhenCommandDoesNotUpdatesCC() throws Exception { when(testCommand.getConfigurationPersistenceService()).thenReturn(ccService); when(testCommand.affectsClusterConfiguration()).thenReturn(false); executor.execute(testCommand, parseResult); verify(dlockService, never()).lock(any(), eq(-1L), eq(-1L)); verify(dlockService, never()).unlock(any()); }