use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.
the class VersionUtilsTestWithGitBackedRepository method calculateDifferences.
@Test
public void calculateDifferences() throws Exception {
this.setRevisionTo("origin/plain");
ServiceTemplateId oldVersion = new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithFourPolicies", false);
ServiceTemplateId newVersion = new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithFourPolicies_w1-wip1", false);
ToscaDiff diffNode = VersionSupport.calculateDifferences(repository.getElement(oldVersion), repository.getElement(newVersion));
ToscaDiff name = diffNode.getChildrenMap().get("name");
ToscaDiff id = diffNode.getChildrenMap().get("id");
ToscaDiff topology = diffNode.getChildrenMap().get("topologyTemplate");
assertEquals(VersionState.CHANGED, diffNode.getState());
assertEquals(VersionState.CHANGED, name.getState());
assertEquals("ServiceTemplateWithFourPolicies_w1-wip1", name.getNewValue());
assertEquals("ServiceTemplateWithFourPolicies", name.getOldValue());
assertEquals(VersionState.CHANGED, name.getState());
assertEquals("ServiceTemplateWithFourPolicies_w1-wip1", id.getNewValue());
assertEquals("ServiceTemplateWithFourPolicies", id.getOldValue());
assertEquals(VersionState.CHANGED, topology.getState());
assertEquals(2, topology.getChildren().size());
}
use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.
the class VersionUtilsTestWithGitBackedRepository method differencesInServiceTemplatesWithTwoNodeTemplatesAndOneDifferentNodeTemplateReversed.
@Test
public void differencesInServiceTemplatesWithTwoNodeTemplatesAndOneDifferentNodeTemplateReversed() throws Exception {
this.setRevisionTo("origin/plain");
ServiceTemplateId oldVersion = new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithTwoNodeTemplates_w1-wip2", false);
ServiceTemplateId newVersion = new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithTwoNodeTemplates_w1-wip1", false);
ToscaDiff diffNode = VersionSupport.calculateDifferences(repository.getElement(oldVersion), repository.getElement(newVersion));
Map<String, ToscaDiff> nodeTemplateDiff = diffNode.getChildrenMap().get("topologyTemplate").getChildrenMap().get("nodeTemplates").getChildrenMap();
ToscaDiff element1 = nodeTemplateDiff.get("0");
ToscaDiff element2 = nodeTemplateDiff.get("1");
assertEquals("NodeTypeWithOneReqCapPairWithoutProperties", element1.getElement());
assertEquals(VersionState.ADDED, element1.getState());
assertEquals("NodeTypeWithXmlElementProperty", element2.getElement());
assertEquals(VersionState.REMOVED, element2.getState());
assertEquals(VersionState.CHANGED, diffNode.getState());
}
use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.
the class VersionUtilsTestWithGitBackedRepository method getDifferencesListWithOnlyOneChange.
@Test
public void getDifferencesListWithOnlyOneChange() throws Exception {
this.setRevisionTo("origin/plain");
NodeTypeId oldVersion = new NodeTypeId("http://opentosca.org/nodetypes", "NodeTypeWith5Versions_0.3.0-w2", false);
NodeTypeId newVersion = new NodeTypeId("http://opentosca.org/nodetypes", "NodeTypeWith5Versions_0.3.4-w1", false);
ToscaDiff toscaDiff = VersionSupport.calculateDifferences(repository.getElement(oldVersion), repository.getElement(newVersion));
assertEquals("## Changes from version 0.3.0-w2 to 0.3.4-w1\n" + "\n" + "### Changed\n" + "- QName/localPart\n" + " changed from \"NodeTypeWith5Versions_0.3.0-w2\" to \"NodeTypeWith5Versions_0.3.4-w1\"\n" + "- name\n" + " changed from \"NodeTypeWith5Versions_0.3.0-w2\" to \"NodeTypeWith5Versions_0.3.4-w1\"", toscaDiff.getChangeLog());
}
use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.
the class VersionUtilsTestWithGitBackedRepository method getDifferencesList.
@Test
public void getDifferencesList() throws Exception {
this.setRevisionTo("origin/plain");
ServiceTemplateId oldVersion = new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithTwoNodeTemplates_w1-wip3", false);
ServiceTemplateId newVersion = new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithTwoNodeTemplates_w1-wip4", false);
ToscaDiff diffNode = VersionSupport.calculateDifferences(repository.getElement(oldVersion), repository.getElement(newVersion));
assertEquals("## Changes from version w1-wip3 to w1-wip4\n" + "\n" + "### Added\n" + "- topologyTemplate/nodeTemplates/NodeTypeWithTwoKVProperties_2\n" + "- topologyTemplate/nodeTemplates/NodeTypeWithTwoKVProperties/deploymentArtifacts\n" + "- topologyTemplate/relationshipTemplates/NodeTypeWithTwoKVProperties_RelationshlpTypeWithValidSourceAndTarget_w1-wip1_NodeTypeWithTwoKVProperties_2\n" + "\n" + "### Changed\n" + "- id\n" + " changed from \"ServiceTemplateWithTwoNodeTemplates_w1-wip3\" to \"ServiceTemplateWithTwoNodeTemplates_w1-wip4\"\n" + "- name\n" + " changed from \"ServiceTemplateWithTwoNodeTemplates_w1-wip3\" to \"ServiceTemplateWithTwoNodeTemplates_w1-wip4\"\n" + "- topologyTemplate/nodeTemplates/NodeTypeWithTwoKVProperties/otherAttributes/{{http://www.opentosca.org/winery/extensions/tosca/2013/02/12}x}\n" + " changed from \"399\" to \"400\"\n" + "- topologyTemplate/nodeTemplates/NodeTypeWithTwoKVProperties/x\n" + " changed from \"399\" to \"400\"\n" + "\n" + "### Removed\n" + "- topologyTemplate/nodeTemplates/NodeTypeWithoutProperties\n" + "- topologyTemplate/relationshipTemplates/NodeTypeWithTwoKVProperties_RelationshipTypeWithoutProperties_NodeTypeWithoutProperties", diffNode.getChangeLog());
}
use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.
the class BackendUtilsTestWithGitBackedRepository method detectPropertyChangesInANodeTemplate.
@Test
public void detectPropertyChangesInANodeTemplate() throws Exception {
this.setRevisionTo("origin/plain");
NodeTypeId newVersion = new NodeTypeId("http://plain.winery.opentosca.org/nodetypes", "NodeTypeWithThreeReqCapPairsCoveringAllReqCapVariants_w1-wip2", false);
WineryVersion oldVersion = new WineryVersion("", 1, 1);
ToscaDiff toscaDiff = BackendUtils.compare(newVersion, oldVersion, repository);
ToscaDiff properties = toscaDiff.getChildrenMap().get("winerysPropertiesDefinition").getChildrenMap().get("propertyDefinitions");
assertEquals(VersionState.CHANGED, toscaDiff.getState());
assertEquals(VersionState.CHANGED, properties.getState());
assertEquals(3, properties.getChildren().size());
}
Aggregations