ArgumentServices { public String getJsonResultFromSpecificMarshaller(JsonMarshaller jm, Object result) throws JsonMarshallingException, JsonMarshallerException { IJsonMarshaller marshaller = getIJsonMarshallerInstance(jm.value()); String res; switch (jm.type()) { case LIST: res = getJsonResultFromSpecificMarshallerIterable((Iterable) result, marshaller); break; case MAP: res = getJsonResultFromSpecificMarshallerMap((Map) result, marshaller); break; default: res = marshaller.toJson(result); } return res; }  List<String> getJsonParameters(Object[] parameters, Annotation[][] annotationss); IJsonMarshaller getIJsonMarshallerInstance(Class<? extends IJsonMarshaller> cls); String getJsonResultFromSpecificMarshaller(JsonMarshaller jm, Object result); String getJsonResultFromSpecificMarshallerIterable(Iterable list, IJsonMarshaller marshaller); List getJavaResultFromSpecificUnmarshallerIterable(String json, IJsonMarshaller marshaller); Map getJavaResultFromSpecificUnmarshallerMap(String json, IJsonMarshaller marshaller); void checkType(Object object, Type paramType);  }
@Test public void testGetJsonResultFromSpecificMarshaller() throws Exception { System.out.println("getJsonResultFromSpecificMarshaller"); IJsonMarshaller ijm = mock(IJsonMarshaller.class); JsonMarshaller jm = mock(JsonMarshaller.class); when(jm.value()).thenReturn((Class) LocaleMarshaller.class); when(jm.type()).thenReturn(JsonMarshallerType.SINGLE).thenReturn(JsonMarshallerType.LIST).thenReturn(JsonMarshallerType.MAP); when(ijm.toJson(any(Object.class))).thenReturn("LG1"); doReturn("[LG1,LG2]").when(instance).getJsonResultFromSpecificMarshallerIterable(any(Iterable.class), any(IJsonMarshaller.class)); doReturn("{\"FR\":LG1,\"US\":LG2}").when(instance).getJsonResultFromSpecificMarshallerMap(any(Map.class), any(IJsonMarshaller.class)); doReturn(ijm).when(instance).getIJsonMarshallerInstance(any(Class.class)); String result = instance.getJsonResultFromSpecificMarshaller(jm, Locale.FRANCE); assertThat(result).isEqualTo("LG1"); result = instance.getJsonResultFromSpecificMarshaller(jm, Arrays.asList(Locale.FRANCE, Locale.US)); assertThat(result).isEqualTo("[LG1,LG2]"); result = instance.getJsonResultFromSpecificMarshaller(jm, getMapOfLocale()); assertThat(result).isEqualTo("{\"FR\":LG1,\"US\":LG2}"); }