Skip to content
Snippets Groups Projects
Commit 4169bbc1 authored by Reiner Jung's avatar Reiner Jung
Browse files

Started adding test.

parent 4c15b588
No related branches found
No related tags found
1 merge request!84Added new new selector with different color selection scheme.
......@@ -16,6 +16,8 @@ dependencies {
implementation 'org.yaml:snakeyaml:2.0'
implementation 'org.csveed:csveed:0.7.4'
testImplementation 'org.hamcrest:hamcrest-core:2.2'
}
java {
......
/***************************************************************************
* Copyright (C) 2023 OceanDSL (https://oceandsl.uni-kiel.de)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package org.oceandsl.analysis.architecture;
import kieker.analysis.architecture.repository.ModelRepository;
import kieker.model.analysismodel.assembly.AssemblyComponent;
import kieker.model.analysismodel.assembly.AssemblyFactory;
import kieker.model.analysismodel.assembly.AssemblyModel;
import kieker.model.analysismodel.assembly.AssemblyPackage;
import kieker.model.analysismodel.deployment.DeploymentModel;
import kieker.model.analysismodel.type.ComponentType;
import kieker.model.analysismodel.type.OperationType;
import kieker.model.analysismodel.type.TypeFactory;
import kieker.model.analysismodel.type.TypeModel;
import kieker.model.analysismodel.type.TypePackage;
/**
* @author Reiner Jung
* @since 1.3.0
*
*/
public final class BasicArchitectureModelUtils {
public static final String COMPONENT_A = "A";
public static final String COMPONENT_B = "B";
public static final String OPERATION_A_A = "a()";
public static final String OPERATION_B_A = "b()";
public static final String BASE = "base";
private BasicArchitectureModelUtils() {
// do not instantiate
}
public static ModelRepository createMinimalModelRepository() {
final ModelRepository repository = ArchitectureModelRepositoryFactory.createEmptyModelRepository("test");
final TypeModel typeModel = createTypeModel(repository);
final AssemblyModel assemblyModel = createAssemblyModel(repository, typeModel);
final DeploymentModel deploymentModel = createDeploymentModel(repository, assemblyModel, typeModel);
return repository;
}
private static TypeModel createTypeModel(final ModelRepository repository) {
final TypeModel typeModel = repository.getModel(TypePackage.Literals.TYPE_MODEL);
final ComponentType componentA = createComponent(COMPONENT_A);
createOperation(componentA, OPERATION_A_A);
final ComponentType componentB = createComponent(COMPONENT_B);
createOperation(componentB, OPERATION_B_A);
typeModel.getComponentTypes().put(COMPONENT_A, componentA);
typeModel.getComponentTypes().put(COMPONENT_B, componentB);
return typeModel;
}
private static void createOperation(final ComponentType component, final String operation) {
final OperationType operationType = TypeFactory.eINSTANCE.createOperationType();
operationType.setName(operation);
operationType.setReturnType("int");
operationType.setSignature("int " + operation);
component.getProvidedOperations().put(operation, operationType);
}
private static ComponentType createComponent(final String component) {
final ComponentType componentType = TypeFactory.eINSTANCE.createComponentType();
componentType.setName(component);
componentType.setPackage(BASE);
return componentType;
}
private static AssemblyModel createAssemblyModel(final ModelRepository repository, final TypeModel typeModel) {
final AssemblyModel assemblyModel = repository.getModel(AssemblyPackage.Literals.ASSEMBLY_MODEL);
final AssemblyComponent componentA = AssemblyFactory.eINSTANCE.createAssemblyComponent();
componentA.setComponentType(typeModel.getComponentTypes().get(COMPONENT_A));
assemblyModel.getComponents().put(COMPONENT_A, componentA);
final AssemblyComponent componentB = AssemblyFactory.eINSTANCE.createAssemblyComponent();
componentB.setComponentType(typeModel.getComponentTypes().get(COMPONENT_B));
assemblyModel.getComponents().put(COMPONENT_B, componentB);
return assemblyModel;
}
}
......@@ -15,14 +15,52 @@
***************************************************************************/
package org.oceandsl.analysis.architecture.stages;
import org.junit.jupiter.api.Assertions;
import static org.hamcrest.MatcherAssert.assertThat;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import org.junit.jupiter.api.Test;
import kieker.analysis.architecture.recovery.events.DeployedOperationCallEvent;
import kieker.analysis.architecture.repository.ModelRepository;
import kieker.model.analysismodel.deployment.DeployedOperation;
import kieker.model.analysismodel.deployment.DeploymentPackage;
import kieker.model.analysismodel.execution.ExecutionFactory;
import kieker.model.analysismodel.execution.ExecutionModel;
import kieker.model.analysismodel.execution.ExecutionPackage;
import kieker.model.analysismodel.execution.Tuple;
import kieker.model.analysismodel.statistics.StatisticsModel;
import kieker.model.analysismodel.statistics.StatisticsPackage;
import teetime.framework.test.StageTester;
import org.oceandsl.analysis.architecture.BasicArchitectureModelUtils;
/**
*
* @author Reiner Jung
* @since 1.3.0
*/
class CountUniqueCallsStageTest {
@Test
public void test() {
Assertions.fail("Not yet implemented");
final ModelRepository repository = BasicArchitectureModelUtils.createMinimalModelRepository();
final StatisticsModel statisticsModel = repository.getModel(StatisticsPackage.Literals.STATISTICS_MODEL);
final ExecutionModel executionModel = repository.getModel(ExecutionPackage.Literals.EXECUTION_MODEL);
final ExecutionModel deployedModel = repository.getModel(DeploymentPackage.Literals.DEPLOYMENT_MODEL);
final CountUniqueCallsStage stage = new CountUniqueCallsStage(statisticsModel, executionModel);
final Duration duration = Duration.of(10, ChronoUnit.SECONDS);
final Tuple<DeployedOperation, DeployedOperation> tuple = ExecutionFactory.eINSTANCE.createTuple();
final DeployedOperationCallEvent event = new DeployedOperationCallEvent(tuple, duration);
StageTester.test(stage).send(event).to(stage.getInputPort()).start();
assertThat(stage.getOutputPort(), StageTester.produces(event));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment