@Test public void getStateFlowDTOByFromStateDTOShouldReturnEmptyListWhenInvalidStateDtoIsGiven() { StateDTO invalidStateDTO = StateDTO.builder().id(INVALID_STATE_ID).name(INVALID_STATE_NAME).build(); StatesEntity invalidStatesEntity = StatesEntity.builder().id(INVALID_STATE_ID).name(INVALID_STATE_NAME).build(); given(converterService.convert(invalidStateDTO, StatesEntity.class)) .willReturn(invalidStatesEntity); given(stateFlowRepository.findByFromStateEntity(invalidStatesEntity)) .willReturn(EMPTY_STATE_FLOW_ENTITY_LIST); Collection<StateFlowDTO> result = stateFlowService.getStateFlowDTOByFromStateDTO(invalidStateDTO); assertThat(result, notNullValue()); assertThat(result, empty()); then(converterService).should().convert(invalidStateDTO, StatesEntity.class); then(stateFlowRepository).should().findByFromStateEntity(invalidStatesEntity); }
@Transactional(readOnly = true) @Override public Collection<StateFlowDTO> getStateFlowDTOByFromStateDTO(StateDTO statesDTO) { Assert.notNull(statesDTO); Assert.notNull(statesDTO.getId()); Assert.notNull(statesDTO.getName()); List<StateFlowEntity> stateFlowEntities = stateFlowRepository.findByFromStateEntity(converterService.convert(statesDTO, StatesEntity.class)); return converterService.convert(stateFlowEntities, StateFlowDTO.class); }
StateFlowServiceImpl implements StateFlowService { @Transactional(readOnly = true) @Override public Collection<StateFlowDTO> getStateFlowDTOByFromStateDTO(StateDTO statesDTO) { Assert.notNull(statesDTO); Assert.notNull(statesDTO.getId()); Assert.notNull(statesDTO.getName()); List<StateFlowEntity> stateFlowEntities = stateFlowRepository.findByFromStateEntity(converterService.convert(statesDTO, StatesEntity.class)); return converterService.convert(stateFlowEntities, StateFlowDTO.class); } }
StateFlowServiceImpl implements StateFlowService { @Transactional(readOnly = true) @Override public Collection<StateFlowDTO> getStateFlowDTOByFromStateDTO(StateDTO statesDTO) { Assert.notNull(statesDTO); Assert.notNull(statesDTO.getId()); Assert.notNull(statesDTO.getName()); List<StateFlowEntity> stateFlowEntities = stateFlowRepository.findByFromStateEntity(converterService.convert(statesDTO, StatesEntity.class)); return converterService.convert(stateFlowEntities, StateFlowDTO.class); }  }
StateFlowServiceImpl implements StateFlowService { @Transactional(readOnly = true) @Override public Collection<StateFlowDTO> getStateFlowDTOByFromStateDTO(StateDTO statesDTO) { Assert.notNull(statesDTO); Assert.notNull(statesDTO.getId()); Assert.notNull(statesDTO.getName()); List<StateFlowEntity> stateFlowEntities = stateFlowRepository.findByFromStateEntity(converterService.convert(statesDTO, StatesEntity.class)); return converterService.convert(stateFlowEntities, StateFlowDTO.class); }  @Transactional(readOnly = true) @Override Collection<StateFlowDTO> getStateFlowDTOByFromStateDTO(StateDTO statesDTO); }
StateFlowServiceImpl implements StateFlowService { @Transactional(readOnly = true) @Override public Collection<StateFlowDTO> getStateFlowDTOByFromStateDTO(StateDTO statesDTO) { Assert.notNull(statesDTO); Assert.notNull(statesDTO.getId()); Assert.notNull(statesDTO.getName()); List<StateFlowEntity> stateFlowEntities = stateFlowRepository.findByFromStateEntity(converterService.convert(statesDTO, StatesEntity.class)); return converterService.convert(stateFlowEntities, StateFlowDTO.class); }  @Transactional(readOnly = true) @Override Collection<StateFlowDTO> getStateFlowDTOByFromStateDTO(StateDTO statesDTO);  }