use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.KeyedExecutionParameter in project legend-engine by finos.
the class ServiceTestRunner method executeTests.
public List<RichServiceTestResult> executeTests() throws IOException, JavaCompileException {
Execution serviceExecution = this.service.execution;
if (serviceExecution instanceof PureMultiExecution) {
List<RichServiceTestResult> results = Lists.mutable.empty();
try (Scope scope = GlobalTracer.get().buildSpan("Generate Tests And Run For MultiExecution Service").startActive(true)) {
MutableMap<String, KeyedExecutionParameter> executionsByKey = Iterate.groupByUniqueKey(((PureMultiExecution) serviceExecution).executionParameters, e -> e.key);
for (KeyedSingleExecutionTest es : ((MultiExecutionTest) service.test).tests) {
List<TestContainer> asserts = es.asserts;
KeyedExecutionParameter e = executionsByKey.get(es.key);
PureMultiExecution pureExecution = (PureMultiExecution) service.execution;
PureSingleExecution pureSingleExecution = new PureSingleExecution();
pureSingleExecution.func = pureExecution.func;
pureSingleExecution.mapping = e.mapping;
pureSingleExecution.runtime = e.runtime;
pureSingleExecution.executionOptions = e.executionOptions;
String noAssertMessage = "No test assert found for key - " + es.key + "!!";
RichServiceTestResult richServiceTestResult = executeSingleExecutionTest(pureSingleExecution, es.data, asserts, noAssertMessage, pureModelContextData, pureModel, scope);
richServiceTestResult.setOptionalMultiExecutionKey(es.key);
results.add(richServiceTestResult);
}
return results;
}
} else if (serviceExecution instanceof PureSingleExecution) {
try (Scope scope = GlobalTracer.get().buildSpan("Generate Single Pure Tests And Run").startActive(true)) {
List<TestContainer> asserts = ((SingleExecutionTest) service.test).asserts;
String noAssertMessage = "No test assert found !!";
return Collections.singletonList(executeSingleExecutionTest((PureSingleExecution) service.execution, ((SingleExecutionTest) service.test).data, asserts, noAssertMessage, pureModelContextData, pureModel, scope));
}
} else {
try (Scope scope = GlobalTracer.get().buildSpan("Generate Extra Service Execution Tests and Run").startActive(true)) {
MutableList<ServiceExecutionExtension> serviceExecutionExtensions = Lists.mutable.withAll(ServiceLoader.load(ServiceExecutionExtension.class));
Pair<ExecutionPlan, RichIterable<? extends String>> testExecutor = getExtraServiceExecutionPlan(serviceExecutionExtensions, serviceExecution, ((Root_meta_legend_service_metamodel_SingleExecutionTest) this.pureService._test())._data());
ExecutionPlan executionPlan = testExecutor.getOne();
Assert.assertTrue(executionPlan instanceof SingleExecutionPlan, () -> "Only Single Execution Plan supported");
List<TestContainer> containers = getExtraServiceTestContainers(serviceExecutionExtensions, service.test);
return Collections.singletonList(executeTestAsserts((SingleExecutionPlan) executionPlan, containers, testExecutor.getTwo(), scope));
}
}
}
use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.service.KeyedExecutionParameter in project legend-engine by finos.
the class ServiceParseTreeWalker method visitKeyedExecutionParameter.
private KeyedExecutionParameter visitKeyedExecutionParameter(ServiceParserGrammar.ExecParameterContext ctx) {
KeyedExecutionParameter keyedExecutionParameter = new KeyedExecutionParameter();
keyedExecutionParameter.sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
// execution key value
keyedExecutionParameter.key = PureGrammarParserUtility.fromGrammarString(ctx.execParameterSignature().STRING().getText(), true);
// mapping
ServiceParserGrammar.ServiceMappingContext mappingContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.serviceMapping(), "mapping", keyedExecutionParameter.sourceInformation);
keyedExecutionParameter.mapping = PureGrammarParserUtility.fromQualifiedName(mappingContext.qualifiedName().packagePath() == null ? Collections.emptyList() : mappingContext.qualifiedName().packagePath().identifier(), mappingContext.qualifiedName().identifier());
keyedExecutionParameter.mappingSourceInformation = walkerSourceInformation.getSourceInformation(mappingContext.qualifiedName());
// runtime
ServiceParserGrammar.ServiceRuntimeContext runtimeContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.serviceRuntime(), "runtime", keyedExecutionParameter.sourceInformation);
keyedExecutionParameter.runtime = this.visitRuntime(runtimeContext);
return keyedExecutionParameter;
}
Aggregations