@Test @RunWithCustomExecutor public void testInsertRequestWithValidationOK() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); DbRequestSingle dbRequestSingle = new DbRequestSingle(vitamCollection, Collections::emptyList); assertEquals(0, vitamCollection.getCollection().countDocuments()); final ArrayNode data = JsonHandler.createArrayNode(); data.add(getNewDocument(GUIDFactory.newGUID().toString(), "title one", 1)); data.add(getNewDocument(GUIDFactory.newGUID().toString(), "title two", 2)); final Insert insert = new Insert(); insert.setData(data); DocumentValidator documentValidator = mock(DocumentValidator.class); doNothing().when(documentValidator).validateDocument(any()); final DbRequestResult insertResult = dbRequestSingle.execute(insert, 0, documentValidator); assertEquals(2, insertResult.getCount()); assertEquals(2, vitamCollection.getCollection().countDocuments()); insertResult.close(); final Select select = new Select(); select.setQuery(eq("Title.keyword", "title one")); final DbRequestResult selectResult = dbRequestSingle.execute(select); final List<VitamDocument> selectCursor = selectResult.getDocuments(VitamDocument.class); assertFalse(selectCursor.isEmpty()); assertEquals(1, selectCursor.size()); assertThat(selectCursor.get(0).getString("Title")).isEqualTo("title one"); assertThat(selectCursor.get(0).getInteger("#version")).isEqualTo(0); selectCursor.clear(); selectResult.close(); }
public DbRequestResult execute(Select request) throws InvalidParseOperationException, DatabaseException, BadRequestException, InvalidCreateOperationException, VitamDBException, SchemaValidationException { DynamicParserTokens parserTokens = new DynamicParserTokens(vitamCollection.getVitamDescriptionResolver(), ontologyLoader.loadOntologies()); return findDocuments(request.getFinalSelect(), parserTokens); }
DbRequestSingle { public DbRequestResult execute(Select request) throws InvalidParseOperationException, DatabaseException, BadRequestException, InvalidCreateOperationException, VitamDBException, SchemaValidationException { DynamicParserTokens parserTokens = new DynamicParserTokens(vitamCollection.getVitamDescriptionResolver(), ontologyLoader.loadOntologies()); return findDocuments(request.getFinalSelect(), parserTokens); } }
DbRequestSingle { public DbRequestResult execute(Select request) throws InvalidParseOperationException, DatabaseException, BadRequestException, InvalidCreateOperationException, VitamDBException, SchemaValidationException { DynamicParserTokens parserTokens = new DynamicParserTokens(vitamCollection.getVitamDescriptionResolver(), ontologyLoader.loadOntologies()); return findDocuments(request.getFinalSelect(), parserTokens); } DbRequestSingle(VitamCollection collection, OntologyLoader ontologyLoader); }
DbRequestSingle { public DbRequestResult execute(Select request) throws InvalidParseOperationException, DatabaseException, BadRequestException, InvalidCreateOperationException, VitamDBException, SchemaValidationException { DynamicParserTokens parserTokens = new DynamicParserTokens(vitamCollection.getVitamDescriptionResolver(), ontologyLoader.loadOntologies()); return findDocuments(request.getFinalSelect(), parserTokens); } DbRequestSingle(VitamCollection collection, OntologyLoader ontologyLoader); DbRequestResult execute(Select request); DbRequestResult execute(Insert request, Integer version,
        DocumentValidator documentValidator); DbRequestResult execute(Delete request); DbRequestResult execute(Update request, DocumentValidator documentValidator); DbRequestResult execute(Update request, Integer version, DocumentValidator documentValidator); void replaceDocument(JsonNode document, String identifierValue, String identifierKey,
        VitamCollection vitamCollection); }
DbRequestSingle { public DbRequestResult execute(Select request) throws InvalidParseOperationException, DatabaseException, BadRequestException, InvalidCreateOperationException, VitamDBException, SchemaValidationException { DynamicParserTokens parserTokens = new DynamicParserTokens(vitamCollection.getVitamDescriptionResolver(), ontologyLoader.loadOntologies()); return findDocuments(request.getFinalSelect(), parserTokens); } DbRequestSingle(VitamCollection collection, OntologyLoader ontologyLoader); DbRequestResult execute(Select request); DbRequestResult execute(Insert request, Integer version,
        DocumentValidator documentValidator); DbRequestResult execute(Delete request); DbRequestResult execute(Update request, DocumentValidator documentValidator); DbRequestResult execute(Update request, Integer version, DocumentValidator documentValidator); void replaceDocument(JsonNode document, String identifierValue, String identifierKey,
        VitamCollection vitamCollection);  }