Skip to content

Commit

Permalink
Fix TParameter xml serialization (winery#606)
Browse files Browse the repository at this point in the history
Signed-off-by: Marvin Bechtold <[email protected]>
  • Loading branch information
mar-be authored Jul 29, 2021
1 parent 51a2437 commit 2d5e36f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import org.eclipse.winery.model.jaxbsupport.map.BooleanToYesNo;
import org.eclipse.winery.model.jsonsupport.YesNo;
import org.eclipse.winery.model.tosca.visitor.Visitor;

Expand All @@ -42,6 +44,7 @@ public class TParameter implements Serializable {
protected String type;

@XmlAttribute(name = "required")
@XmlJavaTypeAdapter(type = boolean.class, value = BooleanToYesNo.class)
@JsonSerialize(using = YesNo.Serializer.class)
@JsonDeserialize(using = YesNo.Deserializer.class)
protected boolean required;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,21 @@ public void createConfigureInterface() throws Exception {
"entitytypes/interfaces/create_configure_interface_result.json");
this.assertGet("relationshiptypes/http%253A%252F%252Fplain.winery.opentosca.org%252Frelationshiptypes/RelationshipTypeWithoutProperties",
"entitytypes/interfaces/create_configure_interface_result.xml");
this.assertGet("relationshiptypes/http%253A%252F%252Fplain.winery.opentosca.org%252Frelationshiptypes/RelationshipTypeWithoutProperties/xml",
"entitytypes/interfaces/create_configure_interface_result.xml");
}

@Test
public void addInputParameters() throws Exception {
this.setRevisionTo("origin/plain");
this.assertNoContentPost("nodetypes/http%253A%252F%252Fopentosca.org%252Fnodetypes/MySQL-DBMS/interfaces/",
"entitytypes/interfaces/add_input_params.json");
this.assertGet("nodetypes/http%253A%252F%252Fopentosca.org%252Fnodetypes/MySQL-DBMS/interfaces/",
"entitytypes/interfaces/add_input_params_result.json");
this.assertGet("nodetypes/http%253A%252F%252Fopentosca.org%252Fnodetypes/MySQL-DBMS",
"entitytypes/interfaces/add_input_params_result.xml");
this.assertGet("nodetypes/http%253A%252F%252Fopentosca.org%252Fnodetypes/MySQL-DBMS/xml",
"entitytypes/interfaces/add_input_params_result.xml");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"operation": [
{
"inputParameters": {
"inputParameter": [
{
"name": "Param1",
"type": "xsd:string",
"required": "YES"
},
{
"name": "Param2",
"type": "xsd:string",
"required": "YES"
},
{
"name": "Param3",
"type": "xsd:string",
"required": "NO"
}
]
},
"name": "configure"
}
],
"name": "http://www.example.com/interfaces/lifecycle"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"operation": [
{
"documentation": [],
"any": [],
"otherAttributes": {},
"inputParameters": {
"inputParameter": [
{
"name": "Param1",
"type": "xsd:string",
"required": "YES"
},
{
"name": "Param2",
"type": "xsd:string",
"required": "YES"
},
{
"name": "Param3",
"type": "xsd:string",
"required": "NO"
}
]
},
"name": "configure"
}
],
"name": "http://www.example.com/interfaces/lifecycle"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Definitions xmlns="http://docs.oasis-open.org/tosca/ns/2011/12" xmlns:winery="http://www.opentosca.org/winery/extensions/tosca/2013/02/12" xmlns:selfservice="http://www.eclipse.org/winery/model/selfservice" xmlns:testwineryopentoscaorg="http://test.winery.opentosca.org" targetNamespace="http://opentosca.org/nodetypes" id="winery-defs-for_nodetypes1-MySQL-DBMS">
<NodeType name="MySQL-DBMS" abstract="no" final="no" targetNamespace="http://opentosca.org/nodetypes">
<Interfaces>
<Interface name="http://www.example.com/interfaces/lifecycle">
<Operation name="configure">
<InputParameters>
<InputParameter name="Param1" type="xsd:string" required="yes"/>
<InputParameter name="Param2" type="xsd:string" required="yes"/>
<InputParameter name="Param3" type="xsd:string" required="no"/>
</InputParameters>
</Operation>
</Interface>
</Interfaces>
</NodeType>
</Definitions>

0 comments on commit 2d5e36f

Please sign in to comment.