use of org.molgenis.data.meta.MetaDataService in project molgenis by molgenis.
the class DataExplorerControllerTest method initTrackingIdPresent.
@Test
public void initTrackingIdPresent() {
String selectedEntityname = "selectedEntityname";
String selectedEntityId = "selectedEntityId";
MetaDataService metaDataService = mock(MetaDataService.class);
when(dataService.getMeta()).thenReturn(metaDataService);
when(metaDataService.getEntityTypes()).thenReturn(Stream.empty());
when(appSettings.getGoogleAnalyticsTrackingId()).thenReturn("id");
when(appSettings.getGoogleAnalyticsTrackingIdMolgenis()).thenReturn("id");
controller.init(selectedEntityname, selectedEntityId, model);
verify(model).addAttribute("hasTrackingId", true);
verify(model).addAttribute("hasMolgenisTrackingId", true);
}
use of org.molgenis.data.meta.MetaDataService in project molgenis by molgenis.
the class RestControllerV2Test method testCreateEntitiesAttribute.
@Test
public void testCreateEntitiesAttribute() throws Exception {
MetaDataService metadataService = mock(MetaDataService.class);
when(dataService.getMeta()).thenReturn(metadataService);
when(dataService.getEntityType(ATTRIBUTE_META_DATA)).thenReturn(entityType);
Attribute attribute0 = mock(Attribute.class);
when(attribute0.getIdValue()).thenReturn("p1");
when(attribute0.getEntityType()).thenReturn(entityType);
Attribute attribute1 = mock(Attribute.class);
when(attribute1.getIdValue()).thenReturn("p2");
when(attribute1.getEntityType()).thenReturn(entityType);
when(entityManager.create(entityType, POPULATE)).thenReturn(attribute0).thenReturn(attribute1);
mockMvc.perform(post(BASE_URI + '/' + ATTRIBUTE_META_DATA).content("{entities:[{id:'p1', name:'Piet'}, {id:'p2', name:'Pietje'}]}").contentType(APPLICATION_JSON)).andExpect(status().isCreated()).andExpect(content().contentType(APPLICATION_JSON_UTF8)).andExpect(jsonPath("$.location", is("/api/v2/sys_md_Attribute?q=id=in=(\"p1\",\"p2\")"))).andExpect(jsonPath("$.resources", hasSize(2))).andExpect(jsonPath("$.resources[0].href", is("/api/v2/sys_md_Attribute/p1"))).andExpect(jsonPath("$.resources[1].href", is("/api/v2/sys_md_Attribute/p2")));
verify(metadataService).addAttribute(attribute0);
verify(metadataService).addAttribute(attribute1);
verifyNoMoreInteractions(metadataService);
}
Aggregations