Search in sources :

Example 6 with OneClickImporterNamingServiceImpl

use of org.molgenis.oneclickimporter.service.impl.OneClickImporterNamingServiceImpl in project molgenis by molgenis.

the class OneClickImporterNamingServiceTest method testGetLabelWithPostFixDuplicateInNoOrder.

@Test
public void testGetLabelWithPostFixDuplicateInNoOrder() {
    EntityType e1 = Mockito.mock(EntityType.class);
    when(e1.getLabel()).thenReturn("label");
    EntityType e2 = Mockito.mock(EntityType.class);
    when(e2.getLabel()).thenReturn("label (1)");
    EntityType e3 = Mockito.mock(EntityType.class);
    when(e3.getLabel()).thenReturn("label (3)");
    String label = "label";
    when(dataService.findAll(ENTITY_TYPE_META_DATA, new QueryImpl<EntityType>().like(LABEL, label), EntityType.class)).thenReturn(Stream.of(e1, e2, e3));
    oneClickImporterNamingService = new OneClickImporterNamingServiceImpl(dataService);
    String actual = oneClickImporterNamingService.getLabelWithPostFix(label);
    String expected = "label (2)";
    assertEquals(actual, expected);
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) QueryImpl(org.molgenis.data.support.QueryImpl) OneClickImporterNamingServiceImpl(org.molgenis.oneclickimporter.service.impl.OneClickImporterNamingServiceImpl) Test(org.testng.annotations.Test)

Aggregations

OneClickImporterNamingServiceImpl (org.molgenis.oneclickimporter.service.impl.OneClickImporterNamingServiceImpl)6 Test (org.testng.annotations.Test)6 QueryImpl (org.molgenis.data.support.QueryImpl)4 EntityType (org.molgenis.data.meta.model.EntityType)3