Commit fc2d7583 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Removed NodeTypeSetter. Added json-path-assert for testing JSON structure

parent 60251f87
Loading
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,18 @@
            <version>5.6.0</version>
            <version>5.6.0</version>
            <scope>test</scope>
            <scope>test</scope>
        </dependency>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <version>2.4.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path-assert</artifactId>
            <version>2.4.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    </dependencies>
    <build>
    <build>
        <finalName>${finalName}</finalName>
        <finalName>${finalName}</finalName>
+0 −30
Original line number Original line Diff line number Diff line
package it.inaf.oats.vospace.datamodel;

import com.fasterxml.jackson.databind.util.StdConverter;
import net.ivoa.xml.vospace.v2.Node;

/**
 * Fills the type field at the end of the JSON deserialization.
 * Node implementations must be annotated with
 * @JsonDeserialize(converter = NodeTypeAdder.<NodeType>.class)
 */
public class NodeTypeSetter<T extends Node> extends StdConverter<T, T> {

    @Override
    public T convert(T node) {
        node.setType("vos:" + node.getClass().getSimpleName());
        return node;
    }

    public static class UnstructuredDataNode extends NodeTypeSetter<net.ivoa.xml.vospace.v2.UnstructuredDataNode> {
    }

    public static class StructuredDataNode extends NodeTypeSetter<net.ivoa.xml.vospace.v2.StructuredDataNode> {
    }

    public static class ContainerNode extends NodeTypeSetter<net.ivoa.xml.vospace.v2.ContainerNode> {
    }

    public static class LinkNode extends NodeTypeSetter<net.ivoa.xml.vospace.v2.LinkNode> {
    }
}
+27 −98
Original line number Original line Diff line number Diff line
@@ -4,29 +4,28 @@
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2020.10.24 at 09:39:16 AM CEST 
// Generated on: 2020.10.24 at 09:39:16 AM CEST 
//
//


package net.ivoa.xml.vospace.v2;
package net.ivoa.xml.vospace.v2;


import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import it.inaf.oats.vospace.datamodel.NodeTypeSetter;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlType;



/**
/**
 *
 *
 * A container node containing any type of node.
 * A container node containing any type of node.
 *
 *
 *
 *
 * <p>Java class for ContainerNode complex type.
 * <p>
 * Java class for ContainerNode complex type.
 *
 *
 * <p>The following schema fragment specifies the expected content contained within this class.
 * <p>
 * The following schema fragment specifies the expected content contained within
 * this class.
 *
 *
 * <pre>
 * <pre>
 * &lt;complexType name="ContainerNode">
 * &lt;complexType name="ContainerNode">
@@ -58,96 +57,26 @@ import javax.xml.bind.annotation.XmlType;
})
})
// <edit>
// <edit>
@XmlRootElement(name = "node")
@XmlRootElement(name = "node")
@JsonDeserialize(converter = NodeTypeSetter.ContainerNode.class)
// </edit>
// </edit>
public class ContainerNode
public class ContainerNode
    extends DataNode
        extends DataNode {
{


    @XmlElement(required = true)
    // <edit>
    protected ContainerNode.Nodes nodes;
    // Auto-generated class defined an inner ContainerNode.Nodes wrapper class.
    // This should simplify usage and JSON compatibility.
    @XmlElement(name = "node")
    @XmlElementWrapper(name = "nodes", required = true)
    protected List<Node> nodes;


    /**
    public List<Node> getNodes() {
     * Gets the value of the nodes property.
        if (nodes == null) {
     * 
            nodes = new ArrayList<>();
     * @return
        }
     *     possible object is
     *     {@link ContainerNode.Nodes }
     *     
     */
    public ContainerNode.Nodes getNodes() {
        return nodes;
        return nodes;
    }
    }


    /**
    public void setNodes(List<Node> value) {
     * Sets the value of the nodes property.
     * 
     * @param value
     *     allowed object is
     *     {@link ContainerNode.Nodes }
     *     
     */
    public void setNodes(ContainerNode.Nodes value) {
        this.nodes = value;
        this.nodes = value;
    }
    }

    // </edit>

    /**
     * <p>Java class for anonymous complex type.
     * 
     * <p>The following schema fragment specifies the expected content contained within this class.
     * 
     * <pre>
     * &lt;complexType>
     *   &lt;complexContent>
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       &lt;sequence>
     *         &lt;element name="node" type="{http://www.ivoa.net/xml/VOSpace/v2.0}Node" maxOccurs="unbounded" minOccurs="0"/>
     *       &lt;/sequence>
     *     &lt;/restriction>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * </pre>
     * 
     * 
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "node"
    })
    public static class Nodes {

        protected List<Node> node;

        /**
         * Gets the value of the node property.
         * 
         * <p>
         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a <CODE>set</CODE> method for the node property.
         * 
         * <p>
         * For example, to add a new item, do as follows:
         * <pre>
         *    getNode().add(newItem);
         * </pre>
         * 
         * 
         * <p>
         * Objects of the following type(s) are allowed in the list
         * {@link Node }
         * 
         * 
         */
        public List<Node> getNode() {
            if (node == null) {
                node = new ArrayList<Node>();
            }
            return this.node;
        }

    }

}
}
+4 −0
Original line number Original line Diff line number Diff line
@@ -11,6 +11,7 @@ package net.ivoa.xml.vospace.v2;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlType;


@@ -52,6 +53,9 @@ import javax.xml.bind.annotation.XmlType;
    ContainerNode.class,
    ContainerNode.class,
    UnstructuredDataNode.class
    UnstructuredDataNode.class
})
})
// <edit>
@XmlRootElement(name = "node")
// </edit>
public class DataNode
public class DataNode
    extends Node
    extends Node
{
{
+0 −3
Original line number Original line Diff line number Diff line
@@ -8,8 +8,6 @@


package net.ivoa.xml.vospace.v2;
package net.ivoa.xml.vospace.v2;


import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import it.inaf.oats.vospace.datamodel.NodeTypeSetter;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElement;
@@ -47,7 +45,6 @@ import javax.xml.bind.annotation.XmlType;
})
})
// <edit>
// <edit>
@XmlRootElement(name = "node")
@XmlRootElement(name = "node")
@JsonDeserialize(converter = NodeTypeSetter.LinkNode.class)
// </edit>
// </edit>
public class LinkNode
public class LinkNode
    extends Node
    extends Node
Loading