SystemCommandStateBean { @Transactional(REQUIRES_NEW) public Optional<SystemCommandStatus> getCommandStatus(final UUID commandId) { return systemCommandStatusRepository.findLatestStatusById(commandId); }  @Transactional(REQUIRES_NEW) void addSystemCommandState(final SystemCommandStatus systemCommandStatus); @Transactional(REQUIRES_NEW) Optional<SystemCommandStatus> getCommandStatus(final UUID commandId); @Transactional(REQUIRES_NEW) boolean commandInProgress(final SystemCommand systemCommand);  }
@Test public void shouldGetSystemCommandStatusFromTheRepository() throws Exception { final UUID commandId = randomUUID(); final Optional<SystemCommandStatus> systemCommandStatus = of(mock(SystemCommandStatus.class)); when(systemCommandStatusRepository.findLatestStatusById(commandId)).thenReturn(systemCommandStatus); assertThat(systemCommandStateBean.getCommandStatus(commandId), is(systemCommandStatus)); }