Search in sources :

Example 11 with ToscaDiff

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());
}
Also used : ToscaDiff(org.eclipse.winery.model.version.ToscaDiff) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) Test(org.junit.jupiter.api.Test)

Example 12 with ToscaDiff

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());
}
Also used : ToscaDiff(org.eclipse.winery.model.version.ToscaDiff) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) Test(org.junit.jupiter.api.Test)

Example 13 with ToscaDiff

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());
}
Also used : ToscaDiff(org.eclipse.winery.model.version.ToscaDiff) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) Test(org.junit.jupiter.api.Test)

Example 14 with ToscaDiff

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());
}
Also used : ToscaDiff(org.eclipse.winery.model.version.ToscaDiff) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) Test(org.junit.jupiter.api.Test)

Example 15 with ToscaDiff

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());
}
Also used : ToscaDiff(org.eclipse.winery.model.version.ToscaDiff) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) WineryVersion(org.eclipse.winery.common.version.WineryVersion) Test(org.junit.jupiter.api.Test)

Aggregations

ToscaDiff (org.eclipse.winery.model.version.ToscaDiff)15 Test (org.junit.jupiter.api.Test)14 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)11 WineryVersion (org.eclipse.winery.common.version.WineryVersion)3 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)3 IOException (java.io.IOException)1 GET (javax.ws.rs.GET)1 NotFoundException (javax.ws.rs.NotFoundException)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 JAXBException (javax.xml.bind.JAXBException)1 QNameWithTypeApiData (org.eclipse.winery.repository.rest.resources.apiData.QNameWithTypeApiData)1 SAXException (org.xml.sax.SAXException)1