### Question:
ImportExportJsonHelper { public static List<SubscriptionItem> readFrom( final InputStream in, @Nullable final ImportExportEventListener eventListener) throws InvalidSourceException { if (in == null) { throw new InvalidSourceException("input is null"); } final List<SubscriptionItem> channels = new ArrayList<>(); try { final JsonObject parentObject = JsonParser.object().from(in); if (!parentObject.has(JSON_SUBSCRIPTIONS_ARRAY_KEY)) { throw new InvalidSourceException("Channels array is null"); } final JsonArray channelsArray = parentObject.getArray(JSON_SUBSCRIPTIONS_ARRAY_KEY); if (eventListener != null) { eventListener.onSizeReceived(channelsArray.size()); } for (Object o : channelsArray) { if (o instanceof JsonObject) { JsonObject itemObject = (JsonObject) o; int serviceId = itemObject.getInt(JSON_SERVICE_ID_KEY, 0); String url = itemObject.getString(JSON_URL_KEY); String name = itemObject.getString(JSON_NAME_KEY); if (url != null && name != null && !url.isEmpty() && !name.isEmpty()) { channels.add(new SubscriptionItem(serviceId, url, name)); if (eventListener != null) { eventListener.onItemCompleted(name); } } } } } catch (Throwable e) { throw new InvalidSourceException("Couldn't parse json", e); } return channels; } private  ImportExportJsonHelper(); static List<SubscriptionItem> readFrom(
            final InputStream in, @Nullable final ImportExportEventListener eventListener); static void writeTo(final List<SubscriptionItem> items, final OutputStream out,
                               @Nullable final ImportExportEventListener eventListener); static void writeTo(final List<SubscriptionItem> items, final JsonSink writer,
                               @Nullable final ImportExportEventListener eventListener);  }### Answer:
@Test public void testEmptySource() throws Exception { String emptySource = "{\"app_version\":\"0.11.6\",\"app_version_int\": 47,\"subscriptions\":[]}"; List<SubscriptionItem> items = ImportExportJsonHelper.readFrom(new ByteArrayInputStream( emptySource.getBytes(StandardCharsets.UTF_8)), null); assertTrue(items.isEmpty()); }
@Test public void testInvalidSource() { List<String> invalidList = Arrays.asList( "{}", "", null, "gibberish"); for (String invalidContent : invalidList) { try { if (invalidContent != null) { byte[] bytes = invalidContent.getBytes(StandardCharsets.UTF_8); ImportExportJsonHelper.readFrom((new ByteArrayInputStream(bytes)), null); } else { ImportExportJsonHelper.readFrom(null, null); } fail("didn't throw exception"); } catch (Exception e) { boolean isExpectedException = e instanceof SubscriptionExtractor.InvalidSourceException; assertTrue("\"" + e.getClass().getSimpleName() + "\" is not the expected exception", isExpectedException); } } }