@Test public void should_find_collection_by_processid_tenant() { populateDatabase(); MongoCursor<Document> iterator = repository.findCollectionByProcessIdTenant(processId, TENANT_ID); List<Document> documents = new ArrayList<>(); while (iterator.hasNext()) { Document reportModel = iterator.next(); documents.add(reportModel); } assertThat(documents.size()).isEqualTo(2); }
public MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId) { return collection.aggregate( Arrays.asList( match(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))), Aggregates.project(Projections.fields( new Document(PROCESS_ID, "$processId"), new Document(CREATION_DATE_TIME, "$creationDateTime"), new Document(UNIT_ID, "$unitId"), new Document(OBJECT_GROUP_ID, "$objectGroupId"), new Document(STATUS, "$status"), new Document(ACTION, "$actions"), new Document(ANALYSE_RESULT, "$analyseResult"), new Document(INPUT_OBJECT_ID, "$inputObjectId"), new Document(OUTPUT_OBJECT_ID, "$outputObjectId"), new Document(GRIFFIN_ID, "$griffinId"), new Document(SCENARIO_ID, "$preservationScenarioId") ) )) ).allowDiskUse(true).iterator(); }
PreservationReportRepository { public MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId) { return collection.aggregate( Arrays.asList( match(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))), Aggregates.project(Projections.fields( new Document(PROCESS_ID, "$processId"), new Document(CREATION_DATE_TIME, "$creationDateTime"), new Document(UNIT_ID, "$unitId"), new Document(OBJECT_GROUP_ID, "$objectGroupId"), new Document(STATUS, "$status"), new Document(ACTION, "$actions"), new Document(ANALYSE_RESULT, "$analyseResult"), new Document(INPUT_OBJECT_ID, "$inputObjectId"), new Document(OUTPUT_OBJECT_ID, "$outputObjectId"), new Document(GRIFFIN_ID, "$griffinId"), new Document(SCENARIO_ID, "$preservationScenarioId") ) )) ).allowDiskUse(true).iterator(); } }
PreservationReportRepository { public MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId) { return collection.aggregate( Arrays.asList( match(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))), Aggregates.project(Projections.fields( new Document(PROCESS_ID, "$processId"), new Document(CREATION_DATE_TIME, "$creationDateTime"), new Document(UNIT_ID, "$unitId"), new Document(OBJECT_GROUP_ID, "$objectGroupId"), new Document(STATUS, "$status"), new Document(ACTION, "$actions"), new Document(ANALYSE_RESULT, "$analyseResult"), new Document(INPUT_OBJECT_ID, "$inputObjectId"), new Document(OUTPUT_OBJECT_ID, "$outputObjectId"), new Document(GRIFFIN_ID, "$griffinId"), new Document(SCENARIO_ID, "$preservationScenarioId") ) )) ).allowDiskUse(true).iterator(); } @VisibleForTesting  PreservationReportRepository(MongoDbAccess mongoDbAccess, String collectionName);  PreservationReportRepository(MongoDbAccess mongoDbAccess); }
PreservationReportRepository { public MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId) { return collection.aggregate( Arrays.asList( match(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))), Aggregates.project(Projections.fields( new Document(PROCESS_ID, "$processId"), new Document(CREATION_DATE_TIME, "$creationDateTime"), new Document(UNIT_ID, "$unitId"), new Document(OBJECT_GROUP_ID, "$objectGroupId"), new Document(STATUS, "$status"), new Document(ACTION, "$actions"), new Document(ANALYSE_RESULT, "$analyseResult"), new Document(INPUT_OBJECT_ID, "$inputObjectId"), new Document(OUTPUT_OBJECT_ID, "$outputObjectId"), new Document(GRIFFIN_ID, "$griffinId"), new Document(SCENARIO_ID, "$preservationScenarioId") ) )) ).allowDiskUse(true).iterator(); } @VisibleForTesting  PreservationReportRepository(MongoDbAccess mongoDbAccess, String collectionName);  PreservationReportRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<PreservationReportEntry> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); PreservationStatsModel stats(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); }
PreservationReportRepository { public MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId) { return collection.aggregate( Arrays.asList( match(and(eq(PROCESS_ID, processId), eq(TENANT, tenantId))), Aggregates.project(Projections.fields( new Document(PROCESS_ID, "$processId"), new Document(CREATION_DATE_TIME, "$creationDateTime"), new Document(UNIT_ID, "$unitId"), new Document(OBJECT_GROUP_ID, "$objectGroupId"), new Document(STATUS, "$status"), new Document(ACTION, "$actions"), new Document(ANALYSE_RESULT, "$analyseResult"), new Document(INPUT_OBJECT_ID, "$inputObjectId"), new Document(OUTPUT_OBJECT_ID, "$outputObjectId"), new Document(GRIFFIN_ID, "$griffinId"), new Document(SCENARIO_ID, "$preservationScenarioId") ) )) ).allowDiskUse(true).iterator(); } @VisibleForTesting  PreservationReportRepository(MongoDbAccess mongoDbAccess, String collectionName);  PreservationReportRepository(MongoDbAccess mongoDbAccess); void bulkAppendReport(List<PreservationReportEntry> reports); MongoCursor<Document> findCollectionByProcessIdTenant(String processId, int tenantId); PreservationStatsModel stats(String processId, int tenantId); void deleteReportByIdAndTenant(String processId, int tenantId); static final String PRESERVATION_REPORT; }