### Question:
Asset { public static String toJson(Collection<Asset> assets) throws IOException { StringWriter sw = new StringWriter(); JsonFactory f = new JsonFactory(); JsonGenerator g = f.createJsonGenerator(sw); g.writeStartObject(); g.writeFieldName("assets"); g.writeStartArray(); for (Asset asset : assets) { asset.write(g); } g.writeEndArray(); g.writeEndObject(); g.close(); String json = sw.toString(); return json; } Asset(); static String toJson(Collection<Asset> assets); static Set<URI> getPhotosToRemove(Asset original, Asset updated); String getId(); void setId(String id); String getCode(); void setCode(String code); String getName(); void setName(String name); Set<String> getTags(); Map<String, String> getAttributes(); Set<URI> getPhotos(); void addPhoto(String url); void fromJson(String json); String toJson();  }### Answer:
@Test public void testToJson() { try { Asset asset = new Asset(); asset.fromJson(this.json); String gen = asset.toJson(); Asset reparsed = new Asset(); reparsed.fromJson(gen); assertEquals(asset.getName(), reparsed.getName()); assertTrue(reparsed.getTags().contains("Featured")); assertTrue(reparsed.getPhotos().contains(new URI("http: assertTrue(reparsed.getAttributes().containsKey("Quantity")); assertEquals("Excellent", reparsed.getAttributes().get("Condition")); } catch (IOException e) { fail(e.toString()); } catch (URISyntaxException e) { fail(e.toString()); } }