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);
}
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);
}
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\"}");
}
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();
}
Aggregations