Search in sources :

Example 31 with ColumnType

use of com.google.api.ads.admanager.axis.v202205.ColumnType in project molgenis-emx2 by molgenis.

the class TestOpenApi method constructApi.

@Test
public void constructApi() throws IOException {
    SchemaMetadata schema = new SchemaMetadata("test");
    TableMetadata table = schema.create(TableMetadata.table("TypeTest"));
    for (ColumnType columnType : ColumnType.values()) {
        if (columnType.isReference()) {
        // TODO: outside of test for now
        } else {
            table.add(Column.column(columnType.toString().toLowerCase() + "Column").setType(columnType));
        }
    }
    TableMetadata personTable = schema.create(TableMetadata.table("Person").add(Column.column("First_Name")).add(Column.column("Last_Name")));
    OpenAPI api = OpenApiYamlGenerator.createOpenApi(schema);
    // useless test
    Assert.assertEquals(1, api.getComponents().getSchemas().size());
    // useless test
    Assert.assertEquals(1, api.getComponents().getSchemas().size());
    StringWriter writer = new StringWriter();
    Yaml.pretty().writeValue(writer, api);
    System.out.println(writer);
}
Also used : TableMetadata(org.molgenis.emx2.TableMetadata) ColumnType(org.molgenis.emx2.ColumnType) SchemaMetadata(org.molgenis.emx2.SchemaMetadata) StringWriter(java.io.StringWriter) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Test(org.junit.Test)

Example 32 with ColumnType

use of com.google.api.ads.admanager.axis.v202205.ColumnType in project molgenis-emx2 by molgenis.

the class TestGetSetAllTypesOnRows method addContents.

private void addContents(SchemaMetadata m, List<ColumnType> columnTypes) {
    TableMetadata t = m.create(table("TypeTest"));
    for (ColumnType columnType : columnTypes) {
        t.add(column("test" + columnType).setType(columnType).setRequired(true));
        t.add(column("test" + columnType + "_nullable").setType(columnType));
        t.add(column("test" + columnType + "_readonly").setType(columnType).setReadonly(true));
    }
}
Also used : ColumnType(org.molgenis.emx2.ColumnType)

Example 33 with ColumnType

use of com.google.api.ads.admanager.axis.v202205.ColumnType in project molgenis-emx2 by molgenis.

the class TestMapPojoToTable method testTypeTestToTable.

@Test
public void testTypeTestToTable() {
    TableMetadata table = Mapper.map(TypeTestBean.class);
    for (ColumnType columnType : new ColumnType[] { STRING, INT, DECIMAL, BOOL, DATE, DATETIME }) {
        String columnName = "a" + columnType.toString().substring(0, 1).toUpperCase() + columnType.toString().substring(1).toLowerCase();
        assertEquals(columnType, table.getColumn(columnName).getColumnType());
    }
}
Also used : ColumnType(org.molgenis.emx2.ColumnType) Test(org.junit.Test)

Example 34 with ColumnType

use of com.google.api.ads.admanager.axis.v202205.ColumnType in project molgenis-emx2 by molgenis.

the class RefAndRefArrayTestExample method createRefAndRefArrayTestExample.

public static void createRefAndRefArrayTestExample(SchemaMetadata schema) {
    ColumnType[] columnTypes = new ColumnType[] { UUID, STRING, BOOL, INT, DECIMAL, TEXT, DATE, DATETIME };
    for (ColumnType columnType : columnTypes) {
        String aTableName = columnType.toString() + "_A";
        String fieldName = "AKeyOf" + columnType;
        schema.create(table(aTableName).add(column(fieldName).setType(columnType).setPkey()));
        String bTableName = columnType.toString() + "_B";
        String refFromBToA = "RefToAKeyOf" + columnType;
        String refArrayFromBToA = "RefArrayToAKeyOf" + columnType;
        schema.create(table(bTableName).add(column(refFromBToA).setType(REF).setRefTable(aTableName)).add(column(refArrayFromBToA).setType(REF_ARRAY).setRefTable(aTableName)));
    }
}
Also used : ColumnType(org.molgenis.emx2.ColumnType)

Example 35 with ColumnType

use of com.google.api.ads.admanager.axis.v202205.ColumnType in project molgenis-emx2 by molgenis.

the class SimpleTypeTestExample method createSimpleTypeTest.

public static void createSimpleTypeTest(SchemaMetadata schema) {
    TableMetadata typeTestTable = table(TYPE_TEST).add(column("id").setPkey());
    ColumnType[] columnTypes = new ColumnType[] { UUID, STRING, BOOL, INT, LONG, DECIMAL, TEXT, DATE, DATETIME };
    for (ColumnType columnType : columnTypes) {
        typeTestTable.add(column("Test " + columnType.toString().toLowerCase()).setType(columnType).setRequired(true));
        typeTestTable.add(column("Test " + columnType.toString().toLowerCase() + " nillable").setType(columnType));
    }
    schema.create(typeTestTable);
}
Also used : TableMetadata(org.molgenis.emx2.TableMetadata) ColumnType(org.molgenis.emx2.ColumnType)

Aggregations

ColumnType (org.molgenis.emx2.ColumnType)11 Function (com.google.common.base.Function)10 Before (org.junit.Before)10 TableMetadata (org.molgenis.emx2.TableMetadata)5 ResultSet (com.google.api.ads.admanager.axis.v202205.ResultSet)4 Test (org.junit.Test)4 ColumnType (com.google.api.ads.admanager.axis.v202105.ColumnType)2 ColumnType (com.google.api.ads.admanager.axis.v202108.ColumnType)2 ColumnType (com.google.api.ads.admanager.axis.v202111.ColumnType)2 ColumnType (com.google.api.ads.admanager.axis.v202202.ColumnType)2 ColumnType (com.google.api.ads.admanager.axis.v202205.ColumnType)2 Row (com.google.api.ads.admanager.axis.v202205.Row)2 ColumnType (com.google.api.ads.admanager.jaxws.v202108.ColumnType)2 ColumnType (com.google.api.ads.admanager.jaxws.v202202.ColumnType)2 ColumnType (com.google.api.ads.admanager.jaxws.v202205.ColumnType)2 ArrayList (java.util.ArrayList)2 AdUnitTargeting (com.google.api.ads.admanager.axis.v202105.AdUnitTargeting)1 BooleanValue (com.google.api.ads.admanager.axis.v202105.BooleanValue)1 Date (com.google.api.ads.admanager.axis.v202105.Date)1 DateTime (com.google.api.ads.admanager.axis.v202105.DateTime)1