Search in sources :

Example 1 with EngineRuntime

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime in project legend-engine by finos.

the class ServiceTestGenerationHelper method hasModelChainConnection.

private static boolean hasModelChainConnection(Runtime runtime, PureModelContextData pureModelContextData) {
    EngineRuntime engineRuntime = resolveRuntime(runtime, pureModelContextData);
    List<StoreConnections> storeConnections = engineRuntime.connections;
    for (StoreConnections s : storeConnections) {
        List<IdentifiedConnection> identifiedConnection = s.storeConnections;
        for (IdentifiedConnection ic : identifiedConnection) {
            if (ic.connection instanceof ModelChainConnection || (("ModelStore").equals(s.store.path) && ic.connection instanceof ConnectionPointer)) {
                return true;
            }
        }
    }
    return false;
}
Also used : StoreConnections(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.StoreConnections) EngineRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime) ModelChainConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.connection.ModelChainConnection) IdentifiedConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.IdentifiedConnection) ConnectionPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.ConnectionPointer)

Example 2 with EngineRuntime

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime in project legend-engine by finos.

the class ServiceTestGenerationHelper method buildTestConnection.

private static StoreConnections buildTestConnection(StoreConnections storeConnections, Function<String, String> testDataAccessor, PureModelContextData pureModelContextData, EngineRuntime runtime, String mappingPath, PureModel pureModel, String testData) {
    StoreConnections newStoreConnections = new StoreConnections();
    newStoreConnections.store = storeConnections.store;
    newStoreConnections.storeConnections = ListIterate.collect(storeConnections.storeConnections, s -> newTestIdentifiedConnection(s, storeConnections, testDataAccessor, pureModelContextData, runtime, mappingPath, pureModel, testData));
    return newStoreConnections;
}
Also used : DatabaseType(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.DatabaseType) Runtime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.Runtime) MutableList(org.eclipse.collections.api.list.MutableList) ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) PackageableElementPointer(org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer) EngineRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime) MediaType(javax.ws.rs.core.MediaType) RichIterable(org.eclipse.collections.api.RichIterable) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData) PackageableConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection) Map(java.util.Map) Tuples(org.eclipse.collections.impl.tuple.Tuples) LegacyRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime) TypeReference(com.fasterxml.jackson.core.type.TypeReference) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) IdentifiedConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.IdentifiedConnection) StoreConnections(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.StoreConnections) ProcessingContext(org.finos.legend.engine.language.pure.compiler.toPureGraph.ProcessingContext) ServiceLoader(java.util.ServiceLoader) Iterate(org.eclipse.collections.impl.utility.Iterate) StandardCharsets(java.nio.charset.StandardCharsets) PackageableElementType(org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementType) RelationalDatabaseConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.RelationalDatabaseConnection) Base64(java.util.Base64) List(java.util.List) DatabaseConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.DatabaseConnection) Lists(org.eclipse.collections.impl.factory.Lists) SingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.SingleExecutionTest) CompileContext(org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext) Service(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Service) ObjectMapperFactory(org.finos.legend.engine.shared.core.ObjectMapperFactory) TestContainer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.TestContainer) Optional(java.util.Optional) XmlModelConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.connection.XmlModelConnection) PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) ModelChainConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.connection.ModelChainConnection) ProcessorContext(org.finos.legend.pure.runtime.java.compiled.generation.ProcessorContext) ExternalFormatConnection(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatConnection) UrlStreamExternalSource(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.UrlStreamExternalSource) Function(java.util.function.Function) ConnectionFactoryExtension(org.finos.legend.engine.protocol.pure.v1.extension.ConnectionFactoryExtension) HelperRuntimeBuilder(org.finos.legend.engine.language.pure.compiler.toPureGraph.HelperRuntimeBuilder) Pair(org.eclipse.collections.api.tuple.Pair) TestDatabaseAuthenticationStrategy(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.authentication.TestDatabaseAuthenticationStrategy) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JsonModelConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.connection.JsonModelConnection) ValueSpecificationBuilder(org.finos.legend.engine.language.pure.compiler.toPureGraph.ValueSpecificationBuilder) ListIterate(org.eclipse.collections.impl.utility.ListIterate) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) RuntimePointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.RuntimePointer) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) Connection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.Connection) LazyIterate(org.eclipse.collections.impl.utility.LazyIterate) PureSingleExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution) ConnectionPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.ConnectionPointer) LocalH2DatasourceSpecification(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.specification.LocalH2DatasourceSpecification) DataProtocolHandler(org.finos.legend.engine.shared.core.url.DataProtocolHandler) org.finos.legend.pure.generated.core_relational_relational_helperFunctions_helperFunctions(org.finos.legend.pure.generated.core_relational_relational_helperFunctions_helperFunctions) PackageableRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime) ValueSpecificationProcessor(org.finos.legend.pure.runtime.java.compiled.generation.processors.valuespecification.ValueSpecificationProcessor) StoreConnections(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.StoreConnections)

Example 3 with EngineRuntime

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime in project legend-engine by finos.

the class ServiceTestGenerationHelper method buildRelationalTestRuntime.

private static Runtime buildRelationalTestRuntime(Runtime runtime, String mappingPath, String testDataCsv, List<String> sql) {
    if (runtime instanceof LegacyRuntime) {
        LegacyRuntime newRuntime = new LegacyRuntime();
        newRuntime.connections = ListIterate.collect(((LegacyRuntime) runtime).connections, c -> newRelationalConnection(c, testDataCsv, sql));
        return newRuntime;
    }
    if (runtime instanceof EngineRuntime) {
        EngineRuntime testRuntime = new EngineRuntime();
        PackageableElementPointer mappingPointer = new PackageableElementPointer();
        mappingPointer.type = PackageableElementType.MAPPING;
        mappingPointer.path = mappingPath;
        testRuntime.mappings.add(mappingPointer);
        testRuntime.connections = ListIterate.collect(((EngineRuntime) runtime).connections, c -> "ModelStore".equals(c.store.path) ? c : newRelationalStoreConnections(c, testDataCsv, sql));
        return testRuntime;
    }
    if (runtime instanceof RuntimePointer) {
        return runtime;
    }
    throw new UnsupportedOperationException("Unsupported runtime type: " + runtime.getClass().getName());
}
Also used : DatabaseType(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.DatabaseType) Runtime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.Runtime) MutableList(org.eclipse.collections.api.list.MutableList) ProcessorSupport(org.finos.legend.pure.m3.navigation.ProcessorSupport) PackageableElementPointer(org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer) EngineRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime) MediaType(javax.ws.rs.core.MediaType) RichIterable(org.eclipse.collections.api.RichIterable) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData) PackageableConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.PackageableConnection) Map(java.util.Map) Tuples(org.eclipse.collections.impl.tuple.Tuples) LegacyRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime) TypeReference(com.fasterxml.jackson.core.type.TypeReference) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) IdentifiedConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.IdentifiedConnection) StoreConnections(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.StoreConnections) ProcessingContext(org.finos.legend.engine.language.pure.compiler.toPureGraph.ProcessingContext) ServiceLoader(java.util.ServiceLoader) Iterate(org.eclipse.collections.impl.utility.Iterate) StandardCharsets(java.nio.charset.StandardCharsets) PackageableElementType(org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementType) RelationalDatabaseConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.RelationalDatabaseConnection) Base64(java.util.Base64) List(java.util.List) DatabaseConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.DatabaseConnection) Lists(org.eclipse.collections.impl.factory.Lists) SingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.SingleExecutionTest) CompileContext(org.finos.legend.engine.language.pure.compiler.toPureGraph.CompileContext) Service(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Service) ObjectMapperFactory(org.finos.legend.engine.shared.core.ObjectMapperFactory) TestContainer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.TestContainer) Optional(java.util.Optional) XmlModelConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.connection.XmlModelConnection) PackageableElement(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement) ModelChainConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.connection.ModelChainConnection) ProcessorContext(org.finos.legend.pure.runtime.java.compiled.generation.ProcessorContext) ExternalFormatConnection(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.ExternalFormatConnection) UrlStreamExternalSource(org.finos.legend.engine.protocol.pure.v1.packageableElement.external.shared.UrlStreamExternalSource) Function(java.util.function.Function) ConnectionFactoryExtension(org.finos.legend.engine.protocol.pure.v1.extension.ConnectionFactoryExtension) HelperRuntimeBuilder(org.finos.legend.engine.language.pure.compiler.toPureGraph.HelperRuntimeBuilder) Pair(org.eclipse.collections.api.tuple.Pair) TestDatabaseAuthenticationStrategy(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.authentication.TestDatabaseAuthenticationStrategy) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JsonModelConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.connection.JsonModelConnection) ValueSpecificationBuilder(org.finos.legend.engine.language.pure.compiler.toPureGraph.ValueSpecificationBuilder) ListIterate(org.eclipse.collections.impl.utility.ListIterate) CoreInstance(org.finos.legend.pure.m4.coreinstance.CoreInstance) RuntimePointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.RuntimePointer) InstanceValue(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.valuespecification.InstanceValue) Connection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.Connection) LazyIterate(org.eclipse.collections.impl.utility.LazyIterate) PureSingleExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution) ConnectionPointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.ConnectionPointer) LocalH2DatasourceSpecification(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.specification.LocalH2DatasourceSpecification) DataProtocolHandler(org.finos.legend.engine.shared.core.url.DataProtocolHandler) org.finos.legend.pure.generated.core_relational_relational_helperFunctions_helperFunctions(org.finos.legend.pure.generated.core_relational_relational_helperFunctions_helperFunctions) PackageableRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime) ValueSpecificationProcessor(org.finos.legend.pure.runtime.java.compiled.generation.processors.valuespecification.ValueSpecificationProcessor) RuntimePointer(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.RuntimePointer) EngineRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime) PackageableElementPointer(org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer) LegacyRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime)

Example 4 with EngineRuntime

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime in project legend-engine by finos.

the class TestRuntimeGenerationForServiceTests method testRuntimeGenerationForModelChainConnection.

@Test
public void testRuntimeGenerationForModelChainConnection() {
    String pureGrammarWithModelChainConnection = "###Relational\n" + "Database demo::modelChainConnection::relationalDB\n" + "(\n" + "  Table Person\n" + "  (\n" + "    fullname VARCHAR(1000) PRIMARY KEY,\n" + "    firm VARCHAR(200)\n" + "  )\n" + ")\n" + "\n" + "\n" + "###Service\n" + "Service demo::modelChainConnection::testModelChainConnectionService\n" + "{\n" + "  pattern: '/maheha/testModelChainConnection/fromStudio/';\n" + "  owners:\n" + "  [\n" + "    'maheha'\n" + "  ];\n" + "  documentation: '';\n" + "  autoActivateUpdates: false;\n" + "  execution: Single\n" + "  {\n" + "    query: |demo::modelChainConnection::dest::Person.all()->project([f|$f.firstName, f|$f.lastName], ['firstName', 'lastName']);\n" + "    mapping: demo::modelChainConnection::simpleModelMappingWithAssociation;\n" + "    runtime:\n" + "    #{\n" + "      mappings:\n" + "      [\n" + "        demo::modelChainConnection::simpleModelMappingWithAssociation\n" + "      ];\n" + "      connections:\n" + "      [\n" + "        ModelStore:\n" + "        [\n" + "          connection_1: demo::modelChainConnection::modelChainConnection\n" + "        ],\n" + "        demo::modelChainConnection::relationalDB:\n" + "        [\n" + "          connection_2: demo::modelChainConnection::mySimpleConnection\n" + "        ]\n" + "      ];\n" + "    }#;\n" + "  }\n" + "  test: Single\n" + "  {\n" + "    data: 'default\\nPerson\\nfullname,firm\\nPierre DeBelen,A\\nA. Only One,A\\n\\n\\n\\n';\n" + "    asserts:\n" + "    [\n" + "    ];\n" + "  }\n" + "}\n" + "\n" + "\n" + "###Pure\n" + "Class demo::modelChainConnection::dest::Address\n" + "{\n" + "  street: String[0..1];\n" + "  extension: demo::modelChainConnection::dest::AddressExtension[0..1];\n" + "}\n" + "\n" + "Class demo::modelChainConnection::dest::AddressExtension\n" + "{\n" + "  stuff: String[1];\n" + "}\n" + "\n" + "Class demo::modelChainConnection::dest::Firm\n" + "{\n" + "  legalName: String[1];\n" + "  employees: demo::modelChainConnection::dest::Person[*];\n" + "  addresses: demo::modelChainConnection::dest::Address[*];\n" + "  count: Integer[1];\n" + "}\n" + "\n" + "Class demo::modelChainConnection::dest::Person\n" + "{\n" + "  firstName: String[1];\n" + "  lastName: String[1];\n" + "  addresses: demo::modelChainConnection::dest::Address[*];\n" + "  firm: demo::modelChainConnection::dest::Firm[0..1];\n" + "  description: String[0..1];\n" + "  type: String[0..1];\n" + "}\n" + "\n" + "Class demo::modelChainConnection::src::_Person\n" + "{\n" + "  fullName: String[1];\n" + "  addresses: demo::modelChainConnection::dest::Address[*];\n" + "}\n" + "\n" + "\n" + "###Mapping\n" + "Mapping demo::modelChainConnection::relationalMapping\n" + "(\n" + "  demo::modelChainConnection::src::_Person: Relational\n" + "  {\n" + "    ~primaryKey\n" + "    (\n" + "      [demo::modelChainConnection::relationalDB]Person.fullname\n" + "    )\n" + "    ~mainTable [demo::modelChainConnection::relationalDB]Person\n" + "    fullName: [demo::modelChainConnection::relationalDB]Person.fullname\n" + "  }\n" + ")\n" + "\n" + "Mapping demo::modelChainConnection::simpleModelMappingWithAssociation\n" + "(\n" + "  demo::modelChainConnection::dest::Person: Pure\n" + "  {\n" + "    ~src demo::modelChainConnection::src::_Person\n" + "    firstName: $src.fullName->substring(0, $src.fullName->indexOf(' ')),\n" + "    lastName: $src.fullName->substring($src.fullName->indexOf(' ') + 1, $src.fullName->length())\n" + "  }\n" + ")\n" + "\n" + "\n" + "###Connection\n" + "ModelChainConnection demo::modelChainConnection::modelChainConnection\n" + "{\n" + "  mappings: [\n" + "    demo::modelChainConnection::relationalMapping\n" + "  ];\n" + "}\n" + "\n" + "RelationalDatabaseConnection demo::modelChainConnection::mySimpleConnection\n" + "{\n" + "  store: demo::modelChainConnection::relationalDB;\n" + "  type: H2;\n" + "  specification: LocalH2\n" + "  {\n" + "    testDataSetupCSV: '';\n" + "  };\n" + "  auth: DefaultH2;\n" + "}\n" + "\n" + "\n" + "###Runtime\n" + "Runtime demo::modelChainConnection\n" + "{\n" + "  mappings:\n" + "  [\n" + "    demo::modelChainConnection::simpleModelMappingWithAssociation\n" + "  ];\n" + "  connections:\n" + "  [\n" + "    ModelStore:\n" + "    [\n" + "      connection_1: demo::modelChainConnection::modelChainConnection\n" + "    ],\n" + "    demo::modelChainConnection::relationalDB:\n" + "    [\n" + "      connection_2: demo::modelChainConnection::mySimpleConnection\n" + "    ]\n" + "  ];\n" + "}\n";
    PureModelContextData contextData = PureGrammarParser.newInstance().parseModel(pureGrammarWithModelChainConnection);
    PureModel pureModel = new PureModel(contextData, null, DeploymentMode.TEST);
    Service service = contextData.getElementsOfType(Service.class).get(0);
    EngineRuntime testRuntime = (EngineRuntime) ServiceTestGenerationHelper.buildSingleExecutionTestRuntime((PureSingleExecution) service.execution, (SingleExecutionTest) service.test, contextData, pureModel);
    Assert.assertEquals(testRuntime.connections.size(), 2);
    Assert.assertNotNull(testRuntime.getStoreConnections("ModelStore"));
    Assert.assertEquals(testRuntime.getStoreConnections("ModelStore").storeConnections.size(), 1);
    Assert.assertFalse((testRuntime.getStoreConnections("ModelStore").storeConnections.get(0).connection instanceof RelationalDatabaseConnection));
}
Also used : PureSingleExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution) SingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.SingleExecutionTest) RelationalDatabaseConnection(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.RelationalDatabaseConnection) EngineRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime) Service(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Service) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData) SingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.SingleExecutionTest) Test(org.junit.Test)

Example 5 with EngineRuntime

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime in project legend-engine by finos.

the class TestRuntimeGenerationForServiceTests method testRuntimeGenerationForServiceWithRuntimePointer.

@Test
public void testRuntimeGenerationForServiceWithRuntimePointer() {
    String pureGrammarWithModelChainConnection = "###Relational\n" + "Database test::relationalDB\n" + "(\n" + "  Table Person\n" + "  (\n" + "    fullname VARCHAR(1000) PRIMARY KEY\n" + "  )\n" + ")\n" + "\n" + "\n" + "###Service\n" + "Service test::serviceWithRuntimePointer\n" + "{\n" + "  pattern: '/garprat/test/fromStudio/';\n" + "  owners:\n" + "  [\n" + "    'garprat'\n" + "  ];\n" + "  documentation: '';\n" + "  autoActivateUpdates: false;\n" + "  execution: Single\n" + "  {\n" + "    query: |test::Person.all()->project([f|$f.fullName], ['fullName']);\n" + "    mapping: test::relationalMapping;\n" + "    runtime: test::runtimePointer;\n" + "  }\n" + "  test: Single\n" + "  {\n" + "    data: 'default\\nPerson\\nfullname\\nPierre DeBelen\\n';\n" + "    asserts:\n" + "    [\n" + "    ];\n" + "  }\n" + "}\n" + "\n" + "\n" + "###Pure\n" + "Class test::Person\n" + "{\n" + "  fullName: String[1];\n" + "}\n" + "\n" + "\n" + "###Mapping\n" + "Mapping test::relationalMapping\n" + "(\n" + "  test::Person: Relational\n" + "  {\n" + "    ~primaryKey\n" + "    (\n" + "      [test::relationalDB]Person.fullname\n" + "    )\n" + "    ~mainTable [test::relationalDB]Person\n" + "    fullName: [test::relationalDB]Person.fullname\n" + "  }\n" + ")\n" + "\n" + "###Connection\n" + "RelationalDatabaseConnection test::mySimpleConnection\n" + "{\n" + "  store: test::relationalDB;\n" + "  type: MemSQL;\n" + "  specification: Static\n" + "  {\n" + "    name: 'memsql_person_data';\n" + "    host: 'myserver_url';\n" + "    port: 80;\n" + "  };\n" + "  auth: DefaultH2;\n" + "}\n" + "\n" + "\n" + "###Runtime\n" + "Runtime test::runtimePointer\n" + "{\n" + "  mappings:\n" + "  [\n" + "     test::relationalMapping\n" + "  ];\n" + "  connections:\n" + "  [\n" + "    test::relationalDB:\n" + "    [\n" + "      connection_1: test::mySimpleConnection\n" + "    ]\n" + "  ];\n" + "}\n";
    PureModelContextData contextData = PureGrammarParser.newInstance().parseModel(pureGrammarWithModelChainConnection);
    PureModel pureModel = new PureModel(contextData, null, DeploymentMode.TEST);
    Service service = contextData.getElementsOfType(Service.class).get(0);
    EngineRuntime testRuntime = (EngineRuntime) ServiceTestGenerationHelper.buildSingleExecutionTestRuntime((PureSingleExecution) service.execution, (SingleExecutionTest) service.test, contextData, pureModel);
    Assert.assertEquals(testRuntime.connections.size(), 1);
}
Also used : PureSingleExecution(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution) SingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.SingleExecutionTest) EngineRuntime(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime) Service(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.Service) PureModel(org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel) PureModelContextData(org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData) SingleExecutionTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.SingleExecutionTest) Test(org.junit.Test)

Aggregations

EngineRuntime (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.EngineRuntime)13 IdentifiedConnection (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.IdentifiedConnection)9 PackageableElementPointer (org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer)8 ConnectionPointer (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.ConnectionPointer)8 StoreConnections (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.StoreConnections)8 ListIterate (org.eclipse.collections.impl.utility.ListIterate)7 LegacyRuntime (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.LegacyRuntime)7 RuntimePointer (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.RuntimePointer)7 PackageableElement (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement)6 PackageableRuntime (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.PackageableRuntime)6 ModelChainConnection (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.modelToModel.connection.ModelChainConnection)6 List (java.util.List)5 PackageableElementType (org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementType)5 Connection (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.connection.Connection)5 Runtime (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.runtime.Runtime)5 RelationalDatabaseConnection (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.RelationalDatabaseConnection)5 RichIterable (org.eclipse.collections.api.RichIterable)4 PureModel (org.finos.legend.engine.language.pure.compiler.toPureGraph.PureModel)4 PureModelContextData (org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData)4 PureSingleExecution (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.PureSingleExecution)4