Search in sources :

Example 11 with Menu

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

the class MappingServiceControllerTest method itShouldCreateNewAttributeMappingWhenSavingIfNonePresent.

@Test
public void itShouldCreateNewAttributeMappingWhenSavingIfNonePresent() throws Exception {
    when(mappingService.getMappingProject("asdf")).thenReturn(mappingProject);
    Menu menu = mock(Menu.class);
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(menu.findMenuItemPath(ID)).thenReturn("/menu/main/mappingservice");
    heightAttr = attrMetaFactory.create().setName("height").setDataType(INT);
    hop.addAttribute(heightAttr);
    mockMvc.perform(post(URI + "/saveattributemapping").param("mappingProjectId", "asdf").param("target", "HOP").param("source", "LifeLines").param("targetAttribute", "height").param("algorithm", "$('length').value()").param("algorithmState", "CURATED")).andExpect(redirectedUrl("/menu/main/mappingservice/mappingproject/asdf"));
    MappingProject expected = new MappingProject("hop hop hop", me);
    expected.setIdentifier("asdf");
    MappingTarget mappingTarget = expected.addTarget(hop);
    EntityMapping entityMapping = mappingTarget.addSource(lifeLines);
    AttributeMapping ageMapping = entityMapping.addAttributeMapping("age");
    ageMapping.setAlgorithm("$('dob').age()");
    AttributeMapping heightMapping = entityMapping.addAttributeMapping("height");
    heightMapping.setAlgorithm("$('length').value()");
    heightMapping.setAlgorithmState(AttributeMapping.AlgorithmState.CURATED);
    Mockito.verify(mappingService).updateMappingProject(expected);
}
Also used : EntityMapping(org.molgenis.semanticmapper.mapping.model.EntityMapping) MappingProject(org.molgenis.semanticmapper.mapping.model.MappingProject) AttributeMapping(org.molgenis.semanticmapper.mapping.model.AttributeMapping) Menu(org.molgenis.core.ui.menu.Menu) MappingTarget(org.molgenis.semanticmapper.mapping.model.MappingTarget) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 12 with Menu

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

the class MappingServiceControllerTest method itShouldRemoveEmptyAttributeMappingsWhenSaving.

@Test
public void itShouldRemoveEmptyAttributeMappingsWhenSaving() throws Exception {
    when(mappingService.getMappingProject("asdf")).thenReturn(mappingProject);
    Menu menu = mock(Menu.class);
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(menu.findMenuItemPath(ID)).thenReturn("/menu/main/mappingservice");
    mockMvc.perform(post(URI + "/saveattributemapping").param("mappingProjectId", "asdf").param("target", "HOP").param("source", "LifeLines").param("targetAttribute", "age").param("algorithm", "").param("algorithmState", "CURATED")).andExpect(redirectedUrl("/menu/main/mappingservice/mappingproject/asdf"));
    MappingProject expected = new MappingProject("hop hop hop", me);
    expected.setIdentifier("asdf");
    MappingTarget mappingTarget = expected.addTarget(hop);
    mappingTarget.addSource(lifeLines);
    Mockito.verify(mappingService).updateMappingProject(expected);
}
Also used : MappingProject(org.molgenis.semanticmapper.mapping.model.MappingProject) Menu(org.molgenis.core.ui.menu.Menu) MappingTarget(org.molgenis.semanticmapper.mapping.model.MappingTarget) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 13 with Menu

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

the class MappingServiceControllerTest method getFirstAttributeMappingInfo_age.

@Test
public void getFirstAttributeMappingInfo_age() throws Exception {
    when(mappingService.getMappingProject("asdf")).thenReturn(mappingProject);
    Menu menu = mock(Menu.class);
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(menu.findMenuItemPath(ID)).thenReturn("/menu/main/mappingservice");
    MvcResult result = mockMvc.perform(post(URI + "/firstattributemapping").param("mappingProjectId", "asdf").param("target", "HOP").param("source", "LifeLines").param("skipAlgorithmStates[]", "CURATED", "DISCUSS").accept(MediaType.APPLICATION_JSON)).andReturn();
    String actual = result.getResponse().getContentAsString();
    assertEquals(actual, "{\"mappingProjectId\":\"asdf\",\"target\":\"HOP\",\"source\":\"LifeLines\",\"targetAttribute\":\"age\"}");
}
Also used : Menu(org.molgenis.core.ui.menu.Menu) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 14 with Menu

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

the class SettingsControllerTest method before.

@BeforeMethod
public void before() {
    initMocks(this);
    Menu menu = mock(Menu.class);
    when(menu.findMenuItemPath(SettingsController.ID)).thenReturn("/test/path");
    when(menuReaderService.getMenu()).thenReturn(menu);
    when(appSettings.getLanguageCode()).thenReturn("DDEEFF");
    User user = mock(User.class);
    when(userAccountService.getCurrentUser()).thenReturn(user);
    when(user.isSuperuser()).thenReturn(false);
    SettingsController settingsController = new SettingsController(menuReaderService, appSettings, userAccountService);
    mockMvc = standaloneSetup(settingsController).build();
}
Also used : 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