Package org.netmelody.cieye.core.domain

Examples of org.netmelody.cieye.core.domain.LandscapeObservation


public class LandscapeObservationTest {

    @Test public void
    translatesToAppropriateJsonRepresentationWhenEmpty() {
        final LandscapeObservation observation = new LandscapeObservation();
       
        assertThat(new JsonTranslator().toJson(observation), is("{\"targets\":[]}"));
    }
View Full Code Here


        assertThat(new JsonTranslator().toJson(observation), is("{\"targets\":[]}"));
    }
   
    @Test public void
    translatesToAppropriateJsonRepresentationWithSimpleTargets() {
        final LandscapeObservation observation = new LandscapeObservation(TargetDetailGroup.of(newArrayList(new TargetDetail("T1ID", "T1URL", "T1", Status.GREEN, 0L),
                                                                                                            new TargetDetail("T2ID", "T2URL", "T2", Status.BROKEN, 0L))));
       
        assertThat(new JsonTranslator().toJson(observation), is("{\"targets\":[" +
                                                                    "{\"lastStartTime\":0," +
                                                                     "\"sponsors\":[]," +
View Full Code Here

                                                                "]}"));
    }
   
    @Test public void
    translatesToAppropriateJsonRepresentationWithComplexTarget() {
        final LandscapeObservation observation = new LandscapeObservation(TargetDetailGroup.of(newArrayList(
                new TargetDetail("T1ID", "T1URL", "T1", Status.GREEN, 123,
                           newArrayList(new RunningBuild(percentageOf(1), Status.GREEN),
                                        new RunningBuild(percentageOf(60), Status.BROKEN)),
                           newHashSet(new Sponsor("S1", "P1"))))));
       
View Full Code Here

                                                                "]}"));
    }
   
    @Test public void
    translatesToAppropriateJsonRepresentationWithDohList() {
        final LandscapeObservation observation = new LandscapeObservation().withDoh(newHashSet(new Sponsor("S1", "P1")));
       
        assertThat(new JsonTranslator().toJson(observation), is("{\"targets\":[],\"dohGroup\":[{\"name\":\"S1\",\"picture\":\"P1\"}]}"));
    }
View Full Code Here

        this.prison = prison;
    }

    @Override
    public CiEyeResponse respond(Request request) throws IOException {
        LandscapeObservation result = new LandscapeObservation();
        long timeToLiveMillis = Long.MAX_VALUE;
        for (Feature feature : landscape.features()) {
            final TargetGroupBriefing briefing = spyIntermediary.briefingOn(feature);
            result = result.add(briefing.status);
            timeToLiveMillis = min(timeToLiveMillis, briefing.millisecondsUntilNextUpdate);
        }
       
        if (prison.crimeReported(landscape)) {
            result = result.withDoh(prison.prisonersFor(landscape));
        }
       
        return CiEyeResponse.withJson(new JsonTranslator().toJson(result)).expiringInMillis(timeToLiveMillis);
    }
View Full Code Here

TOP

Related Classes of org.netmelody.cieye.core.domain.LandscapeObservation

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.