@Test
public void testThatParsingWorks() 
        throws IOException, IllegalArgumentException, JSONException {

    byte[] b = null;
    try (InputStream in = this.getClass()
            .getResourceAsStream("view-to-import.json")) {
        b = IOHelper.readBytes(in);
    }
    if (b == null || b.length == 0) {
        fail("Failed to read view-to-import.json");
        return;
    }
    String jsonStr = new String(b, StandardCharsets.UTF_8);
    JSONObject viewJSON = new JSONObject(jsonStr);
    // The values should match the ones in view-to-import.json
    // We must register "foobar" Bundle to the BundleService beforehand
    Bundle foobar = new Bundle();
    foobar.setName("foobar");
    bundleService.addBundleTemplate(foobar);
    View view = ViewHelper.viewFromJson(bundleService, viewJSON);
    assertEquals("Default view", view.getName());
    assertEquals("DEFAULT", view.getType());
    assertEquals(true, view.isDefault());
    assertEquals(true, view.isPublic());
    assertEquals(false, view.isOnlyForUuId());
    assertEquals("servlet", view.getApplication());
    assertEquals("index", view.getPage());
    List<Bundle> bundles = view.getBundles();
    assertNotNull(bundles);
    assertEquals(1, bundles.size());
    assertEquals(foobar.getName(), bundles.get(0).getName());
}