package be.wegenenverkeer.atomium.japi.client;

import be.wegenenverkeer.atomium.japi.format.Entry;
import be.wegenenverkeer.atomium.japi.format.Feed;
import org.junit.Test;
import rx.Observable;
import rx.Scheduler;
import rx.Subscription;

import javax.xml.bind.annotation.*;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by Karel Maesen, Geovise BVBA on 16/03/15.
 */
public class FunctionalDesignTest{

    //TODO -- use a decent mock implementation, for now we just run the Play demo server

    @Test
    public void test() throws InterruptedException {


        AtomiumClient client = new AtomiumClient.Builder()
                .setBaseUrl("http://localhost:9000")
                .setAcceptXml()
                .build();

        Observable<Entry<Event>> observable = client.feed("feeds/events", Event.class).observe(1000);


        AtomicInteger cnt = new AtomicInteger(0);

        observable.take(1000).toBlocking().forEach(entry -> System.out.println(cnt.incrementAndGet() + " > " + entry.getId() + " - " +
                entry.getUpdated() +  " - " + entry.getContent().getValue()));


        client.close();
    }

}





@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
class Event {

    @XmlElement
    public Double value;

    @XmlElement
    public String description;

    @XmlAttribute
    public Integer version;

    public Event(){
    }


    public String toString() {
        return "Event " + version + " " + "description " + " value: " + value;
    }

}

@@ -144,16 +144,41 @@
 t.Feed;%0A
+import org.junit.Ignore;%0A
 import o
@@ -544,16 +544,24 @@
    @Test
+ @Ignore
 %0A    pub
@@ -579,37 +579,8 @@
 st()
- throws InterruptedException 
 %7B%0A%0A%0A

Set design-test to ignore for the time being.