TimestampPlugin extends Plugin { String generateTimestamp(int timestamp, ZoneId zoneId) { final ZonedDateTime time = ZonedDateTime.ofInstant( Instant.ofEpochSecond(timestamp), zoneId); return formatter.format(Date.from(time.toInstant())); }  @Provides TimestampConfig provideConfig(final ConfigManager configManager); @Subscribe void onConfigChanged(ConfigChanged event); @Subscribe void onScriptCallbackEvent(ScriptCallbackEvent event);  }
@Test public void testGenerateTimestamp() { when(config.timestampFormat()).thenReturn("[yyyy:MM:dd:HH:hh:mm:ss]"); ConfigChanged configChanged = new ConfigChanged(); configChanged.setGroup("timestamp"); configChanged.setKey("format"); configChanged.setNewValue("true"); plugin.onConfigChanged(configChanged); int testInput = 1554667116; String testOutput = "[2019:04:07:15:03:58:36]"; TimeZone timeZone = TimeZone.getTimeZone("America/New_York"); plugin.getFormatter().setTimeZone(timeZone); assertTrue(plugin.generateTimestamp(testInput, timeZone.toZoneId()).equals(testOutput)); }