Search in sources :

Example 21 with BEvent

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();
}
Also used : BEvent(il.ac.bgu.cs.bp.bpjs.model.BEvent) Test(org.junit.Test)

Example 22 with BEvent

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)));
}
Also used : BSyncStatement(il.ac.bgu.cs.bp.bpjs.model.BSyncStatement) BEvent(il.ac.bgu.cs.bp.bpjs.model.BEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 23 with BEvent

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)));
}
Also used : BSyncStatement(il.ac.bgu.cs.bp.bpjs.model.BSyncStatement) BEvent(il.ac.bgu.cs.bp.bpjs.model.BEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 24 with BEvent

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()));
}
Also used : PrintBProgramRunnerListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener) EventPattern(il.ac.bgu.cs.bp.bpjs.analysis.eventpattern.EventPattern) BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) InMemoryEventLoggingListener(il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener) BEvent(il.ac.bgu.cs.bp.bpjs.model.BEvent) Test(org.junit.Test)

Example 25 with BEvent

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()));
}
Also used : BEvent(il.ac.bgu.cs.bp.bpjs.model.BEvent) BThreadSyncSnapshot(il.ac.bgu.cs.bp.bpjs.model.BThreadSyncSnapshot) Test(org.junit.Test)

Aggregations

BEvent (il.ac.bgu.cs.bp.bpjs.model.BEvent)37 Test (org.junit.Test)25 SingleResourceBProgram (il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram)16 BProgramRunner (il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner)13 InMemoryEventLoggingListener (il.ac.bgu.cs.bp.bpjs.execution.listeners.InMemoryEventLoggingListener)13 PrintBProgramRunnerListener (il.ac.bgu.cs.bp.bpjs.execution.listeners.PrintBProgramRunnerListener)13 BSyncStatement (il.ac.bgu.cs.bp.bpjs.model.BSyncStatement)9 EventPattern (il.ac.bgu.cs.bp.bpjs.analysis.eventpattern.EventPattern)8 BProgram (il.ac.bgu.cs.bp.bpjs.model.BProgram)8 BThreadSyncSnapshot (il.ac.bgu.cs.bp.bpjs.model.BThreadSyncSnapshot)7 StringBProgram (il.ac.bgu.cs.bp.bpjs.model.StringBProgram)6 Context (org.mozilla.javascript.Context)6 BProgramSyncSnapshot (il.ac.bgu.cs.bp.bpjs.model.BProgramSyncSnapshot)5 EventSet (il.ac.bgu.cs.bp.bpjs.model.eventsets.EventSet)5 HashSet (java.util.HashSet)5 List (java.util.List)5 Set (java.util.Set)5 ComposableEventSet (il.ac.bgu.cs.bp.bpjs.model.eventsets.ComposableEventSet)4 EventSets (il.ac.bgu.cs.bp.bpjs.model.eventsets.EventSets)4 Collections.emptySet (java.util.Collections.emptySet)4