TaskLogsFilter extends Filter<ILoggingEvent> { @Override public FilterReply decide(final ILoggingEvent event) { Marker marker = event.getMarker(); if (PROGRESS.equals(marker)) { TaskLoggerHelper.progress(toTaskLoggerEvent(event)); } if (MDC.get(LOGBACK_TASK_DISCRIMINATOR_ID) == null) { return DENY; } if (NEXUS_LOG_ONLY.equals(marker) || INTERNAL_PROGRESS.equals(marker)) { return DENY; } return NEUTRAL; }  @Override FilterReply decide(final ILoggingEvent event);  }
@Test public void testNotATask() { MDC.remove(LOGBACK_TASK_DISCRIMINATOR_ID); assertThat(taskLogsFilter.decide(eventWithMarkerOf(null)), equalTo(DENY)); }
@Test public void testIsANexusLog() { startTask(); assertThat(taskLogsFilter.decide(eventWithMarkerOf(NEXUS_LOG_ONLY)), equalTo(DENY)); }
@Test public void testIsInternalProgress() { startTask(); assertThat(taskLogsFilter.decide(eventWithMarkerOf(INTERNAL_PROGRESS)), equalTo(DENY)); }
@Test public void testIsProgress() { startTask(); assertThat(taskLogsFilter.decide(eventWithMarkerOf(PROGRESS)), equalTo(NEUTRAL)); assertNotNull(TaskLoggerHelper.get()); ArgumentCaptor<TaskLoggingEvent> argumentCaptor = ArgumentCaptor.forClass(TaskLoggingEvent.class); verify(taskLogger).progress(argumentCaptor.capture()); TaskLoggingEvent taskLoggingEvent = argumentCaptor.getValue(); assertNotNull(taskLoggingEvent); assertThat(taskLoggingEvent.getMessage(), equalTo(TEST_MESSAGE)); assertThat(taskLoggingEvent.getArgumentArray(), equalTo(TEST_ARGS)); }
@Test public void testNotProgress() { startTask(); assertThat(taskLogsFilter.decide(eventWithMarkerOf(null)), equalTo(NEUTRAL)); assertNotNull(TaskLoggerHelper.get()); }