Search in sources :

Example 1 with JsEventSet

use of il.ac.bgu.cs.bp.bpjs.model.eventsets.JsEventSet in project BPjs by bThink-BGU.

the class JsEventSetTest method testJsSetData.

@Test
public void testJsSetData() throws InterruptedException, URISyntaxException {
    try {
        Context.enter();
        BProgram bpr = new StringBProgram("Eventset", "var es=bp.EventSet('a',function(e){return e.name=='a';});\n");
        new BProgramRunner(bpr).run();
        NativeJavaObject sut = (NativeJavaObject) bpr.getGlobalScope().get("es", bpr.getGlobalScope());
        JsEventSet jsSut = (JsEventSet) Context.jsToJava(sut, JsEventSet.class);
        assertEquals("a", jsSut.getName());
        assertTrue(jsSut.toString().contains("a"));
        assertTrue(jsSut.toString().contains("JsEventSet"));
        assertTrue(jsSut.contains(BEvent.named("a")));
        assertFalse(jsSut.contains(BEvent.named("b")));
    } finally {
        Context.exit();
    }
}
Also used : BProgramRunner(il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner) SingleResourceBProgram(il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram) BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) JsEventSet(il.ac.bgu.cs.bp.bpjs.model.eventsets.JsEventSet) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) Test(org.junit.Test)

Aggregations

BProgramRunner (il.ac.bgu.cs.bp.bpjs.execution.BProgramRunner)1 BProgram (il.ac.bgu.cs.bp.bpjs.model.BProgram)1 SingleResourceBProgram (il.ac.bgu.cs.bp.bpjs.model.SingleResourceBProgram)1 StringBProgram (il.ac.bgu.cs.bp.bpjs.model.StringBProgram)1 JsEventSet (il.ac.bgu.cs.bp.bpjs.model.eventsets.JsEventSet)1 Test (org.junit.Test)1 NativeJavaObject (org.mozilla.javascript.NativeJavaObject)1