FileHelper { public static Configuration loadDefaultSettings(Context context) { try { return readConfigFile(context, "settings.json", true); } catch (Exception e) { Toast.makeText(context, context.getString(R.string.cannot_load_default_config, e.getLocalizedMessage()), Toast.LENGTH_LONG).show(); return null; } }  static InputStream openRead(Context context, String filename); static OutputStream openWrite(Context context, String filename); static Configuration loadCurrentSettings(Context context); static Configuration loadPreviousSettings(Context context); static Configuration loadDefaultSettings(Context context); static void writeSettings(Context context, Configuration config); static File getItemFile(Context context, Configuration.Item item); static InputStreamReader openItemFile(Context context, Configuration.Item item); static int poll(StructPollfd[] fds, int timeout); static FileDescriptor closeOrWarn(FileDescriptor fd, String tag, String message); static T closeOrWarn(T fd, String tag, String message);  }
@Test @PrepareForTest({Configuration.class}) public void testLoadDefaultSettings() throws Exception { InputStream mockInStream = mock(InputStream.class); Configuration mockConfig = mock(Configuration.class); when(mockAssets.open(anyString())).thenReturn(mockInStream); when(mockContext.getAssets()).thenReturn(mockAssets); mockStatic(Configuration.class); doReturn(mockConfig).when(Configuration.class, "read", any(Reader.class)); assertSame(mockConfig, FileHelper.loadDefaultSettings(mockContext)); Mockito.verify(mockAssets.open(anyString())); }