@SuppressWarnings("unchecked") @Test void testDeleteAll() { String entityTypeId = "MyEntityType"; Repository<Entity> repository = mock(Repository.class); when(metaDataService.getRepository(entityTypeId)).thenReturn(Optional.of(repository)); Entity entity1 = mock(Entity.class); Entity entity2 = mock(Entity.class); Query query = Query.builder().setOperator(Operator.MATCHES).setValue("value").build(); org.molgenis.data.Query<Entity> molgenisQuery = mock(org.molgenis.data.Query.class); when(queryMapper.map(query, repository)).thenReturn(molgenisQuery); dataServiceV3Impl.deleteAll(entityTypeId, query); ArgumentCaptor<Stream> captor = ArgumentCaptor.forClass(Stream.class); verify(repository).delete(captor.capture()); Stream<Entity> entityStream = captor.getValue(); entityStream.collect(Collectors.toList()).containsAll(Arrays.asList(entity1, entity2)); }
@Transactional @Override public void deleteAll(String entityTypeId, @Nullable @CheckForNull Query query) { Repository<Entity> repo = getRepository(entityTypeId, OperationType.MODIFY); org.molgenis.data.Query<Entity> molgenisQuery = query != null ? queryMapper.map(query, repo) : new QueryImpl<>(repo); repo.delete(molgenisQuery.findAll()); }
DataServiceV3Impl implements DataServiceV3 { @Transactional @Override public void deleteAll(String entityTypeId, @Nullable @CheckForNull Query query) { Repository<Entity> repo = getRepository(entityTypeId, OperationType.MODIFY); org.molgenis.data.Query<Entity> molgenisQuery = query != null ? queryMapper.map(query, repo) : new QueryImpl<>(repo); repo.delete(molgenisQuery.findAll()); } }
DataServiceV3Impl implements DataServiceV3 { @Transactional @Override public void deleteAll(String entityTypeId, @Nullable @CheckForNull Query query) { Repository<Entity> repo = getRepository(entityTypeId, OperationType.MODIFY); org.molgenis.data.Query<Entity> molgenisQuery = query != null ? queryMapper.map(query, repo) : new QueryImpl<>(repo); repo.delete(molgenisQuery.findAll()); } DataServiceV3Impl(
      MetaDataService metaDataService,
      EntityManagerV3 entityManagerV3,
      QueryMapper queryMapper,
      SortMapper sortMapper,
      FetchMapper fetchMapper,
      EntityValidator entityValidator); }
DataServiceV3Impl implements DataServiceV3 { @Transactional @Override public void deleteAll(String entityTypeId, @Nullable @CheckForNull Query query) { Repository<Entity> repo = getRepository(entityTypeId, OperationType.MODIFY); org.molgenis.data.Query<Entity> molgenisQuery = query != null ? queryMapper.map(query, repo) : new QueryImpl<>(repo); repo.delete(molgenisQuery.findAll()); } DataServiceV3Impl(
      MetaDataService metaDataService,
      EntityManagerV3 entityManagerV3,
      QueryMapper queryMapper,
      SortMapper sortMapper,
      FetchMapper fetchMapper,
      EntityValidator entityValidator); @Transactional @Override Entity create(String entityTypeId, Map<String, Object> requestValues); @Transactional(readOnly = true) @Override Entity find(String entityTypeId, String entityId, Selection filter, Selection expand); @Transactional(readOnly = true) @Override Entities findSubresources(
      String entityTypeId,
      String entityId,
      String attributeName,
      @Nullable @CheckForNull Query query,
      Selection filter,
      Selection expand,
      Sort sort,
      int size,
      int number); @Transactional(readOnly = true) @Override Entities findAll(
      String entityTypeId,
      @Nullable @CheckForNull Query query,
      Selection filter,
      Selection expand,
      Sort sort,
      int size,
      int number); @Transactional @Override void update(String entityTypeId, String entityId, Map<String, Object> requestValues); @Transactional @Override void updatePartial(
      String entityTypeId, String entityId, Map<String, Object> requestValues); @Transactional @Override void delete(String entityTypeId, String entityId); @Transactional @Override void deleteAll(String entityTypeId, @Nullable @CheckForNull Query query); }
DataServiceV3Impl implements DataServiceV3 { @Transactional @Override public void deleteAll(String entityTypeId, @Nullable @CheckForNull Query query) { Repository<Entity> repo = getRepository(entityTypeId, OperationType.MODIFY); org.molgenis.data.Query<Entity> molgenisQuery = query != null ? queryMapper.map(query, repo) : new QueryImpl<>(repo); repo.delete(molgenisQuery.findAll()); } DataServiceV3Impl(
      MetaDataService metaDataService,
      EntityManagerV3 entityManagerV3,
      QueryMapper queryMapper,
      SortMapper sortMapper,
      FetchMapper fetchMapper,
      EntityValidator entityValidator); @Transactional @Override Entity create(String entityTypeId, Map<String, Object> requestValues); @Transactional(readOnly = true) @Override Entity find(String entityTypeId, String entityId, Selection filter, Selection expand); @Transactional(readOnly = true) @Override Entities findSubresources(
      String entityTypeId,
      String entityId,
      String attributeName,
      @Nullable @CheckForNull Query query,
      Selection filter,
      Selection expand,
      Sort sort,
      int size,
      int number); @Transactional(readOnly = true) @Override Entities findAll(
      String entityTypeId,
      @Nullable @CheckForNull Query query,
      Selection filter,
      Selection expand,
      Sort sort,
      int size,
      int number); @Transactional @Override void update(String entityTypeId, String entityId, Map<String, Object> requestValues); @Transactional @Override void updatePartial(
      String entityTypeId, String entityId, Map<String, Object> requestValues); @Transactional @Override void delete(String entityTypeId, String entityId); @Transactional @Override void deleteAll(String entityTypeId, @Nullable @CheckForNull Query query);  }