Search in sources :

Example 21 with InterpreterContext

use of org.apache.zeppelin.interpreter.InterpreterContext in project zeppelin by apache.

the class AngularObjectTest method testWatcher.

@Test
public void testWatcher() throws InterruptedException {
    final AtomicInteger updated = new AtomicInteger(0);
    final AtomicInteger onWatch = new AtomicInteger(0);
    AngularObject ao = new AngularObject("name", "value", "note1", null, new AngularObjectListener() {

        @Override
        public void updated(AngularObject updatedObject) {
            updated.incrementAndGet();
        }
    });
    ao.addWatcher(new AngularObjectWatcher(null) {

        @Override
        public void watch(Object oldObject, Object newObject, InterpreterContext context) {
            onWatch.incrementAndGet();
        }
    });
    assertEquals(0, onWatch.get());
    ao.set("newValue");
    Thread.sleep(500);
    assertEquals(1, onWatch.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) Test(org.junit.Test)

Aggregations

InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)21 Properties (java.util.Properties)9 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)7 Before (org.junit.Before)7 AuthenticationInfo (org.apache.zeppelin.user.AuthenticationInfo)6 AngularObjectRegistry (org.apache.zeppelin.display.AngularObjectRegistry)5 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)5 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 GUI (org.apache.zeppelin.display.GUI)4 Theory (org.junit.experimental.theories.Theory)4 AngularObjectWatcher (org.apache.zeppelin.display.AngularObjectWatcher)3 Interpreter (org.apache.zeppelin.interpreter.Interpreter)3 InterpreterOutput (org.apache.zeppelin.interpreter.InterpreterOutput)3 LocalResourcePool (org.apache.zeppelin.resource.LocalResourcePool)3 AngularObject (org.apache.zeppelin.display.AngularObject)2 BeforeClass (org.junit.BeforeClass)2 Test (org.junit.Test)2 File (java.io.File)1 IOException (java.io.IOException)1