@Override public void setSystemProperties(final Map<String, String> preferences) { setSystemProperty(preferences, ApplicationPreferences.DATE_FORMAT); setSystemProperty(preferences, ApplicationPreferences.DATE_TIME_FORMAT); setSystemProperty(preferences, ApplicationPreferences.DEFAULT_LANGUAGE); setSystemProperty(preferences, ApplicationPreferences.DEFAULT_COUNTRY); setSystemProperty(preferences, KeyStoreConstants.PROP_SIGN); setSystemProperty(preferences, KeyStoreConstants.PROP_PVT_KS_URL); setSystemProperty(preferences, KeyStoreConstants.PROP_PVT_KS_PWD); setSystemProperty(preferences, KeyStoreConstants.PROP_PVT_ALIAS); setSystemProperty(preferences, KeyStoreConstants.PROP_PVT_PWD); setSystemProperty(preferences, KeyStoreConstants.PROP_PUB_KS_URL); setSystemProperty(preferences, KeyStoreConstants.PROP_PUB_KS_PWD); }
@Override public Map<String, String> load() { final Map<String, String> preferences = new HashMap<String, String>(); addSystemProperty( preferences, ApplicationPreferences.DATE_FORMAT ); addSystemProperty( preferences, ApplicationPreferences.DATE_TIME_FORMAT ); addSystemProperty( preferences, ApplicationPreferences.DEFAULT_LANGUAGE ); addSystemProperty( preferences, ApplicationPreferences.DEFAULT_COUNTRY ); // For security Serialization we DO NOT want to set any default // as those can be set through other means and we don't want // to override or mess with that return preferences; }
private int getOffset() { final TimeZone timeZone = getTimeZone(); return timeZone.getOffset(0); }
@Test public void testGetTimeZoneWhenTimeZoneIsAmericaSaoPaulo() { doReturn("America/Sao_Paulo").when(loader).getSystemPropertyTimeZone(); assertEquals("-10800000", getLoaderOffset()); }
private TimeZone getTimeZone() { final String timezone = getSystemPropertyTimeZone(); if (timezone == null || timezone.isEmpty()) { return TimeZone.getDefault(); } else { return TimeZone.getTimeZone(timezone); } }
@Override public Map<String, String> load() { final Map<String, String> preferences = new HashMap<String, String>(); preferences.put( KIE_VERSION_PROPERTY_NAME, getKieVersion() ); return preferences; }
@Override public Map<String, String> load() { final Map<String, String> preferences = new HashMap<>(); final int offset = getOffset(); final String offsetValue = Integer.toString(offset); preferences.put(ApplicationPreferences.KIE_TIMEZONE_OFFSET, offsetValue); return preferences; }
private String getLoaderOffset() { final Map<String, String> preferences = loader.load(); return preferences.get(KIE_TIMEZONE_OFFSET); } }
@Before public void setup() { loader = new KieMetaDataPreferencesLoader(); }
@Before public void setup() { loader = spy(new KieTimeZonePreferencesLoader()); }
@Test public void testLoad() { final Map<String, String> preferences = loader.load(); assertNotNull( preferences ); assertEquals( KieMeta.isProductized(), Boolean.parseBoolean( preferences.get( ApplicationPreferences.KIE_PRODUCTIZED ) ) ); }
@Test public void testGetTimeZoneWhenTimeZoneIsHST() { doReturn("HST").when(loader).getSystemPropertyTimeZone(); assertEquals("-36000000", getLoaderOffset()); }
@Test public void testGetTimeZoneWhenTimeZoneIsNotSet() { doReturn("").when(loader).getSystemPropertyTimeZone(); final TimeZone timeZone = mock(TimeZone.class); final int expectedOffset = 36000000; mockStatic(TimeZone.class); when(TimeZone.getDefault()).thenReturn(timeZone); when(timeZone.getOffset(anyInt())).thenReturn(expectedOffset); assertEquals(String.valueOf(expectedOffset), getLoaderOffset()); }