### Question:
RedbeamsStartService { public void startDatabaseServer(String crn) { DBStack dbStack = dbStackService.getByCrn(crn); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Start called for: {}", dbStack); } if (dbStack.getStatus().isStartInProgressOrCompleted()) { LOGGER.debug("DatabaseServer with crn {} is already being started", dbStack.getResourceCrn()); return; } dbStackStatusUpdater.updateStatus(dbStack.getId(), DetailedDBStackStatus.START_REQUESTED); flowManager.notify(RedbeamsStartEvent.REDBEAMS_START_EVENT.selector(), new RedbeamsEvent(RedbeamsStartEvent.REDBEAMS_START_EVENT.selector(), dbStack.getId())); }  void startDatabaseServer(String crn);  }### Answer:
@Test public void shouldSetStartRequestedStatusAndNotifyTheFlowManager() { when(dbStack.getId()).thenReturn(1L); when(dbStack.getStatus()).thenReturn(Status.STOPPED); when(dbStackStatusUpdater.updateStatus(dbStack.getId(), DetailedDBStackStatus.START_REQUESTED)).thenReturn(Optional.of(dbStack)); ArgumentCaptor<RedbeamsEvent> redbeamsEventArgumentCaptor = ArgumentCaptor.forClass(RedbeamsEvent.class); victim.startDatabaseServer(CRN_STRING); verify(flowManager).notify(eq(RedbeamsStartEvent.REDBEAMS_START_EVENT.selector()), redbeamsEventArgumentCaptor.capture()); assertEquals(dbStack.getId(), redbeamsEventArgumentCaptor.getValue().getResourceId()); assertEquals(RedbeamsStartEvent.REDBEAMS_START_EVENT.selector(), redbeamsEventArgumentCaptor.getValue().selector()); }
@Test public void shouldReturnWithoutAnyActionWhenStartInProgress() { when(dbStack.getStatus()).thenReturn(Status.START_IN_PROGRESS); victim.startDatabaseServer(CRN_STRING); verifyZeroInteractions(dbStackStatusUpdater, flowManager); }