use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId in project winery by eclipse.
the class VersionSupportTest method getNameWithoutVersionFromDefinitionsChildId.
@Test
public void getNameWithoutVersionFromDefinitionsChildId() {
String name = "myElementTest";
DefinitionsChildId id = getDefinitionChildId("http://example.org/tosca/versions", name, "1.2.3", 1, 1);
assertEquals(name, id.getNameWithoutVersion());
}
use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId in project winery by eclipse.
the class VersionSupportTest method getQNameWithComponentVersionOnly.
@Test
public void getQNameWithComponentVersionOnly() {
String name = "myElementTest";
String namespace = "http://example.org/tosca/versions";
String componentVersion = "1.2.3";
DefinitionsChildId id = getDefinitionChildId(namespace, name, componentVersion, 1, 1);
assertEquals("{" + namespace + "}" + name + WineryVersion.WINERY_VERSION_SEPARATOR + componentVersion, VersionSupport.getQNameWithComponentVersionOnly(id));
}
use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId in project winery by eclipse.
the class IdUtil method getPathFragment.
/**
* Executes the real conversion to a path fragment
*
* @param id the id to transform to a path
* @param doubleEncode true if each sub fragment should be double encoded,
* false if it should be encoded only once
*/
private static String getPathFragment(final GenericId id, final boolean doubleEncode) {
String toInsert;
if (id instanceof DefinitionsChildId) {
// @return "[ComponentName]s/{namespace}/{id}/"
DefinitionsChildId tId = (DefinitionsChildId) id;
String res = IdUtil.getRootPathFragment(tId.getClass());
toInsert = tId.getNamespace().getEncoded();
if (doubleEncode) {
toInsert = EncodingUtil.URLencode(toInsert);
}
res = res + toInsert + "/";
toInsert = tId.getXmlId().getEncoded();
if (doubleEncode) {
toInsert = EncodingUtil.URLencode(toInsert);
}
res = res + toInsert + "/";
return res;
} else if (id instanceof ToscaElementId) {
toInsert = id.getXmlId().getEncoded();
if (doubleEncode) {
toInsert = EncodingUtil.URLencode(toInsert);
}
return IdUtil.getPathFragment(id.getParent()) + toInsert + "/";
} else {
throw new IllegalStateException("Unknown subclass of GenericId " + id.getClass());
}
}
use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId in project winery by eclipse.
the class RestUtilsWithGitBackendTest method renameAllVersionNamespacesOfOneComponent.
@Test
public void renameAllVersionNamespacesOfOneComponent() throws Exception {
this.setRevisionTo("origin/plain");
String version = "_0.3.4-w3";
String name = "NodeTypeWith5Versions";
String oldNamespace = "http://opentosca.org/nodetypes";
String newNamespace = "http://example.org/nodetypes";
DefinitionsChildId oldId = new NodeTypeId(oldNamespace, name + version, false);
DefinitionsChildId newId = new NodeTypeId(newNamespace, name + version, false);
Response response = RestUtils.renameAllVersionsOfOneDefinition(oldId, newId);
String expectedEntity = "http://localhost:8080/winery/nodetypes/" + EncodingUtil.URLencode(EncodingUtil.URLencode(newNamespace)) + "/" + name + version + "/";
assertEquals(201, response.getStatus());
assertEquals(expectedEntity, response.getEntity());
assertEquals(5, WineryVersionUtils.getAllVersionsOfOneDefinition(oldId, repository).size());
assertEquals(5, WineryVersionUtils.getAllVersionsOfOneDefinition(newId, repository).size());
}
use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId in project winery by eclipse.
the class RestUtilsWithGitBackendTest method releaseComponentWhichDoesNotHaveChanges.
@Test
public void releaseComponentWhichDoesNotHaveChanges() throws Exception {
this.setRevisionTo("origin/plain");
DefinitionsChildId id = new NodeTypeId("http://opentosca.org/nodetypes", "NodeTypeWithALowerReleasableManagementVersion_2-w2-wip1", false);
DefinitionsChildId releasedId = new NodeTypeId("http://opentosca.org/nodetypes", "NodeTypeWithALowerReleasableManagementVersion_2-w2", false);
int formerVersionCount = WineryVersionUtils.getAllVersionsOfOneDefinition(id, repository).size();
Response response = RestUtils.releaseVersion(id);
int finalVersionCount = WineryVersionUtils.getAllVersionsOfOneDefinition(releasedId, repository).size();
WineryVersion version = WineryVersionUtils.getCurrentVersionWithAllFlags(releasedId, repository);
assertEquals(201, response.getStatus());
assertEquals(formerVersionCount + 1, finalVersionCount);
assertFalse(version.isReleasable());
assertEquals(0, version.getWorkInProgressVersion());
}
Aggregations