Search in sources :

Example 81 with Schema

use of com.google.cloud.datacatalog.v1beta1.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 82 with Schema

use of com.google.cloud.datacatalog.v1beta1.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 83 with Schema

use of com.google.cloud.datacatalog.v1beta1.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 84 with Schema

use of com.google.cloud.datacatalog.v1beta1.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 85 with Schema

use of com.google.cloud.datacatalog.v1beta1.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)57 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 AbstractMessage (com.google.protobuf.AbstractMessage)16 ByteString (com.google.protobuf.ByteString)16 QName (javax.xml.namespace.QName)16 File (java.io.File)15 IOException (java.io.IOException)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)14 ProjectName (com.google.pubsub.v1.ProjectName)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 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 ArrayList (java.util.ArrayList)10 JAXBElement (javax.xml.bind.JAXBElement)10 HashMap (java.util.HashMap)9 List (java.util.List)9