SpecificationAdapter { Specification fromJson(JsonNode jsonNode) { return new Specification(jsonNode.path("name").asText(), jsonNode.path("optional").asBoolean(), jsonNode.path("description").asText(), jsonNode.path("semantics").asText(), jsonNode.path("units").asText(), jsonNode.path("mBeanName").asText(), jsonNode.path("mBeanAttributeName").asText(), jsonNode.path("mBeanCompositeDataItem").asText()); }    }
@Test public void fromJson_shouldConstructASpecificationFromAJsonRepresentation() { JsonNode jsonNode = mock(JsonNode.class, RETURNS_DEEP_STUBS); when(jsonNode.path("name").asText()).thenReturn(NAME); when(jsonNode.path("optional").asBoolean()).thenReturn(OPTIONAL); when(jsonNode.path("description").asText()).thenReturn(DESCRIPTION); when(jsonNode.path("semantics").asText()).thenReturn(SEMANTICS); when(jsonNode.path("units").asText()).thenReturn(UNITS); when(jsonNode.path("mBeanName").asText()).thenReturn(MBEAN_NAME); when(jsonNode.path("mBeanAttributeName").asText()).thenReturn(MBEAN_ATTRIBUTE_NAME); when(jsonNode.path("mBeanCompositeDataItem").asText()).thenReturn(MBEAN_COMPOSITE_DATA_ITEM); Specification actual = specificationAdapter.fromJson(jsonNode); Specification expected = new Specification(NAME, OPTIONAL, DESCRIPTION, SEMANTICS, UNITS, MBEAN_NAME, MBEAN_ATTRIBUTE_NAME, MBEAN_COMPOSITE_DATA_ITEM); assertThat(actual, is(reflectivelyEqualing(expected))); }