StatusRepresentation { public static StatusRepresentation statusRepresentationOf(final ApplicationStatus status) { return new StatusRepresentation(status, null, null); } private  StatusRepresentation(final ApplicationStatus applicationStatus,
                                 final Criticality criticality,
                                 final List<ExternalDependency> dependencies); static StatusRepresentation statusRepresentationOf(final ApplicationStatus status); static StatusRepresentation statusRepresentationOf(final ApplicationStatus status,
                                                              final Criticality criticality,
                                                              final List<ExternalDependency> dependencies); public ApplicationRepresentation application; public ClusterInfo cluster; public SystemInfo system; public TeamInfo team; public Criticality criticality; public List<DependencyRepresentation> dependencies; }
@Test public void shouldCreateStatusRepresentationWithoutDetails() { EdisonApplicationProperties edisonApplicationProperties = edisonApplicationProperties("Some Title", "group", "local-env", "desc"); final StatusRepresentation json = statusRepresentationOf( applicationStatus(applicationInfo("app-name", edisonApplicationProperties), mock(ClusterInfo.class), mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), emptyList()) ); assertThat(json.application.name, is("app-name")); assertThat(json.application.title, is("Some Title")); assertThat(json.application.status, is(OK)); assertThat(json.application.statusDetails.size(), is(0)); }
@Test public void shouldCreateStatusRepresentationWithVersionInfo() { final StatusRepresentation json = statusRepresentationOf( applicationStatus(mock(ApplicationInfo.class), mock(ClusterInfo.class), mock(SystemInfo.class), VersionInfo.versionInfo(versionInfoProperties("1.0.0", "0815", "http: ); assertThat(json.application.version, is("1.0.0")); assertThat(json.application.commit, is("0815")); assertThat(json.application.vcsUrl, is("http: }
@Test public void shouldCreateStatusRepresentationWithClusterInfo() { final ClusterInfo cluster = clusterInfo("BLU", "active"); final StatusRepresentation json = statusRepresentationOf( applicationStatus(mock(ApplicationInfo.class), cluster, mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), emptyList()) ); assertThat(json.cluster.getColor(), is("BLU")); assertThat(json.cluster.getColorState(), is("active")); }
@Test public void shouldCreateStatusRepresentationWithoutClusterInfo() { final ClusterInfo cluster = clusterInfo("", ""); final StatusRepresentation json = statusRepresentationOf( applicationStatus(mock(ApplicationInfo.class), cluster, mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), emptyList()) ); assertThat(json.cluster, is(nullValue())); }
@Test public void shouldCreateStatusRepresentationWithSingleDetail() { final StatusRepresentation json = statusRepresentationOf( applicationStatus(mock(ApplicationInfo.class), mock(ClusterInfo.class), mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), singletonList( statusDetail("someDetail", WARNING, "detailed warning")) ) ); assertThat(json.application.status, is(WARNING)); @SuppressWarnings("unchecked") final Map<String, String> someDetail = (Map) json.application.statusDetails.get("someDetail"); assertThat(someDetail.get("status"), is("WARNING")); assertThat(someDetail.get("message"), is("detailed warning")); assertThat(someDetail.get("link"), is(nullValue())); }
@Test public void shouldCreateStatusRepresentationWithDetailInclUrl() { final StatusRepresentation json = statusRepresentationOf( applicationStatus( mock(ApplicationInfo.class), mock(ClusterInfo.class), mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), singletonList( statusDetail("someDetail", OK, "some message", link("item", "http: ) ) ); assertThat(json.application.status, is(OK)); final JsonMap jsonMap = jsonMapFrom(json.application.statusDetails.get("someDetail")); final JsonMap link = jsonMap.get("links").asListOf(JsonMap.class).get(0); assertThat(link.getString("href"), is("http: assertThat(link.getString("title"), is("some title")); assertThat(link.getString("rel"), is("item")); }
@Test public void shouldCreateStatusRepresentationWithMultipleDetails() { final Map<String, String> detailMap = new HashMap<>(); detailMap.put("Count", "1000"); final StatusRepresentation json = statusRepresentationOf( applicationStatus(mock(ApplicationInfo.class), mock(ClusterInfo.class), mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), asList( statusDetail("Some Detail", OK, "perfect"), statusDetail("Some Other Detail", WARNING, "detailed warning", detailMap)) ) ); assertThat(json.application.status, is(WARNING)); @SuppressWarnings("unchecked") final Map<String, String> someDetail = (Map) json.application.statusDetails.get("someDetail"); assertThat(someDetail.get("status"), is("OK")); assertThat(someDetail.get("message"), is("perfect")); assertThat(someDetail.get("status"), is("OK")); @SuppressWarnings("unchecked") final Map<String, String> someOtherDetail = (Map) json.application.statusDetails.get("someOtherDetail"); assertThat(someOtherDetail.get("status"), is("WARNING")); assertThat(someOtherDetail.get("message"), is("detailed warning")); assertThat(someOtherDetail.get("count"), is("1000")); }