use of il.ac.bgu.cs.bp.bpjs.model.BEvent in project BPjs by bThink-BGU.
the class BEventSetsJsTest method testContains_Data.
@Test
public void testContains_Data() throws Exception {
BEvent eVizObj = events.get("eVizObj");
BEvent eViz = events.get("eViz");
BEvent eName = events.get("eName");
EventSet esDataVizIsViz = eventSets.get("esDataObjVizIsViz");
EventSet esDataIsViz = eventSets.get("esDataIsViz");
Context.enter();
assertTrue(esDataVizIsViz.contains(eVizObj));
assertTrue(esDataIsViz.contains(eViz));
assertFalse(esDataIsViz.contains(eVizObj));
assertFalse(esDataVizIsViz.contains(eViz));
assertFalse(esDataVizIsViz.contains(eName));
assertFalse(esDataIsViz.contains(eName));
Context.exit();
}
use of il.ac.bgu.cs.bp.bpjs.model.BEvent in project BPjs by bThink-BGU.
the class SimpleEventSelectionStrategyTest method testWithBlockingCase.
@Test
public void testWithBlockingCase() {
BEvent expected = eventOne;
Set<BSyncStatement> sets = new HashSet<>(Arrays.asList(BSyncStatement.make(null).request(eventOne), BSyncStatement.make(null).request(eventTwo), BSyncStatement.make(null).block(eventTwo)));
assertEquals(singleton(expected), sut.selectableEvents(sets, Collections.emptyList()));
assertEquals(Optional.of(new EventSelectionResult(expected)), sut.select(sets, Collections.emptyList(), singleton(expected)));
}
use of il.ac.bgu.cs.bp.bpjs.model.BEvent in project BPjs by bThink-BGU.
the class SimpleEventSelectionStrategyTest method testUnanimousCase.
@Test
public void testUnanimousCase() {
BEvent expected = eventOne;
Set<BSyncStatement> sets = new HashSet<>(Arrays.asList(BSyncStatement.make(null).request(eventOne), BSyncStatement.make(null).request(eventOne).waitFor(eventTwo), BSyncStatement.make(null).request(eventOne)));
assertEquals(singleton(expected), sut.selectableEvents(sets, Collections.emptyList()));
assertEquals(Optional.of(new EventSelectionResult(expected)), sut.select(sets, Collections.emptyList(), singleton(eventOne)));
}
use of il.ac.bgu.cs.bp.bpjs.model.BEvent in project BPjs by bThink-BGU.
the class NamedArgsHotNColdTest method superStepTest.
@Test
public void superStepTest() throws InterruptedException {
BProgramRunner sut = new BProgramRunner(new SingleResourceBProgram("NamedArgsHotNCold.js"));
sut.addListener(new PrintBProgramRunnerListener());
InMemoryEventLoggingListener eventLogger = sut.addListener(new InMemoryEventLoggingListener());
sut.run();
eventLogger.getEvents().forEach(e -> System.out.println(e));
final BEvent hotEvent = new BEvent("hotEvent");
final BEvent coldEvent = new BEvent("coldEvent");
final BEvent allDoneEvent = new BEvent("allDone");
EventPattern expected = new EventPattern().append(coldEvent).append(hotEvent).append(coldEvent).append(hotEvent).append(coldEvent).append(hotEvent).append(allDoneEvent);
assertTrue(expected.matches(eventLogger.getEvents()));
}
use of il.ac.bgu.cs.bp.bpjs.model.BEvent in project BPjs by bThink-BGU.
the class ResumeBThreadTest method testToString.
/**
* Test of toString method, of class ResumeBThread.
*/
@Test
public void testToString() {
BEvent evt = new BEvent("evtName");
ResumeBThread sut = new ResumeBThread(new BThreadSyncSnapshot("snap-name", null), evt, null);
String toString = sut.toString();
assertTrue(toString.startsWith("[ResumeBThread:"));
assertTrue(toString.contains("snap-name"));
assertTrue(toString.split("event:")[1].contains(evt.toString()));
}
Aggregations