TswFactory { @NonNull abstract public List<TswSeries> loadFile(@NonNull Path file) throws IOException;  @NonNull abstract TswSource load(@NonNull Path repository); @NonNull abstract List<TswSeries> loadFile(@NonNull Path file); @NonNull static TswFactory getDefault();  }
@Test public void testEmptyFile() throws URISyntaxException, IOException { Path file = getResource("EmptyFile"); for (TswFactory factory : asList(oldFactory, newFactory)) { List<TswSeries> items = factory.loadFile(file); assertTrue(items.isEmpty()); } }
@Test public void testMultiObsPerLine() throws URISyntaxException, IOException { Path file = getResource("MultiObsPerLine"); for (TswFactory factory : asList(oldFactory, newFactory)) { List<TswSeries> items = factory.loadFile(file); assertEquals(1, items.size()); TswSeries single = items.get(0); assertEquals("EXPORTS (Spain)", single.name); assertEquals(new TsDomain(TsFrequency.Monthly, 1976, 0, 155), single.data.get().getDomain()); } }
@Test public void testMultiTs() throws URISyntaxException, IOException { List<TswSeries> items = newFactory.loadFile(getResource("MultiTs")); assertEquals(16, items.size()); TswSeries first = items.get(0); assertEquals("1 s0b44000.e2", first.name); assertEquals(192, first.data.get().getLength()); assertEquals(TsFrequency.Monthly, first.data.get().getFrequency()); TswSeries last = items.get(15); assertEquals("16 s0b72200.e2", last.name); assertEquals(192, last.data.get().getLength()); assertEquals(TsFrequency.Monthly, last.data.get().getFrequency()); }
@Test public void testNanObs() throws URISyntaxException, IOException { Path file = getResource("NanObs"); for (TswFactory factory : asList(oldFactory, newFactory)) { List<TswSeries> items = factory.loadFile(file); assertEquals(1, items.size()); TswSeries single = items.get(0); assertEquals("ipiSPAIN", single.name); assertEquals(new TsDomain(TsFrequency.Monthly, 1983, 1, 158), single.data.get().getDomain()); assertEquals(158 - 4, single.data.get().getObsCount()); assertEquals(Double.NaN, single.data.get().get(4), 0); } }
@Test public void testSingleTs() throws URISyntaxException, IOException { Path file = getResource("SingleTs"); for (TswFactory factory : asList(oldFactory, newFactory)) { List<TswSeries> items = factory.loadFile(file); assertEquals(1, items.size()); TswSeries single = items.get(0); assertEquals("Monetary Aggregate ALP (Spain)", single.name); assertEquals(new TsDomain(TsFrequency.Monthly, 1972, 0, 234), single.data.get().getDomain()); } }
@Test(expected = IOException.class) public void testBinFile() throws URISyntaxException, IOException { Path file = getResource("blog_16x16.png"); for (TswFactory factory : asList(oldFactory, newFactory)) { factory.loadFile(file); } }
@Test public void testEmptyLines() throws URISyntaxException, IOException { Path file = getResource("EmptyLines"); for (TswFactory factory : asList(oldFactory, newFactory)) { List<TswSeries> items = factory.loadFile(file); assertEquals(1, items.size()); } }