Search in sources :

Example 11 with MetaDataService

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);
}
Also used : MetaDataService(org.molgenis.data.meta.MetaDataService) Test(org.testng.annotations.Test)

Example 12 with MetaDataService

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);
}
Also used : MetaDataService(org.molgenis.data.meta.MetaDataService)

Aggregations

MetaDataService (org.molgenis.data.meta.MetaDataService)12 EntityType (org.molgenis.data.meta.model.EntityType)6 Test (org.testng.annotations.Test)5 QueryImpl (org.molgenis.data.support.QueryImpl)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 Stream (java.util.stream.Stream)3 Attribute (org.molgenis.data.meta.model.Attribute)3 Package (org.molgenis.data.meta.model.Package)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)2 java.util (java.util)2 Arrays.asList (java.util.Arrays.asList)2 Collections.singletonList (java.util.Collections.singletonList)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 org.molgenis.data (org.molgenis.data)2 EntityTestHarness (org.molgenis.data.EntityTestHarness)2 AggregateQuery (org.molgenis.data.aggregation.AggregateQuery)2