### Question:
LogUtils { @SuppressWarnings("unchecked") private static String getTaskLogPath(int processDefinitionId, int processInstanceId, int taskInstanceId) { return Optional.of(LoggerFactory.getILoggerFactory()) .map(e -> (AppenderAttachable<ILoggingEvent>) (e.getLogger("ROOT"))) .map(e -> (SiftingAppender) (e.getAppender("TASKLOGFILE"))) .map(e -> ((TaskLogDiscriminator) (e.getDiscriminator()))) .map(TaskLogDiscriminator::getLogBase) .map(e -> Paths.get(e) .toAbsolutePath() .resolve(String.valueOf(processDefinitionId)) .resolve(String.valueOf(processInstanceId)) .resolve(taskInstanceId + ".log")) .map(Path::toString) .orElse(""); } private  LogUtils(); static String getTaskLogPath(TaskInstance taskInstance); static String getTaskLogPath(TaskExecutionContext taskExecutionContext);  }### Answer:
@Test public void testGetTaskLogPath() { TaskInstance taskInstance = new TaskInstance(); taskInstance.setProcessDefinitionId(1); taskInstance.setProcessInstanceId(100); taskInstance.setId(1000); Logger rootLogger = (Logger) LoggerFactory.getILoggerFactory().getLogger("ROOT"); Assert.assertNotNull(rootLogger); SiftingAppender appender = Mockito.mock(SiftingAppender.class); Mockito.when(appender.getName()).thenReturn("TASKLOGFILE"); rootLogger.addAppender(appender); Path logBase = Paths.get("path").resolve("to").resolve("test"); TaskLogDiscriminator taskLogDiscriminator = Mockito.mock(TaskLogDiscriminator.class); Mockito.when(taskLogDiscriminator.getLogBase()).thenReturn(logBase.toString()); Mockito.when(appender.getDiscriminator()).thenReturn(taskLogDiscriminator); Path logPath = Paths.get(".").toAbsolutePath().getParent() .resolve(logBase) .resolve("1").resolve("100").resolve("1000.log"); Assert.assertEquals(logPath.toString(), LogUtils.getTaskLogPath(taskInstance)); }