Search in sources :

Example 1 with ImportParameters

use of com.google.refine.importers.tree.ImportParameters in project OpenRefine by OpenRefine.

the class XmlImportUtilitiesTests method importTreeDataXmlTest.

@Test
public void importTreeDataXmlTest() {
    loadSampleXml();
    String[] recordPath = new String[] { "library", "book" };
    XmlImportUtilitiesStub.importTreeData(createXmlParser(), project, recordPath, columnGroup, -1, new ImportParameters(false, true, false));
    log(project);
    assertProjectCreated(project, 0, 6);
    Assert.assertEquals(project.rows.get(0).cells.size(), 4);
    Assert.assertEquals(columnGroup.subgroups.size(), 1);
    Assert.assertNotNull(columnGroup.subgroups.get("book"));
    Assert.assertEquals(columnGroup.subgroups.get("book").subgroups.size(), 3);
    Assert.assertNotNull(columnGroup.subgroups.get("book").subgroups.get("author"));
    Assert.assertNotNull(columnGroup.subgroups.get("book").subgroups.get("title"));
    Assert.assertNotNull(columnGroup.subgroups.get("book").subgroups.get("publish_date"));
}
Also used : ImportParameters(com.google.refine.importers.tree.ImportParameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Example 2 with ImportParameters

use of com.google.refine.importers.tree.ImportParameters in project OpenRefine by OpenRefine.

the class XmlImportUtilitiesTests method importTreeDataXmlTestDeprecated.

/**
 * Test of deprecated method which can go away when it does
 */
@Test
public void importTreeDataXmlTestDeprecated() {
    loadSampleXml();
    String[] recordPath = new String[] { "library", "book" };
    try {
        XmlImportUtilitiesStub.importTreeData(createXmlParser(), project, recordPath, columnGroup, -1, new ImportParameters(false, true, false));
    } catch (Exception e) {
        Assert.fail();
    }
    assertProjectCreated(project, 0, 6);
    Assert.assertEquals(project.rows.get(0).cells.size(), 4);
    Assert.assertEquals(columnGroup.subgroups.size(), 1);
    Assert.assertNotNull(columnGroup.subgroups.get("book"));
    Assert.assertEquals(columnGroup.subgroups.get("book").subgroups.size(), 3);
    Assert.assertNotNull(columnGroup.subgroups.get("book").subgroups.get("author"));
    Assert.assertNotNull(columnGroup.subgroups.get("book").subgroups.get("title"));
    Assert.assertNotNull(columnGroup.subgroups.get("book").subgroups.get("publish_date"));
}
Also used : ImportParameters(com.google.refine.importers.tree.ImportParameters) TreeReaderException(com.google.refine.importers.tree.TreeReaderException) IOException(java.io.IOException) XMLStreamException(javax.xml.stream.XMLStreamException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with ImportParameters

use of com.google.refine.importers.tree.ImportParameters in project OpenRefine by OpenRefine.

the class XmlImportUtilitiesTests method importXmlWithVaryingStructureTestDeprecated.

/**
 * Test using deprecated method which can go away when it does
 */
@Test
public void importXmlWithVaryingStructureTestDeprecated() {
    loadData(XmlImporterTests.getSampleWithVaryingStructure());
    String[] recordPath = new String[] { "library", "book" };
    try {
        XmlImportUtilitiesStub.importTreeData(createXmlParser(), project, recordPath, columnGroup, -1, new ImportParameters(false, true, false));
    } catch (Exception e) {
        Assert.fail();
    }
    assertProjectCreated(project, 0, 6);
    Assert.assertEquals(project.rows.get(0).cells.size(), 4);
    Assert.assertEquals(project.rows.get(5).cells.size(), 5);
    Assert.assertEquals(columnGroup.subgroups.size(), 1);
    Assert.assertEquals(columnGroup.name, "");
    ImportColumnGroup book = columnGroup.subgroups.get("book");
    Assert.assertNotNull(book);
    Assert.assertEquals(book.columns.size(), 1);
    Assert.assertEquals(book.subgroups.size(), 4);
    Assert.assertNotNull(book.subgroups.get("author"));
    Assert.assertEquals(book.subgroups.get("author").columns.size(), 1);
    Assert.assertNotNull(book.subgroups.get("title"));
    Assert.assertNotNull(book.subgroups.get("publish_date"));
    Assert.assertNotNull(book.subgroups.get("genre"));
}
Also used : ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ImportParameters(com.google.refine.importers.tree.ImportParameters) TreeReaderException(com.google.refine.importers.tree.TreeReaderException) IOException(java.io.IOException) XMLStreamException(javax.xml.stream.XMLStreamException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with ImportParameters

use of com.google.refine.importers.tree.ImportParameters in project OpenRefine by OpenRefine.

the class XmlImportUtilitiesTests method processSubRecordTestXml.

@Test
public void processSubRecordTestXml() {
    loadData("<?xml version=\"1.0\"?><library><book id=\"1\"><author>author1</author><genre>genre1</genre></book></library>");
    createXmlParser();
    ParserSkip();
    try {
        SUT.ProcessSubRecordWrapper(project, parser, columnGroup, record, 0, new ImportParameters(false, false, false));
    } catch (Exception e) {
        Assert.fail();
    }
    log(project);
    Assert.assertEquals(columnGroup.subgroups.size(), 1);
    Assert.assertEquals(columnGroup.name, "");
    Assert.assertNotNull(columnGroup.subgroups.get("library"));
    Assert.assertEquals(columnGroup.subgroups.get("library").subgroups.size(), 1);
    ImportColumnGroup book = columnGroup.subgroups.get("library").subgroups.get("book");
    Assert.assertNotNull(book);
    Assert.assertEquals(book.subgroups.size(), 2);
    Assert.assertNotNull(book.subgroups.get("author"));
    Assert.assertNotNull(book.subgroups.get("genre"));
//TODO check record
}
Also used : ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ImportParameters(com.google.refine.importers.tree.ImportParameters) TreeReaderException(com.google.refine.importers.tree.TreeReaderException) IOException(java.io.IOException) XMLStreamException(javax.xml.stream.XMLStreamException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Example 5 with ImportParameters

use of com.google.refine.importers.tree.ImportParameters in project OpenRefine by OpenRefine.

the class XmlImportUtilitiesTests method importXmlWithVaryingStructureTest.

@Test
public void importXmlWithVaryingStructureTest() {
    loadData(XmlImporterTests.getSampleWithVaryingStructure());
    String[] recordPath = new String[] { "library", "book" };
    XmlImportUtilitiesStub.importTreeData(createXmlParser(), project, recordPath, columnGroup, -1, new ImportParameters(false, true, false));
    log(project);
    assertProjectCreated(project, 0, 6);
    Assert.assertEquals(project.rows.get(0).cells.size(), 4);
    Assert.assertEquals(project.rows.get(5).cells.size(), 5);
    Assert.assertEquals(columnGroup.subgroups.size(), 1);
    Assert.assertEquals(columnGroup.name, "");
    ImportColumnGroup book = columnGroup.subgroups.get("book");
    Assert.assertNotNull(book);
    Assert.assertEquals(book.columns.size(), 1);
    Assert.assertEquals(book.subgroups.size(), 4);
    Assert.assertNotNull(book.subgroups.get("author"));
    Assert.assertEquals(book.subgroups.get("author").columns.size(), 1);
    Assert.assertNotNull(book.subgroups.get("title"));
    Assert.assertNotNull(book.subgroups.get("publish_date"));
    Assert.assertNotNull(book.subgroups.get("genre"));
}
Also used : ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ImportParameters(com.google.refine.importers.tree.ImportParameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Aggregations

ImportParameters (com.google.refine.importers.tree.ImportParameters)7 BeforeTest (org.testng.annotations.BeforeTest)7 Test (org.testng.annotations.Test)7 TreeReaderException (com.google.refine.importers.tree.TreeReaderException)5 IOException (java.io.IOException)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 XMLStreamException (javax.xml.stream.XMLStreamException)5 RefineTest (com.google.refine.RefineTest)4 ImportColumnGroup (com.google.refine.importers.tree.ImportColumnGroup)4 RefineTest (com.google.refine.tests.RefineTest)3