@Test public void getFieldRefMethodDeclaration() { String methodName = "METHOD_NAME"; FieldRef fieldRef = fieldRefSupplier.get(); ParameterField parameterField = new ParameterField(FieldName.create("FIELD_REF")); LinkedHashMap<String, ClassOrInterfaceType> modifiedParametersMap = new LinkedHashMap<>(DEFAULT_PARAMETERTYPE_MAP); modifiedParametersMap.put(parameterField.getName().toString(), parseClassOrInterfaceType(getBoxedClassName(parameterField))); MethodDeclaration retrieved = DefineFunctionUtils.getFieldRefMethodDeclaration(methodName, fieldRef, STRING_CLASS, modifiedParametersMap); String expected = String.format("java.lang.String %s(java.util.List<org.kie.pmml.commons.model.tuples.KiePMMLNameValue> param1, java.lang.Object FIELD_REF) {\n" + " java.lang.String fieldRefVariable = FIELD_REF != null ? (java.lang.String) org.kie.pmml.commons.utils.ConverterTypeUtil.convert(java.lang.String.class, FIELD_REF) " + ": (java.lang.String) null;\n" + " return fieldRefVariable;\n" + "}", methodName); assertEquals(expected, retrieved.toString()); String mapMissingTo = "MAP_MISSING_TO"; fieldRef.setMapMissingTo(mapMissingTo); retrieved = DefineFunctionUtils.getFieldRefMethodDeclaration(methodName, fieldRef, STRING_CLASS, modifiedParametersMap); expected = String.format("java.lang.String %s(java.util.List<org.kie.pmml.commons.model.tuples.KiePMMLNameValue> param1, java.lang.Object FIELD_REF) {\n" + " java.lang.String fieldRefVariable = FIELD_REF != null ? (java.lang.String) org.kie.pmml.commons.utils.ConverterTypeUtil.convert(java.lang.String.class, FIELD_REF) " + ": (java.lang.String) \"MAP_MISSING_TO\";\n" + " return fieldRefVariable;\n" + "}", methodName); assertEquals(expected, retrieved.toString()); }
static MethodDeclaration getFieldRefMethodDeclaration(final String methodName, final FieldRef fieldRef, final ClassOrInterfaceType returnedType, final LinkedHashMap<String, ClassOrInterfaceType> parameterNameTypeMap) { return getFieldRefExpressionMethodDeclaration(methodName, fieldRef, returnedType, parameterNameTypeMap); }
DefineFunctionUtils { static MethodDeclaration getFieldRefMethodDeclaration(final String methodName, final FieldRef fieldRef, final ClassOrInterfaceType returnedType, final LinkedHashMap<String, ClassOrInterfaceType> parameterNameTypeMap) { return getFieldRefExpressionMethodDeclaration(methodName, fieldRef, returnedType, parameterNameTypeMap); } }
DefineFunctionUtils { static MethodDeclaration getFieldRefMethodDeclaration(final String methodName, final FieldRef fieldRef, final ClassOrInterfaceType returnedType, final LinkedHashMap<String, ClassOrInterfaceType> parameterNameTypeMap) { return getFieldRefExpressionMethodDeclaration(methodName, fieldRef, returnedType, parameterNameTypeMap); } private  DefineFunctionUtils(); }
DefineFunctionUtils { static MethodDeclaration getFieldRefMethodDeclaration(final String methodName, final FieldRef fieldRef, final ClassOrInterfaceType returnedType, final LinkedHashMap<String, ClassOrInterfaceType> parameterNameTypeMap) { return getFieldRefExpressionMethodDeclaration(methodName, fieldRef, returnedType, parameterNameTypeMap); } private  DefineFunctionUtils();  }
DefineFunctionUtils { static MethodDeclaration getFieldRefMethodDeclaration(final String methodName, final FieldRef fieldRef, final ClassOrInterfaceType returnedType, final LinkedHashMap<String, ClassOrInterfaceType> parameterNameTypeMap) { return getFieldRefExpressionMethodDeclaration(methodName, fieldRef, returnedType, parameterNameTypeMap); } private  DefineFunctionUtils();   }