@Test @RunWithCustomExecutor public void shouldIndexElasticSearchWithGoodUnitSchema() throws Exception { final GUID uuid = GUIDFactory.newUnitGUID(TENANT_ID_0); final GUID uuid2 = GUIDFactory.newUnitGUID(TENANT_ID_0); VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID_0); final DbRequest dbRequest = new DbRequest(); InsertParserMultiple insertParserMultiple1 = (InsertParserMultiple) RequestParserHelper .getParser(createInsertRequestWithUUID(uuid), mongoDbVarNameAdapter); dbRequest.execInsertUnitRequest(insertParserMultiple1); InsertParserMultiple insertParserMultiple2 = (InsertParserMultiple) RequestParserHelper .getParser(createInsertChild2ParentRequest(uuid2, uuid), mongoDbVarNameAdapter); dbRequest.execInsertUnitRequest(insertParserMultiple2); final QueryBuilder qb1 = QueryBuilders.matchPhrasePrefixQuery(TITLE, VALUE_MY_TITLE + 2); final QueryBuilder qb2 = QueryBuilders.matchPhrasePrefixQuery(TITLE, VALUE_MY_TITLE); final QueryBuilder qb3 = QueryBuilders.matchPhrasePrefixQuery(MY_INT, 10); final QueryBuilder qb4 = QueryBuilders.matchPhrasePrefixQuery(MY_INT, 20); final QueryBuilder qb5 = QueryBuilders.matchPhrasePrefixQuery("underscore", "undersco"); final QueryBuilder qb6 = QueryBuilders.matchPhrasePrefixQuery("_underscore", "undersco"); final QueryBuilder qb7 = QueryBuilders.matchPhrasePrefixQuery("_nbc", 100); final QueryBuilder qb8 = QueryBuilders.matchPhrasePrefixQuery("_unitType", "obj"); SearchResponse response = esClientWithoutVitamBehavior .search(MetadataCollections.UNIT.getName().toLowerCase(), TENANT_ID_0, qb1, null, null, null, 0, 1000, null, null, null); assertEquals(1, response.getHits().getTotalHits().value); response = esClientWithoutVitamBehavior .search(MetadataCollections.UNIT.getName().toLowerCase(), TENANT_ID_0, qb2, null, null, null, 0, 1000, null, null, null); assertEquals(2, response.getHits().getTotalHits().value); response = esClientWithoutVitamBehavior .search(MetadataCollections.UNIT.getName().toLowerCase(), TENANT_ID_0, qb3, null, null, null, 0, 1000, null, null, null); assertEquals(1, response.getHits().getTotalHits().value); response = esClientWithoutVitamBehavior .search(MetadataCollections.UNIT.getName().toLowerCase(), TENANT_ID_0, qb4, null, null, null, 0, 1000, null, null, null); assertEquals(1, response.getHits().getTotalHits().value); response = esClientWithoutVitamBehavior .search(MetadataCollections.UNIT.getName().toLowerCase(), TENANT_ID_0, qb5, null, null, null, 0, 1000, null, null, null); assertEquals(1, response.getHits().getTotalHits().value); response = esClientWithoutVitamBehavior .search(MetadataCollections.UNIT.getName().toLowerCase(), TENANT_ID_0, qb6, null, null, null, 0, 1000, null, null, null); assertEquals(1, response.getHits().getTotalHits().value); try { response = esClientWithoutVitamBehavior .search(MetadataCollections.UNIT.getName().toLowerCase(), TENANT_ID_0, qb7, null, null, null, 0, 1000, null, null, null); fail("should throws exception as matchPhrasePrefixQuery is no allowed for numbers"); } catch (BadRequestException e) { } try { response = esClientWithoutVitamBehavior .search(MetadataCollections.UNIT.getName().toLowerCase(), TENANT_ID_0, qb8, null, null, null, 0, 1000, null, null, null); fail("should throws exception as matchPhrasePrefixQuery is no allowed for keyWords"); } catch (BadRequestException e) { } }
public void execInsertUnitRequest(InsertParserMultiple requestParser) throws MetaDataExecutionException, MetaDataNotFoundException { LOGGER.debug("Exec db insert unit request: %s", requestParser); execInsertUnitRequests(new BulkUnitInsertRequest(Collections.singletonList( new BulkUnitInsertEntry(requestParser.getRequest().getRoots(), requestParser.getRequest().getData()) ))); }
DbRequest { public void execInsertUnitRequest(InsertParserMultiple requestParser) throws MetaDataExecutionException, MetaDataNotFoundException { LOGGER.debug("Exec db insert unit request: %s", requestParser); execInsertUnitRequests(new BulkUnitInsertRequest(Collections.singletonList( new BulkUnitInsertEntry(requestParser.getRequest().getRoots(), requestParser.getRequest().getData()) ))); } }
DbRequest { public void execInsertUnitRequest(InsertParserMultiple requestParser) throws MetaDataExecutionException, MetaDataNotFoundException { LOGGER.debug("Exec db insert unit request: %s", requestParser); execInsertUnitRequests(new BulkUnitInsertRequest(Collections.singletonList( new BulkUnitInsertEntry(requestParser.getRequest().getRoots(), requestParser.getRequest().getData()) ))); } @VisibleForTesting  DbRequest(MongoDbMetadataRepository<Unit> mongoDbUnitRepository,
        MongoDbMetadataRepository<ObjectGroup> mongoDbObjectGroupRepository,
        FieldHistoryManager fieldHistoryManager);  DbRequest(); }
DbRequest { public void execInsertUnitRequest(InsertParserMultiple requestParser) throws MetaDataExecutionException, MetaDataNotFoundException { LOGGER.debug("Exec db insert unit request: %s", requestParser); execInsertUnitRequests(new BulkUnitInsertRequest(Collections.singletonList( new BulkUnitInsertEntry(requestParser.getRequest().getRoots(), requestParser.getRequest().getData()) ))); } @VisibleForTesting  DbRequest(MongoDbMetadataRepository<Unit> mongoDbUnitRepository,
        MongoDbMetadataRepository<ObjectGroup> mongoDbObjectGroupRepository,
        FieldHistoryManager fieldHistoryManager);  DbRequest(); UpdatedDocument execRuleRequest(final String documentId, final RuleActions ruleActions,
        Map<String, DurationData> bindRuleToDuration, OntologyValidator ontologyValidator, UnitValidator unitValidator,
        List<OntologyModel> ontologyModels); Result execRequest(final RequestParserMultiple requestParser, List<OntologyModel> ontologies); UpdatedDocument execUpdateRequest(final RequestParserMultiple requestParser, String documentId,
        MetadataCollections metadataCollection, OntologyValidator ontologyValidator, UnitValidator unitValidator,
        List<OntologyModel> ontologyModels); void execInsertUnitRequest(InsertParserMultiple requestParser); void execInsertObjectGroupRequests(List<InsertParserMultiple> requestParsers); void execInsertUnitRequests(BulkUnitInsertRequest request); void deleteUnits(List<String> documentsToDelete); void deleteObjectGroups(List<String> documentsToDelete); }
DbRequest { public void execInsertUnitRequest(InsertParserMultiple requestParser) throws MetaDataExecutionException, MetaDataNotFoundException { LOGGER.debug("Exec db insert unit request: %s", requestParser); execInsertUnitRequests(new BulkUnitInsertRequest(Collections.singletonList( new BulkUnitInsertEntry(requestParser.getRequest().getRoots(), requestParser.getRequest().getData()) ))); } @VisibleForTesting  DbRequest(MongoDbMetadataRepository<Unit> mongoDbUnitRepository,
        MongoDbMetadataRepository<ObjectGroup> mongoDbObjectGroupRepository,
        FieldHistoryManager fieldHistoryManager);  DbRequest(); UpdatedDocument execRuleRequest(final String documentId, final RuleActions ruleActions,
        Map<String, DurationData> bindRuleToDuration, OntologyValidator ontologyValidator, UnitValidator unitValidator,
        List<OntologyModel> ontologyModels); Result execRequest(final RequestParserMultiple requestParser, List<OntologyModel> ontologies); UpdatedDocument execUpdateRequest(final RequestParserMultiple requestParser, String documentId,
        MetadataCollections metadataCollection, OntologyValidator ontologyValidator, UnitValidator unitValidator,
        List<OntologyModel> ontologyModels); void execInsertUnitRequest(InsertParserMultiple requestParser); void execInsertObjectGroupRequests(List<InsertParserMultiple> requestParsers); void execInsertUnitRequests(BulkUnitInsertRequest request); void deleteUnits(List<String> documentsToDelete); void deleteObjectGroups(List<String> documentsToDelete);  }