use of ai.grakn.migration.csv.CSVMigrator in project grakn by graknlabs.
the class CSVMigratorTest method whenDataIsMissing_ErrorIsNotThrownAndThoseLinesAreSkipped.
@Test
public void whenDataIsMissing_ErrorIsNotThrownAndThoseLinesAreSkipped() {
load(factory, getFile("csv", "pets/schema.gql"));
String template = getFileAsString("csv", "pets/template.gql");
try (CSVMigrator m = new CSVMigrator(getFile("csv", "pets/data/pets.empty"))) {
defaultMigrator.load(template, m.setNullString("").convert());
}
try (GraknTx graph = factory.open(GraknTxType.WRITE)) {
// Re Open Transaction
Stream<Entity> pets = graph.getEntityType("pet").instances();
assertEquals(1, pets.count());
Stream<Entity> cats = graph.getEntityType("cat").instances();
assertEquals(1, cats.count());
AttributeType<String> name = graph.getAttributeType("name");
AttributeType<String> death = graph.getAttributeType("death");
Entity fluffy = name.getAttribute("Fluffy").ownerInstances().iterator().next().asEntity();
assertEquals(1, fluffy.attributes(death).count());
}
}
Aggregations