@Test
public void testAppAsJsonStringWithView() {

  final Application app = new Application("com.acme", "foo", "0.1");
  final Library lib = new Library("digest-123");
  lib.setDigestAlgorithm(DigestAlgorithm.SHA256);
  final Set<Property> props = new HashSet<Property>();
  props.add(new Property(PropertySource.JAVA_MANIFEST, "foo-prop", "bar-prop"));
  lib.setProperties(props);
  final Set<ConstructId> cons = new HashSet<ConstructId>();
  cons.add(new ConstructId(ProgrammingLanguage.JAVA, ConstructType.METH, "com.foo.Bar"));
  lib.setConstructs(cons);
  app.addDependency(new Dependency(app, lib, Scope.COMPILE, false, "fo0-lib.jar", "/tmp/"));
  // All properties (as no view is given)
  final String json_no_view = JacksonUtil.asJsonString(app, null, null);
  // assertEquals("{\"artifact\":\"foo\",\"version\":\"0.1\",\"createdAt\":null,\"modifiedAt\":null,\"lastScan\":null,\"lastVulnChange\":null,\"constructs\":[],\"dependencies\":[{\"lib\":{\"digest\":\"digest-123\",\"digestAlgorithm\":\"SHA256\",\"createdAt\":null,\"properties\":[{\"source\":\"JAVA_MANIFEST\",\"name\":\"foo-prop\",\"value\":\"bar-prop\"}],\"constructs\":[{\"lang\":\"JAVA\",\"type\":\"METH\",\"qname\":\"com.foo.Bar\",\"relates\":null,\"attributes\":null}],\"libraryId\":null,\"wellknownDigest\":null,\"digestVerificationUrl\":null,\"constructCounter\":1,\"constructTypeCounters\":{\"PACK\":0,\"ENUM\":0,\"CONS\":0,\"CLASS\":0,\"INIT\":0,\"METH\":1,\"MODU\":0,\"FUNC\":0}},\"declared\":true,\"traced\":false,\"scope\":\"COMPILE\",\"transitive\":false,\"filename\":\"fo0-lib.jar\",\"path\":\"/tmp/\",\"reachableConstructIds\":null,\"touchPoints\":null,\"parent\":null,\"origin\":null,\"relativePath\":null}],\"empty\":false,\"complete\":true,\"group\":\"com.acme\",\"constructCounter\":0,\"countDependencies\":1,\"constructTypeCounters\":{\"PACK\":0,\"ENUM\":0,\"CONS\":0,\"CLASS\":0,\"INIT\":0,\"METH\":0,\"MODU\":0,\"FUNC\":0}}", json_no_view);
  // All properties without view and those with view Default
  final String json_default_view = JacksonUtil.asJsonString(app, null, Views.Default.class);
  // assertEquals("{\"artifact\":\"foo\",\"version\":\"0.1\",\"createdAt\":null,\"modifiedAt\":null,\"lastScan\":null,\"lastVulnChange\":null,\"constructs\":[],\"dependencies\":[{\"lib\":{\"digest\":\"digest-123\",\"digestAlgorithm\":\"SHA256\",\"createdAt\":null,\"libraryId\":null,\"wellknownDigest\":null,\"digestVerificationUrl\":null,\"constructCounter\":1,\"constructTypeCounters\":{\"PACK\":0,\"ENUM\":0,\"CONS\":0,\"CLASS\":0,\"INIT\":0,\"METH\":1,\"MODU\":0,\"FUNC\":0}},\"declared\":true,\"traced\":false,\"scope\":\"COMPILE\",\"transitive\":false,\"filename\":\"fo0-lib.jar\",\"path\":\"/tmp/\",\"reachableConstructIds\":null,\"touchPoints\":null,\"parent\":null,\"origin\":null,\"relativePath\":null}],\"empty\":false,\"complete\":true,\"group\":\"com.acme\",\"constructCounter\":0,\"countDependencies\":1,\"constructTypeCounters\":{\"PACK\":0,\"ENUM\":0,\"CONS\":0,\"CLASS\":0,\"INIT\":0,\"METH\":0,\"MODU\":0,\"FUNC\":0}}", json_default_view);
  // All properties without view and those with view LibDetails
  final String json_lib_view = JacksonUtil.asJsonString(app, null, Views.LibDetails.class);
  // assertEquals("{\"artifact\":\"foo\",\"version\":\"0.1\",\"createdAt\":null,\"modifiedAt\":null,\"lastScan\":null,\"lastVulnChange\":null,\"constructs\":[],\"dependencies\":[{\"lib\":{\"digest\":\"digest-123\",\"digestAlgorithm\":\"SHA256\",\"createdAt\":null,\"properties\":[{\"source\":\"JAVA_MANIFEST\",\"name\":\"foo-prop\",\"value\":\"bar-prop\"}],\"constructs\":[{\"lang\":\"JAVA\",\"type\":\"METH\",\"qname\":\"com.foo.Bar\",\"relates\":null,\"attributes\":null}],\"libraryId\":null,\"wellknownDigest\":null,\"digestVerificationUrl\":null,\"constructCounter\":1,\"constructTypeCounters\":{\"PACK\":0,\"ENUM\":0,\"CONS\":0,\"CLASS\":0,\"INIT\":0,\"METH\":1,\"MODU\":0,\"FUNC\":0}},\"declared\":true,\"traced\":false,\"scope\":\"COMPILE\",\"transitive\":false,\"filename\":\"fo0-lib.jar\",\"path\":\"/tmp/\",\"reachableConstructIds\":null,\"touchPoints\":null,\"parent\":null,\"origin\":null,\"relativePath\":null}],\"empty\":false,\"complete\":true,\"group\":\"com.acme\",\"constructCounter\":0,\"countDependencies\":1,\"constructTypeCounters\":{\"PACK\":0,\"ENUM\":0,\"CONS\":0,\"CLASS\":0,\"INIT\":0,\"METH\":0,\"MODU\":0,\"FUNC\":0}}", json_lib_view);
}