use of org.palladiosimulator.pcm.usagemodel.UsageScenario in project iobserve-analysis by research-iobserve.
the class UsageModelProviderTest method createThenReadContaining.
@Override
@Test
public void createThenReadContaining() {
final ModelProvider<UsageModel> modelProvider = new ModelProvider<>(UsageModelProviderTest.graph);
final UsageModel writtenModel = new TestModelBuilder().getUsageModel();
final UsageScenario writtenScenario = writtenModel.getUsageScenario_UsageModel().get(0);
final UsageModel readModel;
modelProvider.createComponent(writtenModel);
readModel = (UsageModel) modelProvider.readOnlyContainingComponentById(UsageScenario.class, writtenScenario.getId());
Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
use of org.palladiosimulator.pcm.usagemodel.UsageScenario in project iobserve-analysis by research-iobserve.
the class UsageModelProviderTest method createThenUpdateThenReadUpdated.
@Override
@Test
public void createThenUpdateThenReadUpdated() {
final ModelProvider<UsageModel> modelProvider = new ModelProvider<>(UsageModelProviderTest.graph);
final TestModelBuilder testModelBuilder = new TestModelBuilder();
final UsageModel writtenModel = testModelBuilder.getUsageModel();
final UsageModel readModel;
final UsageScenario writtenUsageScenarioGroup0 = testModelBuilder.getUsageScenarioGroup0();
final ScenarioBehaviour writtenBuyBookScenarioBehaviour = testModelBuilder.getBuyBookScenarioBehaviour();
final EntryLevelSystemCall writtenGetQueryCall = testModelBuilder.getGetQueryCall();
final EntryLevelSystemCall writtenGetPriceCall = testModelBuilder.getGetPriceCall();
modelProvider.createComponent(writtenModel);
// Update the model by adding a loop for choosing several books
final Loop shoppingLoop = UsagemodelFactory.eINSTANCE.createLoop();
final PCMRandomVariable loopIteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
final ScenarioBehaviour chooseBookBehaviour = UsagemodelFactory.eINSTANCE.createScenarioBehaviour();
chooseBookBehaviour.setEntityName("Choose a book");
chooseBookBehaviour.getActions_ScenarioBehaviour().add(writtenGetQueryCall);
chooseBookBehaviour.getActions_ScenarioBehaviour().add(writtenGetPriceCall);
writtenUsageScenarioGroup0.setEntityName("Updated " + writtenUsageScenarioGroup0.getEntityName());
writtenBuyBookScenarioBehaviour.getActions_ScenarioBehaviour().remove(writtenGetQueryCall);
writtenBuyBookScenarioBehaviour.getActions_ScenarioBehaviour().remove(writtenGetPriceCall);
writtenBuyBookScenarioBehaviour.getActions_ScenarioBehaviour().add(shoppingLoop);
writtenGetQueryCall.setScenarioBehaviour_AbstractUserAction(chooseBookBehaviour);
writtenGetPriceCall.setScenarioBehaviour_AbstractUserAction(chooseBookBehaviour);
shoppingLoop.setEntityName("Shopping loop");
shoppingLoop.setScenarioBehaviour_AbstractUserAction(writtenBuyBookScenarioBehaviour);
shoppingLoop.setBodyBehaviour_Loop(chooseBookBehaviour);
shoppingLoop.setLoopIteration_Loop(loopIteration);
loopIteration.setLoop_LoopIteration(shoppingLoop);
loopIteration.setSpecification("2");
modelProvider.updateComponent(UsageModel.class, writtenModel);
readModel = modelProvider.readOnlyRootComponent(UsageModel.class);
Assert.assertTrue(this.equalityHelper.equals(writtenModel, readModel));
}
use of org.palladiosimulator.pcm.usagemodel.UsageScenario in project iobserve-analysis by research-iobserve.
the class UsageModelProviderTest method createThenDeleteComponent.
@Override
@Test
public void createThenDeleteComponent() {
final ModelProvider<UsageModel> modelProvider = new ModelProvider<>(UsageModelProviderTest.graph);
final UsageModel writtenModel = new TestModelBuilder().getUsageModel();
final UsageScenario writtenScenario = writtenModel.getUsageScenario_UsageModel().get(0);
modelProvider.createComponent(writtenModel);
Assert.assertFalse(IModelProviderTest.isGraphEmpty(modelProvider));
new ModelProvider<UsageScenario>(UsageModelProviderTest.graph).deleteComponent(UsageScenario.class, writtenScenario.getId());
// contained anywhere) and the proxy nodes (as they are no containments in this graph)
try (Transaction tx = UsageModelProviderTest.graph.getGraphDatabaseService().beginTx()) {
UsageModelProviderTest.graph.getGraphDatabaseService().execute("MATCH (m:UsageModel), (n:DoubleLiteral), (o:OperationSignature), (p:OperationProvidedRole) DELETE n, m, o, p");
tx.success();
}
Assert.assertTrue(IModelProviderTest.isGraphEmpty(modelProvider));
}
use of org.palladiosimulator.pcm.usagemodel.UsageScenario in project iobserve-analysis by research-iobserve.
the class UsageModelProviderTest method createThenDeleteComponentAndDatatypes.
@Override
@Test
public void createThenDeleteComponentAndDatatypes() {
final ModelProvider<UsageModel> modelProvider = new ModelProvider<>(UsageModelProviderTest.graph);
final UsageModel writtenModel = new TestModelBuilder().getUsageModel();
final UsageScenario writtenScenario = writtenModel.getUsageScenario_UsageModel().get(0);
modelProvider.createComponent(writtenModel);
Assert.assertFalse(IModelProviderTest.isGraphEmpty(modelProvider));
new ModelProvider<UsageScenario>(UsageModelProviderTest.graph).deleteComponentAndDatatypes(UsageScenario.class, writtenScenario.getId(), true);
Assert.assertTrue(IModelProviderTest.isGraphEmpty(modelProvider));
}
use of org.palladiosimulator.pcm.usagemodel.UsageScenario in project iobserve-analysis by research-iobserve.
the class UsageModelProviderTest method createThenReadByName.
@Override
@Test
public void createThenReadByName() {
final ModelProvider<UsageModel> modelProvider = new ModelProvider<>(UsageModelProviderTest.graph);
final ModelProvider<UsageScenario> modelProvider2 = new ModelProvider<>(UsageModelProviderTest.graph);
final UsageModel writtenModel = new TestModelBuilder().getUsageModel();
final UsageScenario writtenScenario = writtenModel.getUsageScenario_UsageModel().get(0);
final List<UsageScenario> readScenarios;
// Create complete model but only read a UsageScenario, because UsageModel itself has no id
modelProvider.createComponent(writtenModel);
readScenarios = modelProvider2.readOnlyComponentByName(UsageScenario.class, writtenScenario.getEntityName());
Assert.assertTrue(readScenarios.size() == 1);
for (final UsageScenario readScenario : readScenarios) {
Assert.assertTrue(this.equalityHelper.equals(writtenScenario, readScenario));
}
}
Aggregations