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());
}
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());
}
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());
}
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);
}
}
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());
}
Aggregations