Search in sources :

Example 56 with DefinitionsChildId

use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId 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 57 with DefinitionsChildId

use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId 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 58 with DefinitionsChildId

use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId 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 59 with DefinitionsChildId

use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId 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 60 with DefinitionsChildId

use of org.eclipse.winery.model.ids.definitions.DefinitionsChildId 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

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