### Question:
SmsJsonConverter { public JsonValue toJson(Map<String, Set<String>> attributeValuePairs) { return toJson(null, attributeValuePairs); } @Inject  SmsJsonConverter(ServiceSchema schema); JsonValue toJson(Map<String, Set<String>> attributeValuePairs); JsonValue toJson(String realm, Map<String, Set<String>> attributeValuePairs); Map<String, Set<String>> fromJson(JsonValue jsonValue); Map<String, Set<String>> fromJson(String realm, JsonValue jsonValue);  }### Answer:
@Test public void convertToJson() throws SMSException { given(serviceSchema.validateAttributes(Matchers.<Map>anyObject())).willReturn(true); JsonValue result = converter.toJson(mapRepresentation); AssertJJsonValueAssert.AbstractJsonValueAssert asserter = AssertJJsonValueAssert.assertThat(result); asserter.isObject() .containsField(SECTION_1_NAME) .containsField(STRING_VALUE_RESOURCE_NAME) .containsField(INT_VALUE_NAME) .containsField(BOOLEAN_VALUE_NAME) .containsField(DECIMAL_VALUE_NAME) .containsField(MAP_VALUE_NAME) .containsField(ARRAY_VALUE_NAME); asserter.isObject().hasObject(SECTION_1_NAME) .contains(Assertions.entry(SECTION_1_STRING_VALUE_NAME, STRING_VALUE)); asserter.isObject().stringAt(STRING_VALUE_RESOURCE_NAME) .isEqualTo(STRING_VALUE); asserter.isObject().integerAt(INT_VALUE_NAME) .isEqualTo(INT_VALUE); asserter.isObject().booleanAt(BOOLEAN_VALUE_NAME) .isEqualTo(BOOLEAN_VALUE); asserter.isObject().doubleAt(DECIMAL_VALUE_NAME) .isEqualTo(DOUBLE_VALUE); asserter.hasArray(ARRAY_VALUE_NAME).isArray().containsOnly(ARRAY_STRING_1, ARRAY_STRING_2); asserter.hasObject(MAP_VALUE_NAME) .contains(Assertions.entry(ATT_1_NAME, ATT_1_VAL)) .contains(Assertions.entry(ATT_2_NAME, ATT_2_VAL)); asserter.isObject().hasNull(PASSWORD_VALUE_NAME); }
@Test(expectedExceptions = JsonException.class) public void invalidValuesToJson() throws SMSException { given(serviceSchema.validateAttributes(Matchers.<Map>anyObject())).willReturn(false); converter.toJson(mapRepresentation); }