use of org.molgenis.data.DataService 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);
}
use of org.molgenis.data.DataService in project molgenis by molgenis.
the class PostgreSqlRepositoryCollectionTest method setUpBeforeMethod.
@BeforeMethod
public void setUpBeforeMethod() {
PostgreSqlEntityFactory postgreSqlEntityFactory = mock(PostgreSqlEntityFactory.class);
DataSource dataSource = mock(DataSource.class);
jdbcTemplate = mock(JdbcTemplate.class);
dataService = mock(DataService.class);
postgreSqlRepoCollection = new PostgreSqlRepositoryCollection(postgreSqlEntityFactory, dataSource, jdbcTemplate, dataService);
}
use of org.molgenis.data.DataService in project molgenis by molgenis.
the class PluginInterceptorTest method postHandle_authenticated.
@Test
public void postHandle_authenticated() throws Exception {
boolean isAuthenticated = true;
when(authentication.isAuthenticated()).thenReturn(isAuthenticated);
PluginInterceptor molgenisPluginInterceptor = new PluginInterceptor(molgenisUi, permissionService);
String uri = PluginController.PLUGIN_URI_PREFIX + "test";
ModelAndView modelAndView = new ModelAndView();
HandlerMethod handlerMethod = mock(HandlerMethod.class);
PluginController pluginController = createMolgenisPluginController(uri);
DataService dataService = mock(DataService.class);
pluginController.setDataService(dataService);
when(handlerMethod.getBean()).thenReturn(pluginController);
molgenisPluginInterceptor.postHandle(null, null, handlerMethod, modelAndView);
assertEquals(modelAndView.getModel().get(PluginAttributes.KEY_PLUGIN_ID), "test");
assertNotNull(modelAndView.getModel().get(PluginAttributes.KEY_MOLGENIS_UI));
assertEquals(modelAndView.getModel().get(PluginAttributes.KEY_AUTHENTICATED), isAuthenticated);
}
Aggregations