Search in sources :

Example 1 with ToscaDiff

use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.

the class VersionUtilsTestWithGitBackedRepository method noDifferencesInServiceTemplatesWithTwoNodeTemplates.

@Test
public void noDifferencesInServiceTemplatesWithTwoNodeTemplates() throws Exception {
    this.setRevisionTo("origin/plain");
    ServiceTemplateId oldVersion = new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithTwoNodeTemplates_w1-wip1", 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));
    assertEquals(VersionState.UNCHANGED, 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 2 with ToscaDiff

use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.

the class VersionUtilsTestWithGitBackedRepository method differencesInServiceTemplateWithChangesInANodeTemplate.

@Test
public void differencesInServiceTemplateWithChangesInANodeTemplate() 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));
    Map<String, ToscaDiff> nodeTemplateDiff = diffNode.getChildrenMap().get("topologyTemplate").getChildrenMap().get("nodeTemplates").getChildrenMap();
    ToscaDiff element1 = nodeTemplateDiff.get("2");
    assertEquals("NodeTypeWithTwoKVProperties", element1.getElement());
    assertEquals(VersionState.CHANGED, element1.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 3 with ToscaDiff

use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.

the class BackendUtilsTestWithGitBackedRepository method detectChangesInANodeTemplate.

@Test
public void detectChangesInANodeTemplate() throws Exception {
    this.setRevisionTo("origin/plain");
    NodeTypeId newVersion = new NodeTypeId("http://plain.winery.opentosca.org/nodetypes", "NodeTypeWithThreeReqCapPairsCoveringAllReqCapVariants_w1-wip1", false);
    WineryVersion oldVersion = new WineryVersion("", 0, 0);
    ToscaDiff toscaDiff = BackendUtils.compare(newVersion, oldVersion, repository);
    ToscaDiff properties = toscaDiff.getChildrenMap().get("winerysPropertiesDefinition");
    assertEquals(VersionState.CHANGED, toscaDiff.getState());
    assertEquals(VersionState.ADDED, properties.getState());
}
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)

Example 4 with ToscaDiff

use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.

the class AbstractComponentInstanceResource method getElementAsJson.

@GET
@Produces(MediaType.APPLICATION_JSON)
public Object getElementAsJson(@QueryParam("versions") @ApiParam("If set, a list of available versions is returned.") String versions, @QueryParam("subComponents") String subComponents, @QueryParam("compareTo") String compareTo, @QueryParam("asChangeLog") String asChangeLog) {
    if (!requestRepository.exists(this.id)) {
        throw new NotFoundException();
    }
    try {
        if (Objects.nonNull(versions)) {
            return WineryVersionUtils.getAllVersionsOfOneDefinition(this.id, requestRepository);
        } else if (Objects.nonNull(subComponents)) {
            return requestRepository.getReferencedDefinitionsChildIds(this.id).stream().map(item -> new QNameWithTypeApiData(item.getXmlId().getDecoded(), item.getNamespace().getDecoded(), item.getGroup())).collect(Collectors.toList());
        } else if (Objects.nonNull(compareTo)) {
            WineryVersion version = VersionUtils.getVersion(compareTo);
            ToscaDiff compare = BackendUtils.compare(this.id, version, requestRepository);
            if (Objects.nonNull(asChangeLog)) {
                return compare.getChangeLog();
            } else {
                return compare;
            }
        } else {
            return BackendUtils.getDefinitionsHavingCorrectImports(requestRepository, this.id);
        }
    } catch (Exception e) {
        LOGGER.warn("Failed to return element at {} as JSON due to exception.", this.id, e);
        throw new WebApplicationException(e);
    }
}
Also used : ToscaDiff(org.eclipse.winery.model.version.ToscaDiff) QNameWithTypeApiData(org.eclipse.winery.repository.rest.resources.apiData.QNameWithTypeApiData) WebApplicationException(javax.ws.rs.WebApplicationException) NotFoundException(javax.ws.rs.NotFoundException) JAXBException(javax.xml.bind.JAXBException) NotFoundException(javax.ws.rs.NotFoundException) SAXException(org.xml.sax.SAXException) WebApplicationException(javax.ws.rs.WebApplicationException) IOException(java.io.IOException) WineryVersion(org.eclipse.winery.common.version.WineryVersion) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with ToscaDiff

use of org.eclipse.winery.model.version.ToscaDiff in project winery by eclipse.

the class VersionUtilsTestWithGitBackedRepository method noDifferencesInServiceTemplate.

@Test
public void noDifferencesInServiceTemplate() throws Exception {
    this.setRevisionTo("origin/plain");
    ServiceTemplateId oldVersion = new ServiceTemplateId("http://plain.winery.opentosca.org/servicetemplates", "ServiceTemplateWithFourPolicies_w1-wip1", 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));
    assertEquals(VersionState.UNCHANGED, 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)

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