ApplicationStatus { private ApplicationStatus(final ApplicationInfo application, final ClusterInfo cluster, final SystemInfo system, final VersionInfo vcs, final TeamInfo team, final List<StatusDetail> details) { this.status = details.stream() .map(StatusDetail::getStatus) .reduce(Status.OK, Status::plus); this.statusDetails = unmodifiableList(new ArrayList<>(details)); this.application = application; this.cluster = cluster; this.system = system; this.vcs = vcs; this.team = team; } private  ApplicationStatus(final ApplicationInfo application,
                              final ClusterInfo cluster,
                              final SystemInfo system,
                              final VersionInfo vcs,
                              final TeamInfo team,
                              final List<StatusDetail> details); static ApplicationStatus applicationStatus(final ApplicationInfo applicationInfo,
                                                      final ClusterInfo clusterInfo,
                                                      final SystemInfo systemInfo,
                                                      final VersionInfo versionInfo,
                                                      final TeamInfo teamInfo,
                                                      final List<StatusDetail> details); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); final ApplicationInfo application; final SystemInfo system; final VersionInfo vcs; final TeamInfo team; final ClusterInfo cluster; final Status status; final List<StatusDetail> statusDetails; }
@Test public void shouldHaveStatusOkIfDetailsAreOk() { final ApplicationStatus applicationStatus = applicationStatus(mock(ApplicationInfo.class), null, mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), singletonList( statusDetail("bar", OK, "a message")) ); assertThat(applicationStatus.status, is(OK)); }
@Test public void shouldHaveStatusWarningIfDetailsContainWarnings() { final ApplicationStatus applicationStatus = applicationStatus(mock(ApplicationInfo.class), null, mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), asList( statusDetail("bar", OK, "a message"), statusDetail("foobar", WARNING, "another message")) ); assertThat(applicationStatus.status, is(WARNING)); }
@Test public void shouldHaveStatusErrorIfDetailsContainWarnings() { final ApplicationStatus applicationStatus = applicationStatus(mock(ApplicationInfo.class), null, mock(SystemInfo.class), mock(VersionInfo.class), mock(TeamInfo.class), asList( statusDetail("bar", OK, "a message"), statusDetail("foobar", ERROR, "another message"), statusDetail("foobar", WARNING, "yet another message")) ); assertThat(applicationStatus.status, is(ERROR)); }