ServiceTools { String _getTemplateOfType(Type type, IJsonMarshaller jsonMarshaller) { if (ParameterizedType.class.isAssignableFrom(type.getClass())) { return getTemplateOfParameterizedType((ParameterizedType) type, jsonMarshaller); } try { return jsonMarshaller.toJson(getInstanceOfClass((Class) type)); } catch (JsonMarshallingException ex) { } return ((Class) type).getSimpleName().toLowerCase(Locale.ENGLISH); }  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 test_getTemplateOfType() throws JsonMarshallingException { System.out.println("_getTemplateOfType"); Class type = String.class; ParameterizedType ptype = mock(ParameterizedType.class); String expResult1 = "Type"; String expResult2 = "ParameterizedType"; doReturn(expResult1).when(instance).getInstanceOfClass(eq(String.class)); doReturn(expResult2).when(instance).getTemplateOfParameterizedType(any(ParameterizedType.class), any(IJsonMarshaller.class)); when(templateMarshaller.toJson(any(String.class))).thenReturn("\""+expResult1+"\"").thenThrow(JsonMarshallingException.class); String result = instance._getTemplateOfType(type, templateMarshaller); assertThat(result).isEqualTo("\""+expResult1+"\""); result = instance._getTemplateOfType(type, templateMarshaller); assertThat(result).isEqualTo("string"); result = instance._getTemplateOfType(ptype, templateMarshaller); assertThat(result).isEqualTo(expResult2); }