use of io.lumeer.api.model.Document in project engine by Lumeer.
the class MorphiaDocumentDaoTest method testCreateDocument.
@Test
public void testCreateDocument() {
MorphiaDocument document = prepareDocument();
String id = documentDao.createDocument(document).getId();
assertThat(id).isNotNull().isNotEmpty();
assertThat(ObjectId.isValid(id)).isTrue();
Document storedDocument = datastore.get(documentDao.databaseCollection(), MorphiaDocument.class, new ObjectId(id));
assertThat(storedDocument).isNotNull();
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(storedDocument.getId()).isEqualTo(id);
assertions.assertThat(storedDocument.getCollectionId()).isEqualTo(COLLECTION_ID);
assertions.assertThat(storedDocument.getCreatedBy()).isEqualTo(CREATED_BY);
assertions.assertThat(storedDocument.getCreationDate()).isEqualTo(CREATION_DATE);
assertions.assertThat(storedDocument.getUpdatedBy()).isNull();
assertions.assertThat(storedDocument.getUpdateDate()).isNull();
assertions.assertThat(storedDocument.getDataVersion()).isEqualTo(DATA_VERSION);
assertions.assertThat(storedDocument.getData()).isNull();
assertions.assertAll();
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class MorphiaDocumentDaoTest method testDeleteDocument.
@Test
public void testDeleteDocument() {
String id = createDocument().getId();
documentDao.deleteDocument(id);
Document storedDocument = datastore.get(documentDao.databaseCollection(), MorphiaDocument.class, new ObjectId(id));
assertThat(storedDocument).isNull();
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class MorphiaDocumentDaoTest method testUpdateDocument.
@Test
public void testUpdateDocument() {
MorphiaDocument document = createDocument();
String id = document.getId();
LocalDateTime updateDate = LocalDateTime.now().withNano(0);
document.setDataVersion(DATA_VERSION2);
document.setUpdatedBy(UPDATED_BY);
document.setUpdateDate(updateDate);
documentDao.updateDocument(document.getId(), document);
Document storedDocument = datastore.get(documentDao.databaseCollection(), MorphiaDocument.class, new ObjectId(id));
assertThat(storedDocument).isNotNull();
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(storedDocument.getId()).isEqualTo(id);
assertions.assertThat(storedDocument.getCollectionId()).isEqualTo(COLLECTION_ID);
assertions.assertThat(storedDocument.getCreatedBy()).isEqualTo(CREATED_BY);
assertions.assertThat(storedDocument.getCreationDate()).isEqualTo(CREATION_DATE);
assertions.assertThat(storedDocument.getUpdatedBy()).isEqualTo(UPDATED_BY);
assertions.assertThat(storedDocument.getUpdateDate()).isEqualTo(updateDate);
assertions.assertThat(storedDocument.getDataVersion()).isEqualTo(DATA_VERSION2);
assertions.assertAll();
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class SearchFacadeIT method testSearchDocumentsByCollectionIds.
@Test
public void testSearchDocumentsByCollectionIds() {
String id1 = createDocument(collectionIds.get(0), "doc1").getId();
String id2 = createDocument(collectionIds.get(0), "doc2").getId();
createDocument(collectionIds.get(1), "doc3");
createDocument(collectionIds.get(1), "doc4");
String id5 = createDocument(collectionIds.get(2), "doc5").getId();
String id6 = createDocument(collectionIds.get(2), "doc6").getId();
List<Document> documents = searchFacade.searchDocuments(new JsonQuery(new HashSet<>(Arrays.asList(collectionIds.get(0), collectionIds.get(2))), null, null));
assertThat(documents).extracting(Document::getId).containsOnly(id1, id2, id5, id6);
}
use of io.lumeer.api.model.Document in project engine by Lumeer.
the class SearchFacadeIT method testSearchDocumentsByFullText.
@Test
public void testSearchDocumentsByFullText() {
String id1 = createDocument(collectionIds.get(0), "word").getId();
String id2 = createDocument(collectionIds.get(0), "fulltext").getId();
String id3 = createDocument(collectionIds.get(1), "something fulltext").getId();
String id4 = createDocument(collectionIds.get(1), "some other word").getId();
String id5 = createDocument(collectionIds.get(2), "full word").getId();
List<Document> documents = searchFacade.searchDocuments(new JsonQuery("fulltext"));
assertThat(documents).extracting(Document::getId).containsOnly(id2, id3);
documents = searchFacade.searchDocuments(new JsonQuery("word"));
assertThat(documents).extracting(Document::getId).containsOnly(id1, id4, id5);
}
Aggregations