podam icon indicating copy to clipboard operation
podam copied to clipboard

PodamFactoryImpl: Support for JAXBElement instantiation

Open patrodyne opened this issue 11 years ago • 4 comments

Classes generated by the JAXB compiler, xjc, produces properties that may include a JAXBElement<T> wrapper. This wrapper is used to encapsulate information related to the XML schema such as the QName (namespace + element name), etc. The wrapper stores the actual property value in its own getValue() / setValue(...) property. Here is a patch for the manufactureAttributeValue method of the PodamFactoryImpl class to create the wrapper and generate a mock of the actual type. It is located just ahead of the exitsing test for "java" and "javax" classes.

import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
...
if ( realAttributeType.getName().startsWith("javax.xml.bind.JAXBElement"))
{
    @SuppressWarnings("unchecked")
    Class<Object> declaredType = (Class<Object>) genericTypeArgs[0];
    String namepaceURI = pojoClass.getPackage().getName();
    QName name = new QName(namepaceURI, attributeName);
    Object value = manufactureAttributeValue(pojoClass, pojos, declaredType, 
        annotations, attributeName, new Type[0]);
    attributeValue = new JAXBElement<Object>(name, declaredType, value);
}
else if (realAttributeType.getName().startsWith("java.")
        || realAttributeType.getName().startsWith("javax.")) {
...

patrodyne avatar Dec 27 '14 18:12 patrodyne

Fixed in Podam 4.5.0.

Marco could I ask your help with releasing?

daivanov avatar Dec 31 '14 08:12 daivanov

Released to Maven Central

On 31 Dec 2014, at 08:48, Daniil Ivanov [email protected] wrote:

Fixed in Podam 4.5.0.

Marco could I ask your help with releasing?

— Reply to this email directly or view it on GitHub https://github.com/mtedone/podam/issues/70#issuecomment-68430407.

mtedone avatar Jan 03 '15 15:01 mtedone

Thank you Marco!

daivanov avatar Jan 03 '15 17:01 daivanov

Closing.

daivanov avatar Jan 17 '15 07:01 daivanov