Search in sources :

Example 41 with NodeTypeId

use of org.eclipse.winery.model.ids.definitions.NodeTypeId in project winery by eclipse.

the class RestUtilsWithGitBackendTest method renameDefinitionWithoutVersion.

@Test
public void renameDefinitionWithoutVersion() throws Exception {
    this.setRevisionTo("origin/plain");
    String oldName = "NodeTypeWithOneReqCapPairWithoutProperties";
    String newName = "exampleName";
    String namespace = "http://plain.winery.opentosca.org/nodetypes";
    DefinitionsChildId oldId = new NodeTypeId(namespace, oldName, false);
    DefinitionsChildId newId = new NodeTypeId(namespace, newName, false);
    Response response = RestUtils.rename(oldId, newId).getResponse();
    String expectedEntity = "http://localhost:8080/winery/nodetypes/" + EncodingUtil.URLencode(EncodingUtil.URLencode(namespace)) + "/" + newName + "/";
    assertEquals(201, response.getStatus());
    assertEquals(expectedEntity, response.getEntity());
}
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 42 with NodeTypeId

use of org.eclipse.winery.model.ids.definitions.NodeTypeId in project winery by eclipse.

the class RestUtilsWithGitBackendTest method renameDefinitionNamespaceWithoutVersion.

@Test
public void renameDefinitionNamespaceWithoutVersion() throws Exception {
    this.setRevisionTo("origin/plain");
    String name = "NodeTypeWithOneReqCapPairWithoutProperties";
    String newNamespace = "http://example.org/nodetypes";
    String oldNamespace = "http://plain.winery.opentosca.org/nodetypes";
    DefinitionsChildId oldId = new NodeTypeId(oldNamespace, name, false);
    DefinitionsChildId newId = new NodeTypeId(newNamespace, name, false);
    Response response = RestUtils.rename(oldId, newId).getResponse();
    String expectedEntity = "http://localhost:8080/winery/nodetypes/" + EncodingUtil.URLencode(EncodingUtil.URLencode(newNamespace)) + "/" + name + "/";
    assertEquals(201, response.getStatus());
    assertEquals(expectedEntity, response.getEntity());
}
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 43 with NodeTypeId

use of org.eclipse.winery.model.ids.definitions.NodeTypeId in project winery by eclipse.

the class RestUtilsWithGitBackendTest method renameSingleDefinitionWhichHasChanges.

@Test
public void renameSingleDefinitionWhichHasChanges() throws Exception {
    this.setRevisionTo("origin/plain");
    String version = "_0.3.4-w3";
    String otherVersion = version + "-wip3";
    String oldName = "NodeTypeWith5Versions";
    String newName = "exampleName";
    String namespace = "http://opentosca.org/nodetypes";
    NodeTypeId oldId = new NodeTypeId(namespace, oldName + version, false);
    DefinitionsChildId newId = new NodeTypeId(namespace, newName + version, false);
    // required because oldId doesn't exist anymore after the rename
    DefinitionsChildId otherElement = new NodeTypeId(namespace, oldName + otherVersion, false);
    makeSomeChanges(oldId);
    Response response = RestUtils.rename(oldId, newId).getResponse();
    String expectedEntity = "http://localhost:8080/winery/nodetypes/" + EncodingUtil.URLencode(EncodingUtil.URLencode(namespace)) + "/" + newName + version + "/";
    assertEquals(201, response.getStatus());
    assertEquals(expectedEntity, response.getEntity());
    assertEquals(4, WineryVersionUtils.getAllVersionsOfOneDefinition(otherElement, repository).size());
    assertEquals(1, 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 44 with NodeTypeId

use of org.eclipse.winery.model.ids.definitions.NodeTypeId in project winery by eclipse.

the class RestUtilsWithGitBackendTest method renameSingleDefinitionNamespaceWithVersion.

@Test
public void renameSingleDefinitionNamespaceWithVersion() 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.rename(oldId, newId).getResponse();
    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(1, 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 45 with NodeTypeId

use of org.eclipse.winery.model.ids.definitions.NodeTypeId in project winery by eclipse.

the class RestUtilsWithGitBackendTest method renameSingleDefinitionWithVersion.

@Test
public void renameSingleDefinitionWithVersion() throws Exception {
    this.setRevisionTo("origin/plain");
    String version = "_0.3.4-w3";
    String oldName = "NodeTypeWith5Versions";
    String newName = "exampleName";
    String namespace = "http://opentosca.org/nodetypes";
    DefinitionsChildId oldId = new NodeTypeId(namespace, oldName + version, false);
    DefinitionsChildId newId = new NodeTypeId(namespace, newName + version, false);
    Response response = RestUtils.rename(oldId, newId).getResponse();
    String expectedEntity = "http://localhost:8080/winery/nodetypes/" + EncodingUtil.URLencode(EncodingUtil.URLencode(namespace)) + "/" + newName + version + "/";
    assertEquals(201, response.getStatus());
    assertEquals(expectedEntity, response.getEntity());
    assertEquals(5, WineryVersionUtils.getAllVersionsOfOneDefinition(oldId, repository).size());
    assertEquals(1, 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)

Aggregations

NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)67 TNodeType (org.eclipse.winery.model.tosca.TNodeType)36 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)28 Test (org.junit.jupiter.api.Test)27 DefinitionsChildId (org.eclipse.winery.model.ids.definitions.DefinitionsChildId)23 QName (javax.xml.namespace.QName)21 IRepository (org.eclipse.winery.repository.backend.IRepository)20 RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)15 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)15 WineryVersion (org.eclipse.winery.common.version.WineryVersion)14 Response (javax.ws.rs.core.Response)13 IOException (java.io.IOException)12 LinkedHashMap (java.util.LinkedHashMap)12 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)11 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)11 ArtifactTemplateId (org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)10 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)10 ArrayList (java.util.ArrayList)9 TDefinitions (org.eclipse.winery.model.tosca.TDefinitions)9 TEntityTemplate (org.eclipse.winery.model.tosca.TEntityTemplate)9