Skip to content

Commit

Permalink
x and y are stored in node template
Browse files Browse the repository at this point in the history
critical tests:
- servicetemplates/ServiceTemplateResource-getInjectionOptions.json
- servicetemplates/ServiceTemplateResource-getInjectionOptions-DriverInjectionTest.json

Signed-off-by: Oliver Kopp <kopp.dev@gmail.com>
  • Loading branch information
koppor committed Sep 7, 2017
1 parent db61e31 commit 547c1e4
Show file tree
Hide file tree
Showing 12 changed files with 1,086 additions and 1,037 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;

import org.eclipse.winery.model.tosca.constants.Namespaces;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.eclipse.jdt.annotation.NonNull;
Expand Down Expand Up @@ -317,6 +321,38 @@ public void setMaxInstances(String value) {
this.maxInstances = value;
}

/**
* Sets the left coordinate of a {@link TNodeTemplate}.
*
* @param x the value of the x-coordinate to be set
*/
public void setX(String x) {
Map<QName, String> otherNodeTemplateAttributes = this.getOtherAttributes();
otherNodeTemplateAttributes.put(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "x"), x);
}

@XmlTransient
public String getX() {
Map<QName, String> otherNodeTemplateAttributes = this.getOtherAttributes();
return otherNodeTemplateAttributes.get(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "x"));
}

/**
* Sets the top coordinate of a {@link TNodeTemplate}.
*
* @param y the value of the coordinate to be set
*/
public void setY(String y) {
Map<QName, String> otherNodeTemplateAttributes = this.getOtherAttributes();
otherNodeTemplateAttributes.put(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "y"), y);
}

@XmlTransient
public String getY() {
Map<QName, String> otherNodeTemplateAttributes = this.getOtherAttributes();
return otherNodeTemplateAttributes.get(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "y"));
}


/**
* <p>Java class for anonymous complex type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,29 +546,6 @@ public static TPlan resolvePlan(TServiceTemplate serviceTemplate, String referen
return resolved;
}

/**
* Sets the x coordinate of a {@link TNodeTemplate}.
*
* @param nodeTemplate the nodeTemplate to be altered
* @param coordinate the value of the coordinate to be set
*/
public static void setLeft(TNodeTemplate nodeTemplate, String coordinate) {
Map<QName, String> otherNodeTemplateAttributes = nodeTemplate.getOtherAttributes();
otherNodeTemplateAttributes.put(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "x"), coordinate);
}

/**
* Sets the y coordinate of a {@link TNodeTemplate}.
*
* @param nodeTemplate the nodeTemplate to be altered
* @param coordinate the value of the coordinate to be set
* @return the altered {@link TNodeTemplate}
*/
public static void setTop(TNodeTemplate nodeTemplate, String coordinate) {
Map<QName, String> otherNodeTemplateAttributes = nodeTemplate.getOtherAttributes();
otherNodeTemplateAttributes.put(new QName(Namespaces.TOSCA_WINERY_EXTENSIONS_NAMESPACE, "y"), coordinate);
}

/**
* This method instantiates a {@link TNodeTemplate} for a given {@link TNodeType}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public Response mergeWithOtherTopologyTemplate(String strOtherServiceTemplateQNa
idMapping.put(nt.getId(), newId);
nt.setId(newId);
int newLeft = Integer.valueOf(ModelUtilities.getLeft((TNodeTemplate) nt)) + shiftLeft.get();
ModelUtilities.setLeft((TNodeTemplate) nt, Integer.toString(newLeft));
((TNodeTemplate) nt).setX(Integer.toString(newLeft));
this.topologyTemplate.getNodeTemplateOrRelationshipTemplate().add(nt);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public void assertGet(String restURL, String fileName) {
JSONAssert.assertEquals(
expectedStr,
receivedStr,
// we allow different ordering in lists and also extensible JSON. That means, more elements are OK.
JSONCompareMode.LENIENT);
// we allow different ordering in lists, but not extensible JSON. That means, more elements are NOT OK. The tests need to be adapted in case new elements come in
JSONCompareMode.NON_EXTENSIBLE);
}
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,51 @@
"otherAttributes": {

},
"relationshipTemplates": [
{
"id": "con_25",
"documentation": [

],
"any": [

],
"otherAttributes": {

},
"type": "{http://winery.opentosca.org/test/ponyuniverse}standsOn",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "straw"
},
"name": "con_25"
},
{
"id": "con_47",
"documentation": [

],
"any": [

],
"otherAttributes": {

},
"properties": {
"any": "<?xml version=\"1.0\" encoding=\"UTF-16\"?>\n<ns3:Properties xmlns=\"http://winery.opentosca.org/test/ponyuniverse/propertiesdefinition/winery\" xmlns:ns0=\"http://winery.opentosca.org/test/ponyuniverse\" xmlns:ns1=\"http://www.eclipse.org/winery/model/selfservice\" xmlns:ns2=\"http://www.eclipse.org/winery/model/selfservice\" xmlns:ns3=\"http://winery.opentosca.org/test/ponyuniverse/propertiesdefinition/winery\" xmlns:tosca=\"http://docs.oasis-open.org/tosca/ns/2011/12\" xmlns:ty=\"http://winery.opentosca.org/test/ponyuniverse\" xmlns:winery=\"http://www.opentosca.org/winery/extensions/tosca/2013/02/12\"><Driver/>\n\t\t\t</ns3:Properties>"
},
"type": "{http://winery.opentosca.org/test/ponyuniverse}attendTo",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "ponycompetition"
},
"name": "con_47"
}
],
"nodeTemplates": [
{
"id": "shetland_pony",
Expand Down Expand Up @@ -46,7 +91,9 @@
},
"name": "shetland_pony",
"minInstances": 1,
"maxInstances": "1"
"maxInstances": "1",
"x": "677",
"y": "161"
},
{
"id": "straw",
Expand All @@ -64,7 +111,9 @@
"type": "{http://winery.opentosca.org/test/ponyuniverse}straw",
"name": "straw",
"minInstances": 1,
"maxInstances": "1"
"maxInstances": "1",
"x": "677",
"y": "545"
},
{
"id": "ponycompetition",
Expand Down Expand Up @@ -118,52 +167,9 @@
},
"name": "ponycompetition",
"minInstances": 1,
"maxInstances": "1"
}
],
"relationshipTemplates": [
{
"id": "con_25",
"documentation": [

],
"any": [

],
"otherAttributes": {

},
"type": "{http://winery.opentosca.org/test/ponyuniverse}standsOn",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "straw"
},
"name": "con_25"
},
{
"id": "con_47",
"documentation": [

],
"any": [

],
"otherAttributes": {

},
"properties": {
"any": "<?xml version=\"1.0\" encoding=\"UTF-16\"?>\n<ns3:Properties xmlns=\"http://winery.opentosca.org/test/ponyuniverse/propertiesdefinition/winery\" xmlns:ns0=\"http://winery.opentosca.org/test/ponyuniverse\" xmlns:ns1=\"http://www.eclipse.org/winery/model/selfservice\" xmlns:ns2=\"http://www.eclipse.org/winery/model/selfservice\" xmlns:ns3=\"http://winery.opentosca.org/test/ponyuniverse/propertiesdefinition/winery\" xmlns:tosca=\"http://docs.oasis-open.org/tosca/ns/2011/12\" xmlns:ty=\"http://winery.opentosca.org/test/ponyuniverse\" xmlns:winery=\"http://www.opentosca.org/winery/extensions/tosca/2013/02/12\"><Driver/>\n\t\t\t</ns3:Properties>"
},
"type": "{http://winery.opentosca.org/test/ponyuniverse}attendTo",
"sourceElement": {
"ref": "shetland_pony"
},
"targetElement": {
"ref": "ponycompetition"
},
"name": "con_47"
"maxInstances": "1",
"x": "1237",
"y": "137"
}
]
}
}
Loading

0 comments on commit 547c1e4

Please sign in to comment.