public static Matcher<ServerHealthService> containsState(final HealthStateType type) { return containsState(type, null, null); }
@Test public void shouldAddMultipleLogToServerHealth() throws Exception { assertThat(serverHealthService.update(ServerHealthState.error("message", "description", globalId)), is(globalId)); assertThat(serverHealthService.update(ServerHealthState.error("message", "description", pipelineId)), is(pipelineId)); assertThat(serverHealthService.logs().size(), is(2)); assertThat(serverHealthService, ServerHealthMatcher.containsState(globalId)); assertThat(serverHealthService, ServerHealthMatcher.containsState(pipelineId)); }
@Test public void shouldRemoveLogWhenUpdateIsFine() throws Exception { serverHealthService.update(ServerHealthState.error("message", "description", globalId)); assertThat(serverHealthService, ServerHealthMatcher.containsState(globalId)); assertThat(serverHealthService.update(ServerHealthState.success(globalId)), is(nullValue())); assertThat(serverHealthService, doesNotContainState(globalId)); }
@Test public void shouldUpdateLogInServerHealth() throws Exception { ServerHealthState serverHealthState = ServerHealthState.error("message", "description", globalId); serverHealthService.update(serverHealthState); ServerHealthState newServerHealthState = ServerHealthState.error("updated message", "updated description", globalId); serverHealthService.update(newServerHealthState); assertThat(serverHealthService.logs().size(), is(1)); assertThat(serverHealthService, ServerHealthMatcher.containsState(globalId, HealthStateLevel.ERROR, "updated message")); }
@Test public void shouldRemoveLogByCategoryFromServerHealth() throws Exception { HealthStateScope scope = forPipeline(PIPELINE_NAME); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(scope))); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.invalidLicense(scope))); serverHealthService.update(ServerHealthState.error("message", "description", globalId)); assertThat(serverHealthService.logs().size(), is(3)); serverHealthService.removeByScope(scope); assertThat(serverHealthService.logs().size(), is(1)); assertThat(serverHealthService, ServerHealthMatcher.containsState(globalId)); }