SimulationRepository repo = SimulationRunner.runSimulation("defaultPackage.test", out, 5, 2000, true, "onevent.simulation.rules.drl");
assertNotNull(repo);
WorkingMemorySimulationRepository wmRepo = (WorkingMemorySimulationRepository) repo;
assertEquals(20, wmRepo.getAggregatedEvents().size());
assertEquals(35, wmRepo.getEvents().size());
for (SimulationEvent event : wmRepo.getEvents()) {
if ((event instanceof EndSimulationEvent) || (event instanceof ActivitySimulationEvent)|| (event instanceof HumanTaskActivitySimulationEvent)) {
assertNotNull(((GenericSimulationEvent) event).getAggregatedEvent());
assertTrue(((GenericSimulationEvent) event).getAggregatedEvent() instanceof AggregatedProcessSimulationEvent);
} else if (event instanceof ProcessInstanceEndSimulationEvent) {
assertNull(((GenericSimulationEvent) event).getAggregatedEvent());
}
}
wmRepo.getSession().execute(new InsertElementsCommand((Collection)wmRepo.getAggregatedEvents()));
wmRepo.fireAllRules();
List<AggregatedSimulationEvent> summary = (List<AggregatedSimulationEvent>) wmRepo.getGlobal("summary");
assertNotNull(summary);
assertEquals(5, summary.size());
for (AggregatedSimulationEvent event : summary) {
if (event instanceof AggregatedProcessSimulationEvent) {
Map<String, Integer> numberOfInstancePerPath = ((AggregatedProcessSimulationEvent) event).getPathNumberOfInstances();
assertNotNull(numberOfInstancePerPath);
assertEquals(1, (int)numberOfInstancePerPath.get("Path800898475-0"));
assertEquals(4, (int)numberOfInstancePerPath.get("Path-960633761-1"));
}
}
SimulationInfo info = wmRepo.getSimulationInfo();
assertNotNull(info);
assertEquals("defaultPackage.test", info.getProcessId());
assertEquals("test", info.getProcessName());
assertEquals(5, info.getNumberOfExecutions());
assertEquals(2000, info.getInterval());
System.out.println("Start date is " + new Date(info.getStartTime()) + " end date is " + new Date(info.getEndTime()));
wmRepo.close();
}