Search in sources :

Example 1 with Result

use of org.molgenis.searchall.model.Result in project molgenis by molgenis.

the class SearchAllServiceTest method testFindAll.

@Test
public void testFindAll() throws Exception {
    when(dataService.findAll(PackageMetadata.PACKAGE, Package.class)).thenReturn(Stream.of(pack1, pack2, pack3, pack_sys));
    when(dataService.findAll(EntityTypeMetadata.ENTITY_TYPE_META_DATA, EntityType.class)).thenReturn(Stream.of(entity1, entity2, entity3, entity4, abstractEntity));
    when(dataService.count("entity id 1", new QueryImpl<>().search("test"))).thenReturn(2L);
    when(dataService.count("entity id 3", new QueryImpl<>().search("test"))).thenReturn(6L);
    when(dataService.count("entity id 4", new QueryImpl<>().search("test"))).thenReturn(11L);
    PackageResult packageResult = PackageResult.create("package id 1", "package test nr 1", "package description 1");
    AttributeResult attributeResult = AttributeResult.create("attr test nr 1", "attr description 1", "BOOL");
    EntityTypeResult entityTypeResult1 = EntityTypeResult.builder().setId("entity id 1").setLabel("entity nr 1").setDescription("entity description 1").setPackageId("package id 2").setLabelMatch(false).setDescriptionMatch(false).setAttributes(singletonList(attributeResult)).setNrOfMatchingEntities(2).build();
    EntityTypeResult entityTypeResult2 = EntityTypeResult.builder().setId("entity id 3").setLabel("entity test nr 3").setDescription("entity description 3").setPackageId("package id 3").setLabelMatch(true).setDescriptionMatch(false).setAttributes(Collections.emptyList()).setNrOfMatchingEntities(6).build();
    EntityTypeResult entityTypeResult3 = EntityTypeResult.builder().setId("entity id 4").setLabel("entity nr 4").setDescription("entity test description 4").setPackageId(null).setLabelMatch(false).setDescriptionMatch(true).setAttributes(Collections.emptyList()).setNrOfMatchingEntities(11).build();
    Result result = Result.builder().setEntityTypes(Arrays.asList(entityTypeResult1, entityTypeResult2, entityTypeResult3)).setPackages(singletonList(packageResult)).build();
    assertEquals(searchAllService.searchAll("test"), result);
}
Also used : EntityTypeResult(org.molgenis.searchall.model.EntityTypeResult) QueryImpl(org.molgenis.data.support.QueryImpl) PackageResult(org.molgenis.searchall.model.PackageResult) AttributeResult(org.molgenis.searchall.model.AttributeResult) EntityTypeResult(org.molgenis.searchall.model.EntityTypeResult) AttributeResult(org.molgenis.searchall.model.AttributeResult) PackageResult(org.molgenis.searchall.model.PackageResult) Result(org.molgenis.searchall.model.Result) Test(org.testng.annotations.Test)

Aggregations

QueryImpl (org.molgenis.data.support.QueryImpl)1 AttributeResult (org.molgenis.searchall.model.AttributeResult)1 EntityTypeResult (org.molgenis.searchall.model.EntityTypeResult)1 PackageResult (org.molgenis.searchall.model.PackageResult)1 Result (org.molgenis.searchall.model.Result)1 Test (org.testng.annotations.Test)1