Search in sources :

Example 91 with Schema

use of com.google.pubsub.v1.Schema in project molgenis-emx2 by molgenis.

the class TestTransaction method testTransaction.

@Test
public void testTransaction() {
    Schema s = db.dropCreateSchema("testTransaction");
    // as long as from same db instance you can use resources in multiple Tx
    try {
        db.tx(db -> {
            Schema s2 = db.getSchema("testTransaction");
            s2.create(table("a"));
            s2.create(table("b"));
            throw new RuntimeException("transaction stopped to check if it rolled back");
        });
    } catch (Exception e) {
        System.out.println(e);
        assertNull(s.getTable("a"));
    }
}
Also used : Schema(org.molgenis.emx2.Schema) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 92 with Schema

use of com.google.pubsub.v1.Schema in project molgenis-emx2 by molgenis.

the class TestImportExportEmx2MetadataIODataAndMetadata method test.

@Test
public void test() throws IOException {
    Path tmp = Files.createTempDirectory(null);
    try {
        StopWatch.start("export and then import again test");
        Path directory = tmp.resolve("test");
        Files.createDirectories(directory);
        Schema schema1 = database.dropCreateSchema(getClass().getSimpleName() + "1");
        StopWatch.print("schema1 created, ready to load the example data");
        ProductComponentPartsExample.create(schema1.getMetadata());
        ProductComponentPartsExample.populate(schema1);
        StopWatch.print("example schema loaded");
        MolgenisIO.toDirectory(directory, schema1);
        StopWatch.print("export to directory complete");
        Schema schema2 = database.dropCreateSchema(getClass().getSimpleName() + "2");
        StopWatch.print("schema2 created, ready to reload the exported data");
        MolgenisIO.fromDirectory(directory, schema2, true);
        StopWatch.print("import from directory complete");
        CompareTools.assertEquals(schema1.getMetadata(), schema2.getMetadata());
        Path excelFile = tmp.resolve("test.xlsx");
        MolgenisIO.toExcelFile(excelFile, schema1);
        StopWatch.print("export to excel complete");
        Schema schema3 = database.dropCreateSchema(getClass().getSimpleName() + "3");
        StopWatch.print("schema3 created, ready to reload the exported data");
        MolgenisIO.importFromExcelFile(excelFile, schema3, true);
        StopWatch.print("import from excel complete");
        CompareTools.assertEquals(schema1.getMetadata(), schema3.getMetadata());
        Path zipFile = tmp.resolve("test.zip");
        MolgenisIO.toZipFile(zipFile, schema1);
        StopWatch.print("export to zipfile complete");
        Schema schema4 = database.dropCreateSchema(getClass().getSimpleName() + "4");
        StopWatch.print("schema4 created, ready to reload the exported data");
        MolgenisIO.fromZipFile(zipFile, schema4, true);
        StopWatch.print("import from zipfile complete");
        CompareTools.assertEquals(schema1.getMetadata(), schema4.getMetadata());
        StopWatch.print("schema comparison: all equal");
    } finally {
        Files.walk(tmp).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
    }
}
Also used : Path(java.nio.file.Path) Schema(org.molgenis.emx2.Schema) File(java.io.File) Test(org.junit.Test)

Example 93 with Schema

use of com.google.pubsub.v1.Schema in project molgenis-emx2 by molgenis.

the class TestLegacyImport method testLegacyImportDirectory.

@Test
public void testLegacyImportDirectory() {
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("bbmri-nl-complete").getFile());
    TableStoreForCsvFilesDirectory store = new TableStoreForCsvFilesDirectory(file.toPath(), ',');
    Schema schema = db.dropCreateSchema("testImportLegacyFormatDirectory");
    executeTest(store, schema);
}
Also used : Schema(org.molgenis.emx2.Schema) TableStoreForCsvFilesDirectory(org.molgenis.emx2.io.tablestore.TableStoreForCsvFilesDirectory) File(java.io.File) TableStoreForCsvInZipFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvInZipFile) Test(org.junit.Test)

Example 94 with Schema

use of com.google.pubsub.v1.Schema in project molgenis-emx2 by molgenis.

the class TestLegacyImport method testLegacyImportZip.

@Test
public void testLegacyImportZip() {
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("bbmri-nl-complete.zip").getFile());
    TableStore store = new TableStoreForCsvInZipFile(file.toPath());
    Schema schema = db.dropCreateSchema("testImportLegacyFormatZip");
    executeTest(store, schema);
}
Also used : Schema(org.molgenis.emx2.Schema) File(java.io.File) TableStoreForCsvInZipFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvInZipFile) TableStoreForCsvInZipFile(org.molgenis.emx2.io.tablestore.TableStoreForCsvInZipFile) TableStore(org.molgenis.emx2.io.tablestore.TableStore) Test(org.junit.Test)

Example 95 with Schema

use of com.google.pubsub.v1.Schema in project molgenis-emx2 by molgenis.

the class TestGraphQLCompositeKeys method setup.

// need ref
// need mref
// need ref_array
@BeforeClass
public static void setup() {
    database = TestDatabaseFactory.getTestDatabase();
    Schema schema = database.dropCreateSchema(schemaName);
    grapql = new GraphqlApiFactory().createGraphqlForSchema(schema);
}
Also used : Schema(org.molgenis.emx2.Schema) BeforeClass(org.junit.BeforeClass)

Aggregations

Test (org.junit.Test)65 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 ByteString (com.google.protobuf.ByteString)19 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)18 AbstractMessage (com.google.protobuf.AbstractMessage)18 QName (javax.xml.namespace.QName)16 SchemaName (com.google.pubsub.v1.SchemaName)15 File (java.io.File)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 ProjectName (com.google.pubsub.v1.ProjectName)14 IOException (java.io.IOException)14 URL (java.net.URL)14 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)14 StringWriter (java.io.StringWriter)13 Schema (org.oasisopen.odata.csdl.v4.Schema)13 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)12 StatusRuntimeException (io.grpc.StatusRuntimeException)12 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 JAXBElement (javax.xml.bind.JAXBElement)10