use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.
the class LinkInstanceServiceIT method testGetLinkInstancesByLinkTypeIds.
@Test
public void testGetLinkInstancesByLinkTypeIds() {
String id1 = linkInstanceDao.createLinkInstance(prepareLinkInstance()).getId();
LinkInstance linkInstance2 = prepareLinkInstance();
linkInstance2.setLinkTypeId(linkTypeId1);
linkInstance2.setDocumentIds(Arrays.asList(documentIdsColl1.get(0), documentIdsColl2.get(2)));
String id2 = linkInstanceDao.createLinkInstance(linkInstance2).getId();
LinkInstance linkInstance3 = prepareLinkInstance();
linkInstance3.setLinkTypeId(linkTypeId1);
linkInstance3.setDocumentIds(Arrays.asList(documentIdsColl1.get(1), documentIdsColl2.get(1)));
String id3 = linkInstanceDao.createLinkInstance(linkInstance3).getId();
LinkInstance linkInstance4 = prepareLinkInstance();
linkInstance4.setLinkTypeId(linkTypeId2);
linkInstance4.setDocumentIds(Arrays.asList(documentIdsColl1.get(0), documentIdsColl2.get(0)));
String id4 = linkInstanceDao.createLinkInstance(linkInstance4).getId();
JsonQuery jsonQuery1 = new JsonQuery(null, new HashSet<>(Arrays.asList(linkTypeId1, linkTypeId2)), null);
Entity entity1 = Entity.json(jsonQuery1);
Response response = client.target(LINK_INSTANCES_URL).path("search").request(MediaType.APPLICATION_JSON).buildPost(entity1).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<LinkInstance> linkInstances = response.readEntity(new GenericType<List<LinkInstance>>() {
});
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id3, id4));
JsonQuery jsonQuery2 = new JsonQuery(null, Collections.singleton(linkTypeId1), null);
Entity entity2 = Entity.json(jsonQuery2);
response = client.target(LINK_INSTANCES_URL).path("search").request(MediaType.APPLICATION_JSON).buildPost(entity2).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
linkInstances = response.readEntity(new GenericType<List<LinkInstance>>() {
});
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id3));
}
use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.
the class LinkInstanceServiceIT method testGetLinkInstancesByDocumentIds.
@Test
public void testGetLinkInstancesByDocumentIds() {
String id1 = linkInstanceDao.createLinkInstance(prepareLinkInstance()).getId();
LinkInstance linkInstance2 = prepareLinkInstance();
linkInstance2.setLinkTypeId(linkTypeId1);
linkInstance2.setDocumentIds(Arrays.asList(documentIdsColl1.get(0), documentIdsColl2.get(2)));
String id2 = linkInstanceDao.createLinkInstance(linkInstance2).getId();
LinkInstance linkInstance3 = prepareLinkInstance();
linkInstance3.setLinkTypeId(linkTypeId1);
linkInstance3.setDocumentIds(Arrays.asList(documentIdsColl1.get(1), documentIdsColl2.get(1)));
String id3 = linkInstanceDao.createLinkInstance(linkInstance3).getId();
LinkInstance linkInstance4 = prepareLinkInstance();
linkInstance4.setLinkTypeId(linkTypeId2);
linkInstance4.setDocumentIds(Arrays.asList(documentIdsColl1.get(0), documentIdsColl2.get(0)));
String id4 = linkInstanceDao.createLinkInstance(linkInstance4).getId();
JsonQuery jsonQuery1 = new JsonQuery(null, null, Collections.singleton(documentIdsColl1.get(0)));
Entity entity1 = Entity.json(jsonQuery1);
Response response = client.target(LINK_INSTANCES_URL).path("search").request(MediaType.APPLICATION_JSON).buildPost(entity1).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<LinkInstance> linkInstances = response.readEntity(new GenericType<List<LinkInstance>>() {
});
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id4));
JsonQuery jsonQuery2 = new JsonQuery(null, null, Collections.singleton(documentIdsColl2.get(1)));
Entity entity2 = Entity.json(jsonQuery2);
response = client.target(LINK_INSTANCES_URL).path("search").request(MediaType.APPLICATION_JSON).buildPost(entity2).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
linkInstances = response.readEntity(new GenericType<List<LinkInstance>>() {
});
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Collections.singletonList(id3));
}
use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.
the class LinkTypeServiceIT method testGetLinkTypesByCollectionIds.
@Test
public void testGetLinkTypesByCollectionIds() {
String id1 = linkTypeDao.createLinkType(prepareLinkType()).getId();
LinkType linkType2 = prepareLinkType();
linkType2.setCollectionIds(Arrays.asList(collectionIds.get(1), collectionIds.get(2)));
linkTypeDao.createLinkType(linkType2);
LinkType linkType3 = prepareLinkType();
linkType3.setCollectionIds(Arrays.asList(collectionIds.get(1), collectionIds.get(0)));
String id3 = linkTypeDao.createLinkType(linkType3).getId();
LinkType linkType4 = prepareLinkType();
linkType4.setCollectionIds(Arrays.asList(collectionIds.get(0), collectionIds.get(2)));
String id4 = linkTypeDao.createLinkType(linkType4).getId();
JsonQuery jsonQuery = new JsonQuery(Collections.singleton(collectionIds.get(0)), null, null);
Entity entity = Entity.json(jsonQuery);
Response response = client.target(LINK_TYPES_URL).path("search").request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<LinkType> linkTypes = response.readEntity(new GenericType<List<LinkType>>() {
});
assertThat(linkTypes).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id3, id4));
}
use of io.lumeer.api.dto.JsonQuery 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.dto.JsonQuery in project engine by Lumeer.
the class SearchFacadeIT method testSearchCollectionsByCollectionIds.
@Test
public void testSearchCollectionsByCollectionIds() {
List<Collection> collections = searchFacade.searchCollections(new JsonQuery(new HashSet<>(Arrays.asList(collectionIds.get(0), collectionIds.get(2))), null, null));
assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(0), collectionIds.get(2));
collections = searchFacade.searchCollections(new JsonQuery(Collections.singleton(collectionIds.get(1)), null, null));
assertThat(collections).extracting(Collection::getId).containsOnly(collectionIds.get(1));
}
Aggregations