ServiceTools { String getTemplateOfParameterizedType(ParameterizedType parameterizedType, IJsonMarshaller jsonMarshaller) { Class cls = (Class) parameterizedType.getRawType(); Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); String res; if (Iterable.class.isAssignableFrom(cls)) { res = getTemplateOfIterable(actualTypeArguments, jsonMarshaller); } else if (Map.class.isAssignableFrom(cls)) { res = getTemplateOfMap(actualTypeArguments, jsonMarshaller); } else { res = cls.getSimpleName().toLowerCase(Locale.ENGLISH); } return res; }  String getShortName(String fullformat); String getLiteralType(Type type); IJsonMarshaller getJsonMarshaller(Annotation[] annotations); IJsonMarshaller getJsonMarshallerFromAnnotation(JsonUnmarshaller jua); String getTemplateOfType(Type type, IJsonMarshaller jsonMarshaller); String getInstanceNameFromDataservice(Class cls); boolean isConsiderateMethod(Method method);  }
@Test public void testGetTemplateOfParameterizedType() { System.out.println("getTemplateOfParameterizedType"); ParameterizedType parameterizedType = mock(ParameterizedType.class); when(parameterizedType.getRawType()).thenReturn(Collection.class).thenReturn(Map.class).thenReturn(String.class); doReturn("Iterable").when(instance).getTemplateOfIterable(any(Type[].class), any(IJsonMarshaller.class)); doReturn("Map").when(instance).getTemplateOfMap(any(Type[].class), any(IJsonMarshaller.class)); String result = instance.getTemplateOfParameterizedType(parameterizedType, templateMarshaller); assertThat(result).isEqualTo("Iterable"); result = instance.getTemplateOfParameterizedType(parameterizedType, templateMarshaller); assertThat(result).isEqualTo("Map"); result = instance.getTemplateOfParameterizedType(parameterizedType, templateMarshaller); assertThat(result).isEqualTo("string"); }