Search in sources :

Example 16 with Database

use of org.molgenis.emx2.Database in project molgenis-emx2 by molgenis.

the class TestMetaDataIsStoredForNextSessions method testArrayTypesTest.

@Test
public void testArrayTypesTest() {
    Schema schema = database.dropCreateSchema(SCHEMA_NAME + "3");
    ArrayTypeTestExample.createSimpleTypeTest(schema.getMetadata());
    try {
        CompareTools.reloadAndCompare(database, schema);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : Schema(org.molgenis.emx2.Schema) Test(org.junit.Test)

Example 17 with Database

use of org.molgenis.emx2.Database in project molgenis-emx2 by molgenis.

the class TestMetaDataIsStoredForNextSessions method testProductComponentsPartsModel.

@Test
public void testProductComponentsPartsModel() {
    Schema schema = database.dropCreateSchema(SCHEMA_NAME + "1");
    ProductComponentPartsExample.create(schema.getMetadata());
    try {
        CompareTools.reloadAndCompare(database, schema);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : Schema(org.molgenis.emx2.Schema) Test(org.junit.Test)

Example 18 with Database

use of org.molgenis.emx2.Database in project molgenis-emx2 by molgenis.

the class TestMetaDataIsStoredForNextSessions method testSimpleTypesTest.

@Test
public void testSimpleTypesTest() {
    Schema schema = database.dropCreateSchema(SCHEMA_NAME + "2");
    SimpleTypeTestExample.createSimpleTypeTest(schema.getMetadata());
    try {
        CompareTools.reloadAndCompare(database, schema);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : Schema(org.molgenis.emx2.Schema) Test(org.junit.Test)

Example 19 with Database

use of org.molgenis.emx2.Database in project molgenis-emx2 by molgenis.

the class TestSettingsAndMembersLoading method testExcelTypesCast.

@Test
public void testExcelTypesCast() {
    Database database = TestDatabaseFactory.getTestDatabase();
    Schema schema = database.dropCreateSchema(TestSettingsAndMembersLoading.class.getSimpleName());
    ClassLoader classLoader = getClass().getClassLoader();
    Path path = new File(classLoader.getResource("settings_and_members.xlsx").getFile()).toPath();
    new ImportExcelTask(path, schema, true).run();
    assertEquals("key1", schema.getTable("table1").getMetadata().getSettings().get(0).key());
    assertEquals("value1", schema.getTable("table1").getMetadata().getSettings().get(0).value());
    assertEquals("key2", schema.getMetadata().getSettings().get(0).key());
    assertEquals("value2", schema.getMetadata().getSettings().get(0).value());
    assertEquals(1, schema.getMembers().size());
    assertEquals("anonymous", schema.getMembers().get(0).getUser());
    assertEquals("Viewer", schema.getMembers().get(0).getRole());
    database.dropSchema(schema.getName());
}
Also used : Path(java.nio.file.Path) Schema(org.molgenis.emx2.Schema) Database(org.molgenis.emx2.Database) File(java.io.File) Test(org.junit.Test)

Example 20 with Database

use of org.molgenis.emx2.Database in project molgenis-emx2 by molgenis.

the class RunMolgenisEmx2 method main.

public static void main(String[] args) {
    logger.info("Starting MOLGENIS EMX2 Software Version=" + Version.getVersion());
    Integer port = (Integer) EnvironmentProperty.getParameter(Constants.MOLGENIS_HTTP_PORT, "8080", INT);
    logger.info("with " + org.molgenis.emx2.Constants.MOLGENIS_HTTP_PORT + "=" + port + " (change either via java properties or via ENV variables)");
    // setup database
    Database db = new SqlDatabase(true);
    if (db.getSchema("pet store") == null) {
        Schema schema = db.createSchema("pet store");
        PetStoreExample.create(schema.getMetadata());
        PetStoreExample.populate(schema);
    }
    // start
    MolgenisWebservice.start(port);
}
Also used : SqlDatabase(org.molgenis.emx2.sql.SqlDatabase) SqlDatabase(org.molgenis.emx2.sql.SqlDatabase)

Aggregations

Test (org.junit.Test)24 Database (com.google.spanner.admin.database.v1.Database)21 Database (org.molgenis.emx2.Database)12 AbstractMessage (com.google.protobuf.AbstractMessage)10 ArrayList (java.util.ArrayList)10 Schema (org.molgenis.emx2.Schema)9 ByteString (com.google.protobuf.ByteString)8 Operation (com.google.longrunning.Operation)7 RestoreDatabaseRequest (com.google.spanner.admin.database.v1.RestoreDatabaseRequest)7 BeforeClass (org.junit.BeforeClass)7 CreateDatabaseRequest (com.google.spanner.admin.database.v1.CreateDatabaseRequest)4 InstanceName (com.google.spanner.admin.database.v1.InstanceName)4 ListDatabasesPagedResponse (com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabasesPagedResponse)3 CreateDatabaseMetadata (com.google.spanner.admin.database.v1.CreateDatabaseMetadata)3 RestoreDatabaseMetadata (com.google.spanner.admin.database.v1.RestoreDatabaseMetadata)3 MetadataUtils.deleteColumn (org.molgenis.emx2.sql.MetadataUtils.deleteColumn)3 BackupName (com.google.spanner.admin.database.v1.BackupName)2 DatabaseName (com.google.spanner.admin.database.v1.DatabaseName)2 GetDatabaseRequest (com.google.spanner.admin.database.v1.GetDatabaseRequest)2 ListDatabasesRequest (com.google.spanner.admin.database.v1.ListDatabasesRequest)2