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"));
}
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations