### Question:
JsonMdlParser implements Parser<ServiceMonitoringDefinitionsDescriptor> { @Override public ServiceMonitoringDefinitionsDescriptor parse(byte[] data) throws IOException { Preconditions.checkNotNull(data); return mapper.readValue(data, ServiceMonitoringDefinitionsDescriptor.class); } JsonMdlParser(JsonSdlObjectMapper mapper); @Override ServiceMonitoringDefinitionsDescriptor parse(byte[] data); String valueAsString(
      ServiceMonitoringDefinitionsDescriptor descriptor,
      boolean usePrettyFormat);  }### Answer:
@Test public void testParseFullFile() throws Exception { ServiceMonitoringDefinitionsDescriptor descriptor = parser.parse(getMdl("service_full.mdl")); assertNotNull(descriptor); assertEquals(descriptor.getName(), "ECHO"); assertEquals(2, descriptor.getMetricEntityAttributeDefinitions().size()); assertEquals(2, descriptor.getMetricEntityTypeDefinitions().size()); assertEquals(3, descriptor.getMetricDefinitions().size()); assertEquals(2, descriptor.getRoles().size()); for (RoleMonitoringDefinitionsDescriptor role : descriptor.getRoles()) { assertEquals(3, role.getMetricDefinitions().size()); } }
@Test public void testParseUnknownElement() throws Exception { ServiceMonitoringDefinitionsDescriptor descriptor = parser .parse(getMdl("service_unknown_elements.mdl")); assertEquals(descriptor.getName(), "ECHO"); }
@Test(expected = IOException.class) public void testBadJson() throws Exception { parser.parse(getMdl("service_badjson.sdl")); }