Search in sources :

Example 1 with UsageScenario

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));
}
Also used : UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) Test(org.junit.Test)

Example 2 with UsageScenario

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));
}
Also used : Loop(org.palladiosimulator.pcm.usagemodel.Loop) UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) EntryLevelSystemCall(org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall) ScenarioBehaviour(org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable) Test(org.junit.Test)

Example 3 with UsageScenario

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));
}
Also used : UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) Transaction(org.neo4j.graphdb.Transaction) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) Test(org.junit.Test)

Example 4 with UsageScenario

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));
}
Also used : UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) Test(org.junit.Test)

Example 5 with UsageScenario

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));
    }
}
Also used : UsageScenario(org.palladiosimulator.pcm.usagemodel.UsageScenario) UsageModel(org.palladiosimulator.pcm.usagemodel.UsageModel) Test(org.junit.Test)

Aggregations

UsageScenario (org.palladiosimulator.pcm.usagemodel.UsageScenario)20 UsageModel (org.palladiosimulator.pcm.usagemodel.UsageModel)17 ScenarioBehaviour (org.palladiosimulator.pcm.usagemodel.ScenarioBehaviour)12 Test (org.junit.Test)8 EntryCallSequenceModel (org.iobserve.analysis.data.EntryCallSequenceModel)7 AbstractUserAction (org.palladiosimulator.pcm.usagemodel.AbstractUserAction)7 EntryLevelSystemCall (org.palladiosimulator.pcm.usagemodel.EntryLevelSystemCall)7 Start (org.palladiosimulator.pcm.usagemodel.Start)7 Stop (org.palladiosimulator.pcm.usagemodel.Stop)7 ReferenceElements (org.iobserve.analysis.userbehavior.ReferenceElements)6 Correspondent (org.iobserve.model.correspondence.Correspondent)6 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)5 Loop (org.palladiosimulator.pcm.usagemodel.Loop)5 EntryCallEvent (org.iobserve.stages.general.data.EntryCallEvent)4 ArrayList (java.util.ArrayList)3 BranchTransition (org.palladiosimulator.pcm.usagemodel.BranchTransition)3 HashMap (java.util.HashMap)2 Branch (org.palladiosimulator.pcm.usagemodel.Branch)2 List (java.util.List)1 EObject (org.eclipse.emf.ecore.EObject)1