### Question:
JsonDeserializer { public List<LWM2MResource> deserialize(String json) { JsonResourceArray array = asJsonResourceArray(json); List<LWM2MResource> resources = new ArrayList<>(); Map<String, LWM2MResource> multipleResources = new HashMap<>(); for (JsonResource jsonResource : array.getResources()) { LWM2MResource lwm2mResource = toLWM2MResource(jsonResource, multipleResources); if (lwm2mResource != null) { resources.add(lwm2mResource); } } return resources; } private  JsonDeserializer(); static JsonDeserializer create(); JsonResourceArray asJsonResourceArray(String json); List<LWM2MResource> deserialize(String json);  }### Answer:
@Test public void parseDeviceObject() throws Exception { InputStream input = JsonDeserializerTest.class.getResourceAsStream(DEVICE_OBJECT_JSON); String jsonString = IOUtils.toString(input); List<LWM2MResource> resources = deserializer.deserialize(jsonString); assertThat(resources, hasSize(13)); assertThat(resources.get(0).getType(), equalTo(LWM2MResourceType.STRING)); assertArrayEquals("Open Mobile Alliance".getBytes(), resources.get(0).getValue()); assertThat(resources.get(3).getType(), equalTo(LWM2MResourceType.STRING)); assertThat(resources.get(4).getNestedInstances().get(0).getType(), equalTo(LWM2MResourceType.INTEGER)); }
@Test public void parseNotification() throws Exception { InputStream input = JsonDeserializerTest.class.getResourceAsStream(NOTIFICATION_JSON); String jsonString = IOUtils.toString(input); List<LWM2MResource> resources = deserializer.deserialize(jsonString); assertThat(resources, hasSize(1)); assertThat(resources.get(0).getType(), nullValue()); assertThat(resources.get(0).getNestedInstances(), hasSize(3)); assertThat(resources.get(0).getNestedInstances().get(0).getType(), equalTo(LWM2MResourceType.FLOAT)); }
@Test public void parseCustomObject() throws Exception { InputStream input = JsonDeserializerTest.class.getResourceAsStream(CUSTOM_OBJECT_JSON); String jsonString = IOUtils.toString(input); List<LWM2MResource> resources = deserializer.deserialize(jsonString); System.out.println(resources); }