Package org.bladerunnerjs.plugin

Examples of org.bladerunnerjs.plugin.EventObserver


 
  @Test
  public void observersGetNotifiedOnReady() throws Exception
  {
    TestRootNode rootNode = new TestRootNode( new File(TEST_DIR, "brjs-root-node") );
    EventObserver observer = mock(EventObserver.class);
   
    rootNode.addObserver(observer);
    rootNode.ready();
   
    verify(observer).onEventEmitted( any(NodeReadyEvent.class), eq(rootNode) );
View Full Code Here


  @Test
  public void multipleObserversGetNotifiedOnReady() throws Exception
  {
    TestRootNode rootNode = new TestRootNode( new File(TEST_DIR, "brjs-root-node") );
    EventObserver observer1 = mock(EventObserver.class);
    EventObserver observer2 = mock(EventObserver.class);
   
    rootNode.addObserver(observer1);
    rootNode.addObserver(observer2);
    rootNode.ready();
   
View Full Code Here

  @Test
  public void parentsObserversGetNotified() throws Exception
  {
    TestRootNode rootNode = new TestRootNode( new File(TEST_DIR, "brjs-root-node") );
    TestNode node = new TestNode(rootNode, rootNode, new File(rootNode.dir(), "path/to-file" ) );
    EventObserver observer = mock(EventObserver.class);
   
    rootNode.addObserver(observer);
    node.ready();
   
    verify(observer).onEventEmitted( any(NodeReadyEvent.class), eq(node) );
View Full Code Here

  public void notificationsBubbleUpToParentsParent() throws Exception
  {
    TestRootNode rootNode = new TestRootNode( new File(TEST_DIR, "brjs-root-node") );
    TestNode midNode = new TestNode(rootNode, rootNode, new File(rootNode.dir(), "path" ) );
    TestNode lowerNode = new TestNode(rootNode, midNode, new File(midNode.dir(), "to-file" ) );
    EventObserver observer = mock(EventObserver.class);
   
    rootNode.addObserver(observer);
    lowerNode.ready();
   
    verify(observer).onEventEmitted( any(NodeReadyEvent.class), eq(lowerNode) );
View Full Code Here

  {
    TestRootNode rootNode = new TestRootNode( new File(TEST_DIR, "brjs-root-node") );
    TestNode midNode = new TestNode(rootNode, rootNode, new File(rootNode.dir(), "path" ) );
    TestNode lowerNode = new TestNode(rootNode, midNode, new File(midNode.dir(), "to-file" ) );
   
    EventObserver rootObserver = mock(EventObserver.class);
    EventObserver lowerObserver = mock(EventObserver.class);
   
    rootNode.addObserver(rootObserver);
    lowerNode.addObserver(lowerObserver);
    midNode.ready();
   
View Full Code Here

  {
    TestRootNode rootNode = new TestRootNode( new File(TEST_DIR, "brjs-root-node") );
    TestNode midNode = new TestNode(rootNode, rootNode, new File(rootNode.dir(), "path" ) );
    TestNode lowerNode = new TestNode(rootNode, midNode, new File(midNode.dir(), "to-file" ) );
   
    EventObserver rootObserver = mock(EventObserver.class);
    EventObserver midObserver = mock(EventObserver.class);
    EventObserver lowerObserver = mock(EventObserver.class);
   
    rootNode.addObserver(rootObserver);
    midNode.addObserver(midObserver);
    lowerNode.addObserver(lowerObserver);
    lowerNode.ready();
View Full Code Here

    File nodeDir = new File(TEST_DIR, "brjs-root-node");
    TestRootNode rootNode = new TestRootNode( nodeDir );
   
    assertTrue(nodeDir.exists());

    EventObserver observer = mock(EventObserver.class);
    rootNode.addObserver(NodeReadyEvent.class, observer);
   
    rootNode.registerNode(rootNode);
   
    verify(observer).onEventEmitted( any(NodeDiscoveredEvent.class), eq(rootNode) );
View Full Code Here

  @Test
  public void readyIsNotCalledOnInitIfDirDoesntExist() throws Exception
  {
    File nodeDir = new File(TEST_DIR, "root2");
    TestRootNode rootNode = new TestRootNode( nodeDir );
    EventObserver observer = mock(EventObserver.class);
   
    rootNode.addObserver(observer);
   
    assertFalse(nodeDir.exists());
    rootNode.registerNode(rootNode);
View Full Code Here

  public void exceptionsFromANodeObserverDoNotGetPropagatedAndAnErrorIsLogged() throws Exception
  {
    LogMessageStore logStore = new LogMessageStore(true);
    TestRootNode rootNode = new TestRootNode( new File(TEST_DIR, "brjs-root-node"), new TestLoggerFactory(logStore) );
   
    EventObserver observer = mock(EventObserver.class);
    RuntimeException ex = new RuntimeException();
    doThrow(ex).when(observer).onEventEmitted(any(Event.class), eq(rootNode));
   
    rootNode.addObserver(observer);
    rootNode.ready();
   
    logStore.verifyWarnLogMessage(ObserverList.Messages.NODE_OBSERVER_EXCEPTION_MSG, observer.getClass(), ExceptionUtils.getStackTrace(ex));
  }
View Full Code Here

  public void observersOnlyGetNotifiedForCorrectEvents() throws Exception
  {
    TestRootNode rootNode = new TestRootNode( new File(TEST_DIR, "brjs-root-node") );
    TestNode midNode = new TestNode(rootNode, rootNode, new File(rootNode.dir(), "path" ) );
    TestNode lowerNode = new TestNode(rootNode, midNode, new File(midNode.dir(), "to-file" ) );
    EventObserver observer = mock(EventObserver.class);
   
    rootNode.addObserver(MyTestEvent.class, observer);
    lowerNode.notifyObservers(new MyTestEvent(), lowerNode);
    lowerNode.notifyObservers(new AnotherTestEvent(), lowerNode);
   
View Full Code Here

TOP

Related Classes of org.bladerunnerjs.plugin.EventObserver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.