Search in sources :

Example 1 with SearchAllService

use of org.molgenis.searchall.service.SearchAllService in project molgenis by molgenis.

the class SearchAllServiceTest method setUp.

@BeforeClass
public void setUp() {
    dataService = mock(DataService.class);
    searchAllService = new SearchAllService(dataService);
    LocaleContextHolder.setLocale(Locale.ENGLISH);
    pack1 = mock(Package.class);
    when(pack1.getLabel()).thenReturn("package test nr 1");
    when(pack1.getId()).thenReturn("package id 1");
    when(pack1.getDescription()).thenReturn("package description 1");
    pack2 = mock(Package.class);
    when(pack2.getLabel()).thenReturn("package nr 2");
    when(pack2.getId()).thenReturn("package id 2");
    when(pack2.getDescription()).thenReturn("package description 2");
    pack_sys = mock(Package.class);
    when(pack_sys.getLabel()).thenReturn("package sys");
    when(pack_sys.getId()).thenReturn(PACKAGE_SYSTEM);
    when(pack_sys.getDescription()).thenReturn("package test description");
    pack3 = mock(Package.class);
    when(pack3.getLabel()).thenReturn("package nr 3");
    when(pack3.getId()).thenReturn("package id 3");
    when(pack3.getDescription()).thenReturn(null);
    // matches label
    attr1 = mock(Attribute.class);
    when(attr1.getLabel("en")).thenReturn("attr test nr 1");
    when(attr1.getName()).thenReturn("attr id 1");
    when(attr1.getDescription("en")).thenReturn("attr description 1");
    when(attr1.getDataType()).thenReturn(BOOL);
    // no match
    attr2 = mock(Attribute.class);
    when(attr2.getLabel("en")).thenReturn("attr nr 2");
    when(attr2.getName()).thenReturn("attr id 2");
    when(attr2.getDescription("en")).thenReturn(null);
    when(attr2.getDataType()).thenReturn(BOOL);
    // no match
    attr3 = mock(Attribute.class);
    when(attr3.getLabel("en")).thenReturn("attr nr 3");
    when(attr3.getName()).thenReturn("attr id 3");
    when(attr3.getDescription("en")).thenReturn("attr description 3");
    when(attr3.getDataType()).thenReturn(BOOL);
    // no match
    attr4 = mock(Attribute.class);
    when(attr4.getLabel("en")).thenReturn("attr nr 4");
    when(attr4.getName()).thenReturn("attr id 4");
    when(attr4.getDescription("en")).thenReturn("attr description 4");
    when(attr4.getDataType()).thenReturn(BOOL);
    // no match
    attr5 = mock(Attribute.class);
    when(attr5.getLabel("en")).thenReturn("attr nr 5");
    when(attr5.getName()).thenReturn("attr id 5");
    when(attr5.getDescription("en")).thenReturn("attr description 5");
    when(attr5.getDataType()).thenReturn(BOOL);
    entity1 = mock(EntityType.class);
    when(entity1.getLabel("en")).thenReturn("entity nr 1");
    when(entity1.getId()).thenReturn("entity id 1");
    when(entity1.getDescription("en")).thenReturn("entity description 1");
    when(entity1.getAllAttributes()).thenReturn(singletonList(attr1));
    when(entity1.getPackage()).thenReturn(pack2);
    entity2 = mock(EntityType.class);
    when(entity2.getLabel("en")).thenReturn("entity nr 2");
    when(entity2.getId()).thenReturn("entity id 2");
    when(entity2.getDescription("en")).thenReturn("entity description 2");
    when(entity2.getAllAttributes()).thenReturn(Arrays.asList(attr2, attr5));
    when(entity2.getPackage()).thenReturn(pack2);
    entity3 = mock(EntityType.class);
    when(entity3.getLabel("en")).thenReturn("entity test nr 3");
    when(entity3.getId()).thenReturn("entity id 3");
    when(entity3.getDescription("en")).thenReturn("entity description 3");
    when(entity3.getAllAttributes()).thenReturn(singletonList(attr3));
    when(entity3.getPackage()).thenReturn(pack3);
    entity4 = mock(EntityType.class);
    when(entity4.getLabel("en")).thenReturn("entity nr 4");
    when(entity4.getId()).thenReturn("entity id 4");
    when(entity4.getDescription("en")).thenReturn("entity test description 4");
    when(entity4.getAllAttributes()).thenReturn(singletonList(attr4));
    when(entity4.getPackage()).thenReturn(null);
    abstractEntity = mock(EntityType.class);
    when(abstractEntity.getLabel("en")).thenReturn("abstract");
    when(abstractEntity.getId()).thenReturn("abstract");
    when(abstractEntity.getDescription("en")).thenReturn("abstract");
    when(abstractEntity.getAllAttributes()).thenReturn(singletonList(attr1));
    when(abstractEntity.isAbstract()).thenReturn(true);
    when(abstractEntity.getPackage()).thenReturn(pack1);
}
Also used : SearchAllService(org.molgenis.searchall.service.SearchAllService) Package(org.molgenis.data.meta.model.Package) DataService(org.molgenis.data.DataService) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

DataService (org.molgenis.data.DataService)1 Package (org.molgenis.data.meta.model.Package)1 SearchAllService (org.molgenis.searchall.service.SearchAllService)1 BeforeClass (org.testng.annotations.BeforeClass)1