ExternalResources { @SuppressWarnings("ConstantConditions") public static ExternalResources initialize( @NonNull Context context, Url url) { if (null == context) { throw new IllegalArgumentException("Context must not be null."); } if (null == url) { throw new IllegalArgumentException("Path must not be null."); } synchronized (ExternalResources.class) { if (null != singleton) { throw new IllegalStateException("Singleton instance already exists."); } singleton = new Builder(context, url).build(); } return singleton; } private  ExternalResources(@NonNull Context context, @NonNull Converter converter,
      @NonNull Url url, @NonNull Options options, @Cache.Policy int cachePolicy,
      @Logger.Level int logLevel, @NonNull Resources defaultResources,
      @Nullable OnExternalResourcesLoadFailedListener failedListener,
      boolean useApplicationResources); @SuppressWarnings("ConstantConditions") static ExternalResources initialize(
      @NonNull Context context, Url url); @SuppressWarnings("ConstantConditions") static ExternalResources initialize(
      @NonNull Context context, @NonNull String baseUrl); @SuppressWarnings("ConstantConditions") static ExternalResources initialize(
      @NonNull ExternalResources externalResources); static ExternalResources getInstance(); void onConfigurationChanged(Configuration newConfig); boolean getBoolean(@BoolRes int resId); boolean getBoolean(@NonNull String key); @ColorInt int getColor(@ColorRes int resId); @ColorInt int getColor(@NonNull String key); float getDimension(@DimenRes int resId); float getDimension(@NonNull String key); String getString(@StringRes int resId); String getString(@NonNull String key); String getString(@StringRes int resId, Object... formatArgs); String getString(@NonNull String key, Object... formatArgs); String[] getStringArray(@ArrayRes int resId); String[] getStringArray(@NonNull String key); int getInteger(@IntegerRes int resId); int getInteger(@NonNull String key); int[] getIntArray(@ArrayRes int resId); int[] getIntArray(@NonNull String key); void register(OnExternalResourcesChangeListener listener); void unregister(OnExternalResourcesChangeListener listener); void removeFailListener(); static final String TAG; }
@Test(expected = IllegalArgumentException.class) public void testInitializeWithExternalResourcesWithNull() { ExternalResources.singleton = null; ExternalResources.initialize(null); }
@Test(expected = IllegalStateException.class) public void testInitializeWithExternalResourcesAlreadyInitialize() { ExternalResources.singleton = null; ExternalResources.initialize(externalResources); ExternalResources.initialize(externalResources); }
@Test public void testInitializeWithPath() throws Exception { ExternalResources.singleton = null; assertNotNull(ExternalResources.initialize(context, "/")); }
@Test(expected = IllegalArgumentException.class) public void testInitializeWithPathWoContext() throws Exception { ExternalResources.singleton = null; assertNotNull(ExternalResources.initialize(null, "/")); }
@Test(expected = IllegalArgumentException.class) public void testInitializeWithPathWoPath() throws Exception { ExternalResources.singleton = null; assertNotNull(ExternalResources.initialize(context, (String) null)); }
@Test(expected = IllegalStateException.class) public void testInitializeWitPathAlreadyInitialize() { ExternalResources.singleton = null; ExternalResources.initialize(context, "/"); ExternalResources.initialize(context, "/"); }
@Test public void testInitializeWithUrl() throws Exception { ExternalResources.singleton = null; assertNotNull(ExternalResources.initialize(context, new DefaultUrl("/"))); }
@Test(expected = IllegalArgumentException.class) public void testInitializeWithUrlWoContext() throws Exception { ExternalResources.singleton = null; assertNotNull(ExternalResources.initialize(null, new DefaultUrl("/"))); }
@Test(expected = IllegalArgumentException.class) public void testInitializeWithUrlWoPath() throws Exception { ExternalResources.singleton = null; assertNotNull(ExternalResources.initialize(context, (DefaultUrl) null)); }
@Test(expected = IllegalStateException.class) public void testInitializeWitUrlAlreadyInitialize() { ExternalResources.singleton = null; ExternalResources.initialize(context, new DefaultUrl("/")); ExternalResources.initialize(context, new DefaultUrl("/")); }