@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<Experiment> list(String schearch) { if (Strings.isNullOrEmpty(schearch)) return repository.all(QExperiment.experiment, createConstructiorExpression()); return repository.list( QExperiment.experiment, QExperiment.experiment.name.containsIgnoreCase(schearch), createConstructiorExpression()); }
@Test public void listWithError() { String schearch = "search"; Mockito.when( repository.list( QSampleEntity.sampleEntity, service.getFilter(schearch), QSampleEntity.sampleEntity)) .thenReturn(getList()); List<SampleEntity> list = service.list(schearch); Mockito.verify(repository) .list(QSampleEntity.sampleEntity, service.getFilter(schearch), QSampleEntity.sampleEntity); MatcherAssert.assertThat(list, Matchers.hasSize(1)); MatcherAssert.assertThat(list, Matchers.contains(createSampleEntity(ID, null))); }