### Question:
LogSegmentNameParser implements FileWatcher.FileNameParser<LogSegment> { public LogSegment parse(Path path) { int UUID_LEN = 36; String segmentFileName = path.getFileName().toString(); if ("system.log".equals(segmentFileName) || "runner_system.log".equalsIgnoreCase(segmentFileName)) { return LogSegment.builder() .name("system") .build(); } if (!segmentFileName.endsWith(".log")) { log.warn("createSegment ['{}'] -> invalid segment file name: invalid extension", segmentFileName); return null; } if (segmentFileName.length() < UUID_LEN) { log.warn("createSegment ['{}'] -> invalid segment file name: no uuid", segmentFileName); return null; } try { UUID correlationId = UUID.fromString(segmentFileName.substring(0, UUID_LEN)); int taskNameStartAt = UUID_LEN + 1; int taskNameEndAt = segmentFileName.lastIndexOf('_'); if (taskNameEndAt < taskNameStartAt) { log.warn("createSegment ['{}'] -> invalid segment file name: no created at", segmentFileName); return null; } String segmentName = segmentFileName.substring(taskNameStartAt, taskNameEndAt); int createdAtStart = taskNameEndAt + 1; int createdAtEnd = segmentFileName.length() - ".log".length(); long createdAt = Long.parseLong(segmentFileName.substring(createdAtStart, createdAtEnd)); return LogSegment.builder() .correlationId(correlationId) .name(segmentName) .createdAt(new Date(createdAt)) .build(); } catch (Exception e) { log.warn("createSegment ['{}'] -> error: {}", segmentFileName, e.getMessage()); } return null; }  LogSegment parse(Path path);  }### Answer:
@Test public void testSuccess() { LogSegmentNameParser parser = new LogSegmentNameParser(); UUID correlationId = UUID.randomUUID(); String taskName = "test-task_Oo"; Date createdAt = new Date(); String fileName = correlationId + "-" + taskName + "_" + createdAt.getTime() + ".log"; LogSegment segment = parser.parse(Paths.get(fileName)); assertEquals(correlationId, segment.correlationId()); assertEquals(taskName, segment.name()); assertEquals(createdAt, segment.createdAt()); }