Search in sources :

Example 51 with DefinitionsChildId

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

Example 52 with DefinitionsChildId

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

Example 53 with DefinitionsChildId

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());
    }
}
Also used : ToscaElementId(org.eclipse.winery.model.ids.elements.ToscaElementId) DefinitionsChildId(org.eclipse.winery.model.ids.definitions.DefinitionsChildId)

Example 54 with DefinitionsChildId

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());
}
Also used : Response(javax.ws.rs.core.Response) DefinitionsChildId(org.eclipse.winery.model.ids.definitions.DefinitionsChildId) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) Test(org.junit.jupiter.api.Test)

Example 55 with DefinitionsChildId

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

Aggregations

DefinitionsChildId (org.eclipse.winery.model.ids.definitions.DefinitionsChildId)77 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)29 Test (org.junit.jupiter.api.Test)21 QName (javax.xml.namespace.QName)19 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)17 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)16 TDefinitions (org.eclipse.winery.model.tosca.TDefinitions)16 HashMap (java.util.HashMap)15 IRepository (org.eclipse.winery.repository.backend.IRepository)14 TNodeType (org.eclipse.winery.model.tosca.TNodeType)13 Path (java.nio.file.Path)12 Map (java.util.Map)12 RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)12 TExtensibleElements (org.eclipse.winery.model.tosca.TExtensibleElements)12 Logger (org.slf4j.Logger)11 LoggerFactory (org.slf4j.LoggerFactory)11 InputStream (java.io.InputStream)10 HashSet (java.util.HashSet)10 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)10