TaskLoggerFactory { public static TaskLogger create(final Object taskObject, final Logger log, final TaskLogInfo taskLogInfo) { TaskLogging taskLogging = taskObject.getClass().getAnnotation(TaskLogging.class); if (taskLogging == null) { taskLogging = TaskLoggingDefault.class.getAnnotation(TaskLogging.class); } switch (taskLogging.value()) { case NEXUS_LOG_ONLY: return new ProgressTaskLogger(log); case TASK_LOG_ONLY: return new TaskLogOnlyTaskLogger(log, taskLogInfo); case TASK_LOG_ONLY_WITH_PROGRESS: return new TaskLogWithProgressLogger(log, taskLogInfo); case BOTH: default: return new SeparateTaskLogTaskLogger(log, taskLogInfo); } } private  TaskLoggerFactory(); static TaskLogger create(final Object taskObject, final Logger log, final TaskLogInfo taskLogInfo);  }
@Test public void testBoth() { TaskLogger taskLogger = TaskLoggerFactory.create(new Both(), mock(Logger.class), mock(TaskLogInfo.class)); assertThat(taskLogger, instanceOf(SeparateTaskLogTaskLogger.class)); }
@Test public void testTaskLogOnly() { TaskLogger taskLogger = TaskLoggerFactory.create(new TaskLogOnly(), mock(Logger.class), mock(TaskLogInfo.class)); assertThat(taskLogger, instanceOf(TaskLogOnlyTaskLogger.class)); }
@Test public void testTaskLogWithProgress() { TaskLogger taskLogger = TaskLoggerFactory.create(new TaskLogWithProgress(), mock(Logger.class), mock(TaskLogInfo.class)); assertThat(taskLogger, instanceOf(TaskLogWithProgressLogger.class)); }
@Test public void testNexusLogOnly() { TaskLogger taskLogger = TaskLoggerFactory.create(new NexusLogOnly(), mock(Logger.class), mock(TaskLogInfo.class)); assertThat(taskLogger, instanceOf(ProgressTaskLogger.class)); }
@Test public void testDefault() { TaskLogger taskLogger = TaskLoggerFactory.create(new Object(), mock(Logger.class), mock(TaskLogInfo.class)); assertThat(taskLogger, instanceOf(SeparateTaskLogTaskLogger.class)); }