package com.flexibledeveloper.observer;

import org.junit.Test;

/**
 * Created by kharyam on 5/17/14.
 */
public class ObserverTest {

  @Test
  public void nominalBehavior() {
    ConcreteSubject subject = new ConcreteSubject();
    Data originalData = new Data("Original Value 1","Original Value 2","Original Value 3");
    subject.setData(originalData);

    Observer observer1 = new ConcreteObserver1();
    Observer observer2 = new ConcreteObserver2();
    Observer observer3 = new ConcreteObserver3();

    subject.registerObserver(observer1);
    subject.registerObserver(observer2);
    subject.registerObserver(observer3);

    subject.notifyObservers();


    Data newData = new Data("New Value 1","New Value 2","New Value 3");

    subject.notifyObservers(newData);

  }
}

@@ -170,16 +170,61 @@
 vior() %7B
+%0A%0A    System.out.println(%22Creating Subject%22);
 %0A    Con
@@ -393,24 +393,70 @@
 inalData);%0A%0A
+    System.out.println(%22Creating Observers%22);%0A
     Observer
@@ -590,24 +590,73 @@
 server3();%0A%0A
+    System.out.println(%22Registering Observers%22);%0A
     subject.
@@ -763,24 +763,73 @@
 bserver3);%0A%0A
+    System.out.println(%22%5CnNotifying observers%22);%0A
     subject.
@@ -848,17 +848,16 @@
 ers();%0A%0A
-%0A
     Data
@@ -917,24 +917,273 @@
 Value 3%22);%0A%0A
+    System.out.println(%22%5CnNotifying observers with new data%22);%0A    subject.notifyObservers(newData);%0A%0A    System.out.println(%22%5CnRemoving observer2%22);%0A    subject.removeObserver(observer2);%0A%0A    System.out.println(%22%5CnNotifying remaining observers%22);%0A
     subject.

Test the removal of an observer.