InputTimeZoneManager { public static String getTimezone(String sourceId) throws AdeException { final DateTime dateTime = s_sourceToTimeZoneMap.get(sourceId); if (dateTime != null) { final long offsetInMillis = dateTime.getZone().getOffset(dateTime.getMillis()); String timeZoneString = String.format("%02d:%02d", Math.abs(offsetInMillis / MILLIS_IN_HOUR), Math.abs((offsetInMillis / MILLIS_IN_MINUTE) % EXCESS_MINUTES)); if (offsetInMillis < 0) { timeZoneString = "GMT-" + timeZoneString; } else { timeZoneString = "GMT+" + timeZoneString; } return timeZoneString; } else { if (s_configuredInputTimeZone == null) { try { final IAdeConfigProperties config = Ade.getAde().getConfigProperties(); s_configuredInputTimeZone = config.getInputTimeZone().getID(); } catch (Exception e) { throw new AdeInternalException("Unexpected Exception getting Input TimeZone from Ade", e); } } return s_configuredInputTimeZone; } } private  InputTimeZoneManager(); static void updateTimezone(String sourceId, DateTime dateTime); static String getTimezone(String sourceId); static final long SECONDS_IN_MINUTE; static final long MINUTES_IN_HOUR; static final long EXCESS_MINUTES; static final long MILLIS_IN_SECOND; static final long MILLIS_IN_MINUTE; static final long MILLIS_IN_HOUR; }
@Test public void TestGetTimezoneWithNullDateAndNonNullConfig() throws AdeException{ InputTimeZoneManager.s_configuredInputTimeZone = "1"; assertEquals("getTimezone null date but not a null configuredInputTimezone ","1", InputTimeZoneManager.getTimezone(null)); }
@Test(expected = AdeException.class) public void TestGetTimezoneWithNullSourceID() throws AdeException{ assertEquals("getTimezone null sourceID ","",InputTimeZoneManager.getTimezone(null)); }