@@ -0,0 +1,2420 @@
+package no.cantara.jau.eventextraction;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.AfterClass;%0Aimport org.testng.annotations.BeforeClass;%0Aimport org.testng.annotations.Test;%0A%0Aimport java.io.*;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Paths;%0Aimport java.util.List;%0A%0Apublic class EventExtractorTest %7B%0A    private static final Logger log = LoggerFactory.getLogger(EventExtractorTest.class);%0A    private final static String LOG_FILE_PATH = %22event-extractor-test-log-file.log%22;%0A%0A    private String regularLogLine;%0A    private String errorLogLine;%0A    private String mdcLogLine;%0A%0A    @BeforeClass%0A    public void createFileWithEvents() throws IOException %7B%0A        File logFile = Files.createFile(Paths.get(LOG_FILE_PATH)).toFile();%0A%0A        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(%0A                new FileOutputStream(logFile), %22utf-8%22))) %7B%0A            regularLogLine = %2217:16:26.828 %5Bmain%5D TRACE n.n.pharmacy.config.ApplicationMode - isDemoMode: false%22;%0A            errorLogLine = %2212:34:45.035 %5Bpool-1-thread-1%5D ERROR n.c.jau.coms.CheckForUpdateHelper - checkForUpdate failed, do nothing. Retrying in 60 seconds.%22;%0A            mdcLogLine = %2213:28:13.343 this-is-an-mdc-tag %5Bpool-1-thread-1%5D DEBUG no.cantara.jau.JavaAutoUpdater - Checking if process is running...%22;%0A%0A            writer.write(regularLogLine);%0A            writer.newLine();%0A            writer.write(errorLogLine);%0A            writer.newLine();%0A            writer.write(mdcLogLine);%0A        %7D%0A    %7D%0A%0A    @AfterClass%0A    public void deleteTestFile() throws IOException %7B%0A        Files.delete(Paths.get(LOG_FILE_PATH));%0A    %7D%0A%0A    @Test%0A    public void shouldExtractEventsBasedOnTags() %7B%0A        EventRepo repo = new EventRepo();%0A        EventExtractor extractor = new EventExtractor(repo, %22this-is-an-mdc-tag%22, LOG_FILE_PATH);%0A%0A        extractor.run();%0A%0A        List%3CNumberedLine%3E eventsExtracted = repo.getEvents();%0A        Assert.assertEquals(eventsExtracted.size(), 2);%0A%0A        String event1 = eventsExtracted.get(0).getLine();%0A        String event2 = eventsExtracted.get(1).getLine();%0A        boolean shouldHaveBeenExtracted = (event1.equals(errorLogLine) %7C%7C event1%0A                .equals(mdcLogLine)) && (event2.equals(errorLogLine) %7C%7C event2%0A                .equals(mdcLogLine));%0A%0A        Assert.assertTrue(shouldHaveBeenExtracted);%0A    %7D%0A%7D%0A

Test for event extraction