LocaleMarshaller implements IJsonMarshaller<Locale> { @Override public String toJson(Locale obj) throws JsonMarshallingException { if(null != obj) { return String.format("{\"%s\":\"%s\",\"%s\":\"%s\"}", Constants.Message.COUNTRY, obj.getCountry(), Constants.Message.LANGUAGE, obj.getLanguage()); } return "null"; }  @Override String toJson(Locale obj); @Override Locale toJava(String json);  }
@Test public void testToJson() throws JsonMarshallingException { System.out.println("toJson"); String expResult = "{\"country\":\"FR\",\"language\":\"fr\"}"; String result = instance.toJson(Locale.FRANCE); assertThat(result).isEqualTo(expResult); }
@Test public void testToJsonNull() throws JsonMarshallingException { System.out.println("toJson"); String result = instance.toJson(null); assertThat(result).isEqualTo("null"); }