@Test
public void testExec() throws Exception {

    final URL resource = AbstractCoreIntegrationTest.class.getResource("kernel/valid-metadata.iso19139.xml");
    String uuid = UUID.randomUUID().toString();
    ServiceContext importContext = createServiceContext();
    loginAsAdmin(importContext);
    importMetadataXML(importContext, uuid, resource.openStream(), MetadataType.METADATA, ReservedGroup.all.getId(), uuid);
    uuid = UUID.randomUUID().toString();
    final int mdId1 = importMetadataXML(importContext, uuid, resource.openStream(), MetadataType.METADATA, ReservedGroup.all.getId(),
        uuid);
    metadataRepository.update(mdId1, new Updater<Metadata>() {
        @Override
        public void apply(@Nonnull Metadata entity) {
            entity.getSourceInfo().setGroupOwner(null);
        }
    });
    ServiceContext context = createServiceContext();
    context.setUserSession(new UserSession());
    final String now = getTomorrow();
    final String lastMonth = getLastMonth();
    assertRecords(0, createParams(read("dateFrom", now), read("dateTo", now)), context);
    assertRecords(2, createParams(read("dateFrom", lastMonth), read("dateTo", now)), context);
    assertRecords(0, createParams(read("dateFrom", lastMonth), read("dateTo", now), read("groups", "2"), read("groups", "42")), context);
    assertRecords(1, createParams(read("dateFrom", lastMonth), read("dateTo", now), read("groups", ReservedGroup.all.getId()),
        read("groups", "42")), context);
    loginAsAdmin(context);
    assertRecords(0, createParams(read("dateFrom", now), read("dateTo", now)), context);
    assertRecords(2, createParams(read("dateFrom", lastMonth), read("dateTo", now)), context);
    assertRecords(0, createParams(read("dateFrom", lastMonth), read("dateTo", now), read("groups", "2"), read("groups", "42")), context);
    assertRecords(1, createParams(read("dateFrom", lastMonth), read("dateTo", now), read("groups", ReservedGroup.all.getId()),
        read("groups", "42")), context);
    // there was a bug where certain queries would cause an exception.  We are just checking that no exception occurs
}