Search in sources :

Example 1 with COLLECTION_NAME

use of org.jnosql.diana.elasticsearch.document.DocumentEntityGerator.COLLECTION_NAME in project jnosql-diana-driver by eclipse.

the class ElasticsearchDocumentCollectionManagerTest method shouldRetrieveListSubdocumentList.

@Test
public void shouldRetrieveListSubdocumentList() {
    DocumentEntity entity = entityManager.insert(createSubdocumentList());
    Document key = entity.find("_id").get();
    DocumentQuery query = select().from(COLLECTION_NAME).where(key.getName()).eq(key.get()).build();
    DocumentEntity documentEntity = entityManager.singleResult(query).get();
    assertNotNull(documentEntity);
    List<List<Document>> contacts = (List<List<Document>>) documentEntity.find("contacts").get().get();
    assertEquals(3, contacts.size());
    assertTrue(contacts.stream().allMatch(d -> d.size() == 3));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Document(org.jnosql.diana.api.document.Document) Arrays(java.util.Arrays) TypeReference(org.jnosql.diana.api.TypeReference) ArrayList(java.util.ArrayList) DocumentEntityGerator.getEntity(org.jnosql.diana.elasticsearch.document.DocumentEntityGerator.getEntity) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Arrays.asList(java.util.Arrays.asList) Duration(java.time.Duration) DocumentQueryBuilder.delete(org.jnosql.diana.api.document.query.DocumentQueryBuilder.delete) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) DocumentQueryBuilder.select(org.jnosql.diana.api.document.query.DocumentQueryBuilder.select) INDEX(org.jnosql.diana.elasticsearch.document.DocumentEntityGerator.INDEX) DocumentDeleteQuery(org.jnosql.diana.api.document.DocumentDeleteQuery) TermQueryBuilder(org.elasticsearch.index.query.TermQueryBuilder) DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) QueryBuilders.termQuery(org.elasticsearch.index.query.QueryBuilders.termQuery) Documents(org.jnosql.diana.api.document.Documents) COLLECTION_NAME(org.jnosql.diana.elasticsearch.document.DocumentEntityGerator.COLLECTION_NAME) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) DocumentQuery(org.jnosql.diana.api.document.DocumentQuery) DocumentEntity(org.jnosql.diana.api.document.DocumentEntity) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Document(org.jnosql.diana.api.document.Document) Test(org.junit.jupiter.api.Test)

Aggregations

Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1 QueryBuilders.termQuery (org.elasticsearch.index.query.QueryBuilders.termQuery)1 TermQueryBuilder (org.elasticsearch.index.query.TermQueryBuilder)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.contains (org.hamcrest.Matchers.contains)1 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)1 TypeReference (org.jnosql.diana.api.TypeReference)1 Document (org.jnosql.diana.api.document.Document)1 DocumentDeleteQuery (org.jnosql.diana.api.document.DocumentDeleteQuery)1 DocumentEntity (org.jnosql.diana.api.document.DocumentEntity)1 DocumentQuery (org.jnosql.diana.api.document.DocumentQuery)1 Documents (org.jnosql.diana.api.document.Documents)1 DocumentQueryBuilder.delete (org.jnosql.diana.api.document.query.DocumentQueryBuilder.delete)1 DocumentQueryBuilder.select (org.jnosql.diana.api.document.query.DocumentQueryBuilder.select)1 COLLECTION_NAME (org.jnosql.diana.elasticsearch.document.DocumentEntityGerator.COLLECTION_NAME)1