Search in sources :

Example 11 with DataCollection

use of org.molgenis.oneclickimporter.model.DataCollection in project molgenis by molgenis.

the class OneClickImporterServiceTest method testBuildDataSheetWithValidFormulaFile.

@Test
public void testBuildDataSheetWithValidFormulaFile() throws IOException, InvalidFormatException, URISyntaxException, EmptySheetException {
    List<Sheet> sheets = loadSheetFromFile(OneClickImporterServiceTest.class, "/valid-with-formula.xlsx");
    DataCollection actual = oneClickImporterService.buildDataCollectionsFromExcel(sheets).get(0);
    Column c1 = Column.create("name", 0, newArrayList("Mark", "Mariska"));
    Column c2 = Column.create("age", 1, newArrayList(26.0, 22.0));
    DataCollection expected = DataCollection.create("Sheet1", newArrayList(c1, c2));
    assertEquals(actual, expected);
}
Also used : DataCollection(org.molgenis.oneclickimporter.model.DataCollection) Column(org.molgenis.oneclickimporter.model.Column) Sheet(org.apache.poi.ss.usermodel.Sheet) Test(org.testng.annotations.Test)

Example 12 with DataCollection

use of org.molgenis.oneclickimporter.model.DataCollection in project molgenis by molgenis.

the class OneClickImporterServiceTest method testBuildDataCollectionWithComplexValidCsvFile.

@Test
public void testBuildDataCollectionWithComplexValidCsvFile() throws IOException, URISyntaxException {
    oneClickImporterService = new OneClickImporterServiceImpl();
    List<String[]> lines = loadLinesFromFile(OneClickImporterServiceTest.class, "/complex-valid.csv");
    DataCollection actual = oneClickImporterService.buildDataCollectionFromCsv("complex-valid", lines);
    Column c1 = Column.create("first name", 0, newArrayList("Mark", "Fleur", "Dennis", "Bart", "Sido", "Mariska", "Tommy", "Connor", "Piet", "Jan"));
    Column c2 = Column.create("last name", 1, newArrayList("de Haan", "Kelpin", "Hendriksen", "Charbon", "Haakma", "Slofstra", "de Boer", "Stroomberg", "Klaassen", null));
    Column c3 = Column.create("full name", 2, newArrayList("Mark de Haan", "Fleur Kelpin", "Dennis Hendriksen", "Bart Charbon", "Sido Haakma", "Mariska Slofstra", "Tommy de Boer", "Connor Stroomberg", "Piet Klaassen", null));
    Column c4 = Column.create("UMCG employee", 3, newArrayList(true, true, true, true, true, true, true, true, false, false));
    Column c5 = Column.create("Age", 4, newArrayList(26.4f, null, null, null, null, 22, 27, null, 53, 0.123f));
    DataCollection expected = DataCollection.create("complex-valid", newArrayList(c1, c2, c3, c4, c5));
    assertEquals(actual, expected);
}
Also used : DataCollection(org.molgenis.oneclickimporter.model.DataCollection) Column(org.molgenis.oneclickimporter.model.Column) OneClickImporterServiceImpl(org.molgenis.oneclickimporter.service.impl.OneClickImporterServiceImpl) Test(org.testng.annotations.Test)

Example 13 with DataCollection

use of org.molgenis.oneclickimporter.model.DataCollection in project molgenis by molgenis.

the class OneClickImporterServiceTest method testBuildDataCollectionWithSimpleValidCsvFile.

@Test
public void testBuildDataCollectionWithSimpleValidCsvFile() throws IOException, URISyntaxException {
    oneClickImporterService = new OneClickImporterServiceImpl();
    List<String[]> lines = loadLinesFromFile(OneClickImporterServiceTest.class, "/simple-valid.csv");
    DataCollection actual = oneClickImporterService.buildDataCollectionFromCsv("simple-valid", lines);
    Column c1 = Column.create("name", 0, newArrayList("Mark", "Connor", "Fleur", "Dennis"));
    Column c2 = Column.create("superpower", 1, newArrayList("arrow functions", "Oldschool syntax", "Lambda Magician", "Root access"));
    DataCollection expected = DataCollection.create("simple-valid", newArrayList(c1, c2));
    assertEquals(actual, expected);
}
Also used : DataCollection(org.molgenis.oneclickimporter.model.DataCollection) Column(org.molgenis.oneclickimporter.model.Column) OneClickImporterServiceImpl(org.molgenis.oneclickimporter.service.impl.OneClickImporterServiceImpl) Test(org.testng.annotations.Test)

Aggregations

DataCollection (org.molgenis.oneclickimporter.model.DataCollection)13 Test (org.testng.annotations.Test)11 Column (org.molgenis.oneclickimporter.model.Column)9 Sheet (org.apache.poi.ss.usermodel.Sheet)6 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)4 File (java.io.File)4 EntityType (org.molgenis.data.meta.model.EntityType)4 ArrayList (java.util.ArrayList)3 Progress (org.molgenis.jobs.Progress)3 OneClickImporterTestUtils.loadFile (org.molgenis.oneclickimporter.service.utils.OneClickImporterTestUtils.loadFile)3 OneClickImporterServiceImpl (org.molgenis.oneclickimporter.service.impl.OneClickImporterServiceImpl)2 List (java.util.List)1 Row (org.apache.poi.ss.usermodel.Row)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Entity (org.molgenis.data.Entity)1 Package (org.molgenis.data.meta.model.Package)1 UnknownFileTypeException (org.molgenis.oneclickimporter.exceptions.UnknownFileTypeException)1 EntityServiceImpl (org.molgenis.oneclickimporter.service.impl.EntityServiceImpl)1 Transactional (org.springframework.transaction.annotation.Transactional)1