PartitionSpec { public String interpret(String input) { switch (this.interpreter) { case STRING: return getFormattedString(input); case STATIC: return this.format; default: return getFormattedTime(input); } } PartitionSpec();  PartitionSpec(String name, List<String> sources, Interpreter interpreter, String format,
      int secondsToRound);  PartitionSpec(String name, List<String> sources, Interpreter interpreter);  PartitionSpec(String name, List<String> sources);  PartitionSpec(String name, String... sources); String getName(); List<String> getSources(); Interpreter getInterpreter(); StringFormat getStringFormat(); void setStringFormat(StringFormat format); void setFormat(String format); String getFormat(); String interpret(String input); String toString();  }
@Test public void testEmptyDate() { PartitionSpec spec = new PartitionSpec("test", Collections.emptyList(), Interpreter.SECONDS, "YYYY-MM-dd HH:mm:ss", 0); assertEquals(null, spec.interpret("")); assertEquals(null, spec.interpret(null)); }
@Test public void testDateFormatterSeconds() { PartitionSpec spec = new PartitionSpec("test", Collections.emptyList(), Interpreter.SECONDS, "YYYY-MM-dd HH:mm:ss", 0); assertEquals("2017-01-19 05:05:59", spec.interpret("1484802359")); }
@Test public void testDateFormatterMilliseconds() { PartitionSpec spec = new PartitionSpec("test", Collections.emptyList(), Interpreter.MILLISECONDS, "YYYY-MM-dd HH:mm:ss", 0); assertEquals("2017-01-19 05:05:59", spec.interpret("1484802359000")); }
@Test public void testRoundToSeconds() { PartitionSpec spec = new PartitionSpec("test", Collections.emptyList(), Interpreter.MILLISECONDS, "YYYY-MM-dd HH:mm:ss", 300); assertEquals("2017-01-19 05:05:00", spec.interpret("1484802359000")); }
@Test public void testStatic() { PartitionSpec spec = new PartitionSpec("test", Collections.emptyList(), Interpreter.STATIC, "static", 0); assertEquals("static", spec.interpret("")); }
@Test public void testString() { PartitionSpec spec = new PartitionSpec("test", Collections.emptyList(), Interpreter.STRING, "string", 0); assertEquals("a_string", spec.interpret("a_string")); }
@Test public void testStringConstructor() { PartitionSpec spec = new PartitionSpec("test", Collections.emptyList()); assertEquals("a_string", spec.interpret("a_string")); }