use of ai.grakn.migration.base.MigratorBuilder in project grakn by graknlabs.
the class CSVMigratorTest method whenLinesIsSetToN_OnlyFirstNLinesAreProcessed.
@Test
public void whenLinesIsSetToN_OnlyFirstNLinesAreProcessed() {
load(factory, getFile("csv", "pets/schema.gql"));
String template = getFileAsString("csv", "pets/template.gql");
declareAndLoad(template, "pets/data/pets.quotes", new MigratorBuilder().setUri(engine.uri()).setKeyspace(keyspace).setRetries(0).setFailFast(false).setLines(3).build());
try (GraknTx graph = factory.open(GraknTxType.WRITE)) {
// Re Open Transaction
Collection<Entity> pets = graph.getEntityType("pet").instances().collect(Collectors.toSet());
TestCase.assertEquals(3, pets.size());
Collection<Entity> cats = graph.getEntityType("cat").instances().collect(Collectors.toSet());
TestCase.assertEquals(2, cats.size());
Collection<Entity> dogs = graph.getEntityType("dog").instances().collect(Collectors.toSet());
TestCase.assertEquals(0, dogs.size());
}
}
use of ai.grakn.migration.base.MigratorBuilder in project grakn by graknlabs.
the class JsonMigratorTest method setup.
@Before
public void setup() {
Keyspace keyspace = SampleKBLoader.randomKeyspace();
factory = Grakn.session(engine.uri(), keyspace);
migrator = new MigratorBuilder().setUri(engine.uri()).setKeyspace(keyspace).setRetries(0).setFailFast(false).build();
}
use of ai.grakn.migration.base.MigratorBuilder in project grakn by graknlabs.
the class XMLMigratorTest method migrateXMLWithElement.
private static void migrateXMLWithElement(String element, String template) {
// load the schema
MigratorTestUtils.load(session, MigratorTestUtils.getFile("xml", "schema.gql"));
// load the data
Migrator migrator = new MigratorBuilder().setUri(engine.uri()).setKeyspace(keyspace).build();
File xmlFile = MigratorTestUtils.getFile("xml", "data.xml");
XmlMigrator xmlMigrator = new XmlMigrator(xmlFile);
xmlMigrator.element(element);
migrator.load(template, xmlMigrator.convert());
}
Aggregations