Search in sources :

Example 6 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class MetadataManagerControllerTest method beforeMethod.

@BeforeMethod
public void beforeMethod() {
    MockitoAnnotations.initMocks(this);
    FreeMarkerViewResolver freeMarkerViewResolver = new FreeMarkerViewResolver();
    freeMarkerViewResolver.setSuffix(".ftl");
    Menu menu = mock(Menu.class);
    when(menu.findMenuItemPath(MetadataManagerController.METADATA_MANAGER)).thenReturn("/test/path");
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(appSettings.getLanguageCode()).thenReturn("nl");
    User user = mock(User.class);
    when(user.isSuperuser()).thenReturn(false);
    when(userAccountService.getCurrentUser()).thenReturn(user);
    MetadataManagerController metadataEditorController = new MetadataManagerController(menuReaderService, appSettings, metadataManagerService, userAccountService);
    mockMvc = MockMvcBuilders.standaloneSetup(metadataEditorController).setLocaleResolver(localeResolver).setMessageConverters(new FormHttpMessageConverter(), gsonHttpMessageConverter).build();
}
Also used : FormHttpMessageConverter(org.springframework.http.converter.FormHttpMessageConverter) User(org.molgenis.data.security.auth.User) FreeMarkerViewResolver(org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver) Menu(org.molgenis.core.ui.menu.Menu) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class OneClickImporterControllerTest method before.

@BeforeMethod
public void before() {
    OneClickImporterController oneClickImporterController = new OneClickImporterController(menuReaderService, appSettings, userAccountService, fileStore, oneClickImportJobExecutionFactory, jobExecutor);
    Menu menu = mock(Menu.class);
    when(menu.findMenuItemPath(OneClickImporterController.ONE_CLICK_IMPORTER)).thenReturn("/test-path");
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(localeResolver.resolveLocale(any())).thenReturn(new Locale("nl"));
    when(appSettings.getLanguageCode()).thenReturn("en");
    User user = mock(User.class);
    when(user.isSuperuser()).thenReturn(false);
    when(userAccountService.getCurrentUser()).thenReturn(user);
    OneClickImportJobExecution jobExecution = mock(OneClickImportJobExecution.class);
    when(oneClickImportJobExecutionFactory.create()).thenReturn(jobExecution);
    EntityType oneClickImportJobExecutionEntityType = mock(EntityType.class);
    when(jobExecution.getEntityType()).thenReturn(oneClickImportJobExecutionEntityType);
    when(jobExecution.getIdValue()).thenReturn("id_1");
    when(oneClickImportJobExecutionEntityType.getId()).thenReturn("jobExecutionId");
    StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
    stringConverter.setWriteAcceptCharset(false);
    mockMvc = MockMvcBuilders.standaloneSetup(oneClickImporterController).setLocaleResolver(localeResolver).setMessageConverters(gsonHttpMessageConverter, stringConverter).build();
}
Also used : Locale(java.util.Locale) EntityType(org.molgenis.data.meta.model.EntityType) User(org.molgenis.data.security.auth.User) Menu(org.molgenis.core.ui.menu.Menu) OneClickImportJobExecution(org.molgenis.oneclickimporter.job.OneClickImportJobExecution) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class NavigatorControllerTest method before.

@BeforeMethod
public void before() {
    initMocks(this);
    Menu menu = mock(Menu.class);
    when(menu.findMenuItemPath(NavigatorController.ID)).thenReturn("/test/path");
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(appSettings.getLanguageCode()).thenReturn("de");
    User user = mock(User.class);
    when(userAccountService.getCurrentUser()).thenReturn(user);
    when(user.isSuperuser()).thenReturn(false);
    NavigatorController navigatorController = new NavigatorController(menuReaderService, appSettings, userAccountService);
    mockMvc = MockMvcBuilders.standaloneSetup(navigatorController).setLocaleResolver(localeResolver).build();
}
Also used : User(org.molgenis.data.security.auth.User) Menu(org.molgenis.core.ui.menu.Menu) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 9 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class DataExplorerControllerTest method beforeTest.

@BeforeMethod
public void beforeTest() {
    when(permissionService.hasPermission(new EntityTypeIdentity("yes"), EntityTypePermission.WRITEMETA)).thenReturn(true);
    when(permissionService.hasPermission(new EntityTypeIdentity("no"), EntityTypePermission.WRITEMETA)).thenReturn(false);
    when(idAttr.getDataType()).thenReturn(STRING);
    when(entityType.getIdAttribute()).thenReturn(idAttr);
    when(package_.getLabel()).thenReturn("pack");
    when(package_.getId()).thenReturn("packId");
    when(parentPackage.getLabel()).thenReturn("parent");
    when(parentPackage.getId()).thenReturn("parentId");
    when(package_.getParent()).thenReturn(parentPackage);
    when(entityType.getPackage()).thenReturn(package_);
    when(repository.findOneById(entityId)).thenReturn(entity);
    when(dataService.getEntityType(entityTypeId)).thenReturn(entityType);
    when(dataService.getRepository(entityTypeId)).thenReturn(repository);
    when(dataExplorerSettings.getEntityReport(entityTypeId)).thenReturn("template");
    when(dataExplorerSettings.getModStandaloneReports()).thenReturn(true);
    when(freemarkerConfigurer.getConfiguration()).thenReturn(configuration);
    Menu menu = mock(Menu.class);
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(menu.findMenuItemPath(NAVIGATOR)).thenReturn(null);
    when(localeResolver.resolveLocale(any())).thenReturn(Locale.ENGLISH);
    mockMvc = MockMvcBuilders.standaloneSetup(controller).setMessageConverters(gsonHttpMessageConverter).build();
}
Also used : EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) Menu(org.molgenis.core.ui.menu.Menu) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 10 with Menu

use of org.molgenis.core.ui.menu.Menu in project molgenis by molgenis.

the class QuestionnaireControllerTest method beforeMethod.

@BeforeMethod
private void beforeMethod() {
    initMocks(this);
    Menu menu = mock(Menu.class);
    when(menu.findMenuItemPath(QuestionnaireController.ID)).thenReturn("/test/path");
    User user = mock(User.class);
    when(user.isSuperuser()).thenReturn(false);
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(appSettings.getLanguageCode()).thenReturn("en");
    when(userAccountService.getCurrentUser()).thenReturn(user);
    QuestionnaireController questionnaireController = new QuestionnaireController(questionnaireService, menuReaderService, appSettings, userAccountService);
    mockMvc = MockMvcBuilders.standaloneSetup(questionnaireController).setMessageConverters(new FormHttpMessageConverter(), gsonHttpMessageConverter).build();
}
Also used : FormHttpMessageConverter(org.springframework.http.converter.FormHttpMessageConverter) User(org.molgenis.data.security.auth.User) Menu(org.molgenis.core.ui.menu.Menu) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Menu (org.molgenis.core.ui.menu.Menu)14 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)6 BeforeMethod (org.testng.annotations.BeforeMethod)6 Test (org.testng.annotations.Test)6 User (org.molgenis.data.security.auth.User)5 MappingTarget (org.molgenis.semanticmapper.mapping.model.MappingTarget)4 AttributeMapping (org.molgenis.semanticmapper.mapping.model.AttributeMapping)3 EntityMapping (org.molgenis.semanticmapper.mapping.model.EntityMapping)3 MappingProject (org.molgenis.semanticmapper.mapping.model.MappingProject)3 MvcResult (org.springframework.test.web.servlet.MvcResult)3 FormHttpMessageConverter (org.springframework.http.converter.FormHttpMessageConverter)2 GsonBuilder (com.google.gson.GsonBuilder)1 IOException (java.io.IOException)1 Locale (java.util.Locale)1 Molgenis (org.molgenis.core.ui.Molgenis)1 XmlMolgenisUiLoader (org.molgenis.core.ui.XmlMolgenisUiLoader)1 EntityType (org.molgenis.data.meta.model.EntityType)1 EntityTypeIdentity (org.molgenis.data.security.EntityTypeIdentity)1 OneClickImportJobExecution (org.molgenis.oneclickimporter.job.OneClickImportJobExecution)1 StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)1