1 | package geniusweb.logconverter;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertEquals;
|
---|
4 | import static org.junit.Assert.assertTrue;
|
---|
5 |
|
---|
6 | import java.io.File;
|
---|
7 | import java.io.IOException;
|
---|
8 | import java.nio.file.Files;
|
---|
9 | import java.util.List;
|
---|
10 | import java.util.logging.Level;
|
---|
11 |
|
---|
12 | import org.junit.Test;
|
---|
13 |
|
---|
14 | import com.fasterxml.jackson.core.JsonParseException;
|
---|
15 | import com.fasterxml.jackson.databind.JsonMappingException;
|
---|
16 |
|
---|
17 | public class ConvertTest {
|
---|
18 | TestReporter reporter = new TestReporter();
|
---|
19 |
|
---|
20 | @Test
|
---|
21 | public void e2esmoketest() {
|
---|
22 | Convert.main(new String[] { "-s",
|
---|
23 | "src/test/resources/APP1646925947841local.json", "-f", "CSV" });
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Test
|
---|
27 | public void e2eTest()
|
---|
28 | throws JsonParseException, JsonMappingException, IOException {
|
---|
29 | new Convert(new File("src/test/resources/APP1646925947841local.json"),
|
---|
30 | Level.WARNING, null, Convert.Format.CSV, reporter);
|
---|
31 | assertEquals(null, reporter.getError());
|
---|
32 | }
|
---|
33 |
|
---|
34 | @Test
|
---|
35 | public void e2eToFile() throws IOException {
|
---|
36 | File outfile = File.createTempFile("temp", "csv");
|
---|
37 | outfile.delete();
|
---|
38 | new Convert(new File("src/test/resources/APP1646925947841local.json"),
|
---|
39 | Level.WARNING, outfile, Convert.Format.CSV, reporter);
|
---|
40 | assertEquals(null, reporter.getError());
|
---|
41 | List<String> lines = Files.readAllLines(outfile.toPath());
|
---|
42 | assertEquals(37, lines.size());
|
---|
43 | lines.remove(0); // remove header line.
|
---|
44 | int row = 0;
|
---|
45 | for (String line : lines) {
|
---|
46 | String[] cols = line.split(",");
|
---|
47 | Integer session = Integer.valueOf(cols[0]);
|
---|
48 | assertEquals((Integer) (row / 2), session);
|
---|
49 | assertTrue(Double.valueOf(cols[3]) > 0); // all utils valid
|
---|
50 | row++;
|
---|
51 | }
|
---|
52 | outfile.delete();
|
---|
53 | }
|
---|
54 |
|
---|
55 | } |
---|