use of org.iobserve.analysis.userbehavior.ReferenceElements in project iobserve-analysis by research-iobserve.
the class CallSequenceScalabilityReference method getModel.
/**
* It creates a fixed number of user sessions. The number of calls per user session is
* determined by the passed numberOfIterations parameter. It defines how often a fixed call
* sequence is added to the call sequence of each user session. It is used to evaluate the
* approach's response times with an increasing number of calls (RQ-3.2). It returns user
* session that are used to execute the approach and to measure the response time. Thereby, this
* method is called repeatedly to constantly increase the number of calls per UserSession.
*
* @param numberOfIterations
* defines how many calls per user session are created
* @return user sessions
*/
public static ReferenceElements getModel(final int numberOfIterations) {
final ReferenceElements testElements = new ReferenceElements();
final int numberOfUserSessions = 50;
final EntryCallSequenceModel entryCallSequenceModel = new EntryCallSequenceModel(TestHelper.getUserSessions(numberOfUserSessions));
boolean branchDecisionerUserGroup1 = true;
boolean branchDecisionerUserGroup2 = true;
for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
final double userGroupDecisioner = (double) i / (double) numberOfUserSessions;
int entryTime = 1;
int exitTime = 2;
// by their operation signatures
if (userGroupDecisioner < 0.3) {
branchDecisionerUserGroup1 = !branchDecisionerUserGroup1;
// each user session is iterated and thus the number of calls per user session
for (int j = 0; j < numberOfIterations; j++) {
// One single call
EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0], ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
// An iterated call to represent a loop
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1], ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1], ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
// Alternative calls to represent a branch
final int branchDecisioner = TestHelper.getRandomInteger(2, 1);
if (branchDecisioner == 1) {
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0], ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
} else {
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[1], ReferenceUsageModelBuilder.CLASS_SIGNATURE[1], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
}
// An equal call to merge the branch transitions
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[2], ReferenceUsageModelBuilder.CLASS_SIGNATURE[2], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
}
} else {
branchDecisionerUserGroup2 = !branchDecisionerUserGroup2;
// each user session is iterated and thus the number of calls per user session
for (int j = 0; j < numberOfIterations; j++) {
// One single call
EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3], ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
// An iterated call to represent a loop
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
// Alternative calls to represent a branch
final int branchDecisioner = TestHelper.getRandomInteger(2, 1);
if (branchDecisioner == 1) {
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3], ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
} else {
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
}
// An equal call to merge the branch transitions
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[0], ReferenceUsageModelBuilder.CLASS_SIGNATURE[0], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime += 2;
exitTime += 2;
}
}
}
// Returns the created user sessions. Now our approach can be executed and the response
// times can be measured
testElements.setEntryCallSequenceModel(entryCallSequenceModel);
return testElements;
}
use of org.iobserve.analysis.userbehavior.ReferenceElements in project iobserve-analysis by research-iobserve.
the class LoopWithinLoopReference method getLoopWithinLoopReferenceModel.
/**
* It creates a reference usage model that contains loops within loops. Accordingly, user
* sessions whose call sequences contain iterated segments that again contain iterated segments
* are created.(RQ-1.7)
*
* @param referenceUsageModelFileName
* file name of the reference model to store its result
* @param repositoryLookupModel
* repository model provider
* @param correspondenceModel
* correspondence model
*
* @return reference usage model and corresponding user sessions
* @throws IOException
* on error
*/
public ReferenceElements getLoopWithinLoopReferenceModel(final String referenceUsageModelFileName, final RepositoryLookupModelProvider repositoryLookupModel, final ICorrespondence correspondenceModel) throws IOException {
// Create a random number of user sessions and random model element parameters. The user
// sessions' behavior will be created according to the reference usage model and
// subsequently the user sessions are used to create a usage model. The created usage model
// is matched against the reference usage model
final int countOfLoop1 = TestHelper.getRandomInteger(4, 2);
final int countOfLoop2 = TestHelper.getRandomInteger(4, 2);
final int lengthOfSubsequentLoopSequence = TestHelper.getRandomInteger(2, 1);
// In the following the reference usage model is created
Optional<Correspondent> optionCorrespondent;
AbstractUserAction lastAction;
final UsageModel usageModel = UsageModelFactory.createUsageModel();
final UsageScenario usageScenario = UsageModelFactory.createUsageScenario("", usageModel);
final ScenarioBehaviour scenarioBehaviour = usageScenario.getScenarioBehaviour_UsageScenario();
final Start start = UsageModelFactory.createStart("");
UsageModelFactory.addUserAction(scenarioBehaviour, start);
final Stop stop = UsageModelFactory.createStop("");
UsageModelFactory.addUserAction(scenarioBehaviour, stop);
lastAction = start;
// The exterior loop is created
final Loop loop = UsageModelFactory.createLoop("", scenarioBehaviour);
UsageModelFactory.connect(lastAction, loop);
UsageModelFactory.connect(loop, stop);
final PCMRandomVariable pcmLoopIteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
pcmLoopIteration.setSpecification(String.valueOf(countOfLoop1));
loop.setLoopIteration_Loop(pcmLoopIteration);
final Start loopStart = UsageModelFactory.createStart("");
UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStart);
final Stop loopStop = UsageModelFactory.createStop("");
UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStop);
lastAction = loopStart;
// The interior loop is created
final Loop loop2 = UsageModelFactory.createLoop("", loop.getBodyBehaviour_Loop());
UsageModelFactory.connect(lastAction, loop2);
final PCMRandomVariable pcmLoop2Iteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
pcmLoop2Iteration.setSpecification(String.valueOf(countOfLoop2));
loop2.setLoopIteration_Loop(pcmLoop2Iteration);
final Start loop2Start = UsageModelFactory.createStart("");
UsageModelFactory.addUserAction(loop2.getBodyBehaviour_Loop(), loop2Start);
final Stop loop2Stop = UsageModelFactory.createStop("");
UsageModelFactory.addUserAction(loop2.getBodyBehaviour_Loop(), loop2Stop);
lastAction = loop2Start;
optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[2], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[2]);
if (optionCorrespondent.isPresent()) {
final Correspondent correspondent = optionCorrespondent.get();
final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, correspondent);
UsageModelFactory.addUserAction(loop2.getBodyBehaviour_Loop(), entryLevelSystemCall);
UsageModelFactory.connect(lastAction, entryLevelSystemCall);
lastAction = entryLevelSystemCall;
}
UsageModelFactory.connect(lastAction, loop2Stop);
lastAction = loop2;
// The sequence that exclusively belongs to the exterior loop is created
for (int i = 0; i < lengthOfSubsequentLoopSequence; i++) {
switch(i) {
case 0:
optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3]);
break;
case 1:
optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4]);
break;
default:
throw new IllegalArgumentException("Illegal value of model element parameter");
}
if (optionCorrespondent.isPresent()) {
final Correspondent correspondent = optionCorrespondent.get();
final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModel, correspondent);
UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), entryLevelSystemCall);
UsageModelFactory.connect(lastAction, entryLevelSystemCall);
lastAction = entryLevelSystemCall;
}
}
UsageModelFactory.connect(lastAction, loopStop);
final int numberOfConcurrentUsers = TestHelper.getRandomInteger(200, 1);
final EntryCallSequenceModel entryCallSequenceModel = new EntryCallSequenceModel(TestHelper.getUserSessions(numberOfConcurrentUsers));
// According to the reference usage model user sessions are created that exactly represent
// the user behavior of the reference usage model. The entry and exit times enable that the
// calls within the user sessions are ordered according to the reference usage model.
int entryTime = 1;
int exitTime = 2;
for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
entryTime = 1;
exitTime = 2;
// Represents the exterior loop of the reference usage model
for (int k = 0; k < countOfLoop1; k++) {
// Represents the interior loop of the reference usage model
for (int j = 0; j < countOfLoop2; j++) {
final EntryCallEvent entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[2], ReferenceUsageModelBuilder.CLASS_SIGNATURE[2], String.valueOf(i), "hostname");
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime = entryTime + 2;
exitTime = exitTime + 2;
}
// Calls of the exterior loop
for (int j = 0; j < lengthOfSubsequentLoopSequence; j++) {
EntryCallEvent entryCallEvent = null;
switch(j) {
case 0:
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[3], ReferenceUsageModelBuilder.CLASS_SIGNATURE[3], String.valueOf(i), "hostname");
break;
case 1:
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[4], ReferenceUsageModelBuilder.CLASS_SIGNATURE[4], String.valueOf(i), "hostname");
break;
default:
throw new IllegalArgumentException("Illegal value of model element parameter");
}
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime = entryTime + 2;
exitTime = exitTime + 2;
}
}
}
// Saves the reference usage model and sets the usage model and the EntryCallSequenceModel
// as the reference elements. Our approach is now executed with the EntryCallSequenceModel
// and the resulting usage model can be matched against the reference usage model
final ReferenceElements referenceElements = new ReferenceElements();
TestHelper.saveModel(usageModel, referenceUsageModelFileName);
referenceElements.setEntryCallSequenceModel(entryCallSequenceModel);
referenceElements.setUsageModel(usageModel);
return referenceElements;
}
use of org.iobserve.analysis.userbehavior.ReferenceElements in project iobserve-analysis by research-iobserve.
the class OverlappingIterationReference method getModel.
/**
* Creates a reference model that contains a loop element. The user sessions contain iterated
* call sequences that share overlapping calls. Thereby, one iterated sequence consists of more
* calls than the other. Thus, it can be checked whether the approach transforms the iterated
* call sequence that consists of more calls to a loop (RQ-1.4)
*
* @param referenceUsageModelFileName
* file name of the reference model to store its result
* @param repositoryLookupModelProvider
* repository model provider
* @param correspondenceModel
* correspondence model
*
* @return a reference usage model and corresponding user sessions
* @throws IOException
* on error
*/
public static ReferenceElements getModel(final String referenceUsageModelFileName, final RepositoryLookupModelProvider repositoryLookupModelProvider, final ICorrespondence correspondenceModel) throws IOException {
// Creates a random number of user sessions and random model element parameters. The user
// sessions' behavior will be created according to the reference usage model and
// subsequently the user sessions are used to create a usage model. The created usage model
// is matched against the reference usage model.
final int numberOfConcurrentUsers = TestHelper.getRandomInteger(200, 1);
// One of the iterated sequences is iterated twice and one is iterated three times. The
// number of iterations is set randomly.
final int loopCount1 = TestHelper.getRandomInteger(3, 2);
final int lengthOfSequence1 = 2 * loopCount1;
final int loopCount2;
if (loopCount1 == 3) {
loopCount2 = 2;
} else {
loopCount2 = 3;
}
final int lengthOfSequence2 = 2 * loopCount2;
final ReferenceElements referenceElements = new ReferenceElements();
final EntryCallSequenceModel entryCallSequenceModel = new EntryCallSequenceModel(TestHelper.getUserSessions(numberOfConcurrentUsers));
// In the following the reference usage model is created
AbstractUserAction lastAction;
final UsageModel usageModel = UsageModelFactory.createUsageModel();
final UsageScenario usageScenario = UsageModelFactory.createUsageScenario("", usageModel);
final ScenarioBehaviour scenarioBehaviour = usageScenario.getScenarioBehaviour_UsageScenario();
final Start start = UsageModelFactory.createStart("");
UsageModelFactory.addUserAction(scenarioBehaviour, start);
final Stop stop = UsageModelFactory.createStop("");
UsageModelFactory.addUserAction(scenarioBehaviour, stop);
// According to the randomly set number of iterations the sequence that is iterated three
// times is represented by a loop element. The other sequence is represented by a sequence
final Loop loop = UsageModelFactory.createLoop("", scenarioBehaviour);
if (lengthOfSequence1 >= lengthOfSequence2) {
UsageModelFactory.connect(start, loop);
final PCMRandomVariable pcmLoopIteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
pcmLoopIteration.setSpecification(String.valueOf(loopCount1));
// Set number of loops
loop.setLoopIteration_Loop(pcmLoopIteration);
final Start loopStart = UsageModelFactory.createStart("");
UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStart);
final Stop loopStop = UsageModelFactory.createStop("");
UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStop);
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 0, loopStart, scenarioBehaviour);
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 2, lastAction, scenarioBehaviour);
UsageModelFactory.connect(lastAction, loopStop);
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 3, loop, scenarioBehaviour);
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 2, lastAction, scenarioBehaviour);
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 3, lastAction, scenarioBehaviour);
UsageModelFactory.connect(lastAction, stop);
} else {
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 0, start, scenarioBehaviour);
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 2, lastAction, scenarioBehaviour);
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 0, lastAction, scenarioBehaviour);
UsageModelFactory.connect(lastAction, loop);
final PCMRandomVariable pcmLoopIteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
pcmLoopIteration.setSpecification(String.valueOf(loopCount2));
// Set number of loops
loop.setLoopIteration_Loop(pcmLoopIteration);
final Start loopStart = UsageModelFactory.createStart("");
UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStart);
final Stop loopStop = UsageModelFactory.createStop("");
UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), loopStop);
lastAction = loopStart;
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 2, lastAction, scenarioBehaviour);
lastAction = OverlappingIterationReference.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondenceModel, 3, lastAction, scenarioBehaviour);
UsageModelFactory.connect(lastAction, loopStop);
UsageModelFactory.connect(loop, stop);
}
OverlappingIterationReference.createMatchingEntryAndExitEvents(entryCallSequenceModel, lengthOfSequence1, lengthOfSequence2, loopCount1, loopCount2);
// Saves the reference usage model and sets the usage model and the EntryCallSequenceModel
// as the reference elements. Our approach is now executed with the EntryCallSequenceModel
// and the resulting usage model can be matched against the reference usage model
TestHelper.saveModel(usageModel, referenceUsageModelFileName);
referenceElements.setEntryCallSequenceModel(entryCallSequenceModel);
referenceElements.setUsageModel(usageModel);
return referenceElements;
}
use of org.iobserve.analysis.userbehavior.ReferenceElements in project iobserve-analysis by research-iobserve.
the class SimpleLoopReference method getModel.
/**
* Creates a reference model that contains a loop element. Accordingly, user sessions whose call
* sequences contain iterated calls are created.(RQ-1.3)
*
* @param referenceUsageModelFileName
* reference usage model file name
* @param repositoryLookupModelProvider
* repository model provider
* @param correspondenceModel
* correspondence model
*
* @return the reference usage model and a corresponding EntryCallSequenceModel
* @throws IOException
* on error
*/
public static ReferenceElements getModel(final String referenceUsageModelFileName, final RepositoryLookupModelProvider repositoryLookupModelProvider, final ICorrespondence correspondenceModel) throws IOException {
// Create a random number of user sessions and random model element parameters. The user
// sessions' behavior will be created according to the reference usage model and
// subsequently the user sessions are used to create a usage model. The created usage model
// is matched against the reference usage model
final int numberOfConcurrentUsers = TestHelper.getRandomInteger(200, 1);
final int loopCount = TestHelper.getRandomInteger(5, 2);
final int numberOfIteratedCalls = TestHelper.getRandomInteger(5, 1);
final EntryCallSequenceModel entryCallSequenceModel = new EntryCallSequenceModel(TestHelper.getUserSessions(numberOfConcurrentUsers));
final ReferenceElements referenceElements = new ReferenceElements();
// In the following the reference usage model is created
AbstractUserAction lastAction;
final UsageModel usageModel = UsageModelFactory.createUsageModel();
final UsageScenario usageScenario = UsageModelFactory.createUsageScenario("", usageModel);
final ScenarioBehaviour scenarioBehaviour = usageScenario.getScenarioBehaviour_UsageScenario();
final Start start = UsageModelFactory.createAddStartAction("", scenarioBehaviour);
final Stop stop = UsageModelFactory.createAddStopAction("", scenarioBehaviour);
// A loop is created and the loop count is set
final Loop loop = UsageModelFactory.createLoop("", scenarioBehaviour);
UsageModelFactory.connect(start, loop);
final PCMRandomVariable pcmLoopIteration = CoreFactory.eINSTANCE.createPCMRandomVariable();
pcmLoopIteration.setSpecification(String.valueOf(loopCount));
loop.setLoopIteration_Loop(pcmLoopIteration);
UsageModelFactory.connect(loop, stop);
// The EntryLevelSystemCalls that are iterated are added to the loop element
final Start loopStart = UsageModelFactory.createAddStartAction("", loop.getBodyBehaviour_Loop());
final Stop loopStop = UsageModelFactory.createAddStopAction("", loop.getBodyBehaviour_Loop());
lastAction = loopStart;
Optional<Correspondent> optionCorrespondent;
// iterated calls to the loop
for (int i = 0; i < numberOfIteratedCalls; i++) {
if (i >= 0 && i < 5) {
optionCorrespondent = correspondenceModel.getCorrespondent(ReferenceUsageModelBuilder.CLASS_SIGNATURE[i], ReferenceUsageModelBuilder.OPERATION_SIGNATURE[i]);
} else {
throw new IllegalArgumentException("Illegal value of model element parameter");
}
if (optionCorrespondent.isPresent()) {
final Correspondent correspondent = optionCorrespondent.get();
final EntryLevelSystemCall entryLevelSystemCall = UsageModelFactory.createEntryLevelSystemCall(repositoryLookupModelProvider, correspondent);
UsageModelFactory.addUserAction(loop.getBodyBehaviour_Loop(), entryLevelSystemCall);
UsageModelFactory.connect(lastAction, entryLevelSystemCall);
lastAction = entryLevelSystemCall;
}
}
UsageModelFactory.connect(lastAction, loopStop);
// According to the reference usage model user sessions are created that exactly represent
// the user behavior of the reference usage model. The entry and exit times enable that the
// calls within the user sessions are ordered according to the reference usage model
int entryTime = 1;
int exitTime = 2;
for (int i = 0; i < entryCallSequenceModel.getUserSessions().size(); i++) {
entryTime = 1;
exitTime = 2;
// number of iterated calls
for (int k = 0; k < loopCount; k++) {
for (int j = 0; j < numberOfIteratedCalls; j++) {
EntryCallEvent entryCallEvent = null;
if (j >= 0 && j < 5) {
entryCallEvent = new EntryCallEvent(entryTime, exitTime, ReferenceUsageModelBuilder.OPERATION_SIGNATURE[j], ReferenceUsageModelBuilder.CLASS_SIGNATURE[j], String.valueOf(i), "hostname");
} else {
throw new IllegalArgumentException("Illegal value of model element parameter");
}
entryCallSequenceModel.getUserSessions().get(i).add(entryCallEvent, true);
entryTime = entryTime + 2;
exitTime = exitTime + 2;
}
}
}
// Saves the reference usage model and sets the usage model and the EntryCallSequenceModel
// as the reference elements. Our approach is now executed with the EntryCallSequenceModel
// and the resulting usage model can be matched against the reference usage model
TestHelper.saveModel(usageModel, referenceUsageModelFileName);
referenceElements.setEntryCallSequenceModel(entryCallSequenceModel);
referenceElements.setUsageModel(usageModel);
return referenceElements;
}
Aggregations