Search in sources :

Example 1 with MigratorBuilder

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());
    }
}
Also used : GraknTx(ai.grakn.GraknTx) Entity(ai.grakn.concept.Entity) MigratorBuilder(ai.grakn.migration.base.MigratorBuilder) MigratorTestUtils.getFileAsString(ai.grakn.test.migration.MigratorTestUtils.getFileAsString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 2 with MigratorBuilder

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();
}
Also used : Keyspace(ai.grakn.Keyspace) MigratorBuilder(ai.grakn.migration.base.MigratorBuilder) Before(org.junit.Before)

Example 3 with MigratorBuilder

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());
}
Also used : XmlMigrator(ai.grakn.migration.xml.XmlMigrator) MigratorBuilder(ai.grakn.migration.base.MigratorBuilder) Migrator(ai.grakn.migration.base.Migrator) XmlMigrator(ai.grakn.migration.xml.XmlMigrator) File(java.io.File)

Aggregations

MigratorBuilder (ai.grakn.migration.base.MigratorBuilder)3 GraknTx (ai.grakn.GraknTx)1 Keyspace (ai.grakn.Keyspace)1 Entity (ai.grakn.concept.Entity)1 Migrator (ai.grakn.migration.base.Migrator)1 XmlMigrator (ai.grakn.migration.xml.XmlMigrator)1 MigratorTestUtils.getFileAsString (ai.grakn.test.migration.MigratorTestUtils.getFileAsString)1 File (java.io.File)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Before (org.junit.Before)1 Test (org.junit.Test)1