Search in sources :

Example 41 with ServiceTemplateId

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

the class XmlRepositoryIntegrationTests method testGroupDefinitions.

@Test
public void testGroupDefinitions() throws Exception {
    // Setup test
    ServiceTemplateId id = new ServiceTemplateId(QName.valueOf("{http://plain.winery.opentosca.org/servicetemplates}ServiceTemplateWithOneNodeTemplate_w1-wip1"));
    TServiceTemplate element = repository.getElement(id);
    assertNotNull(element.getTopologyTemplate());
    TNodeTemplate nodeTemplate = element.getTopologyTemplate().getNodeTemplate("NodeTypeWith5Versions_0_3.4-w3-wip1");
    assertNotNull(nodeTemplate);
    TGroupDefinition testGroup = new TGroupDefinition.Builder("test", QName.valueOf("{tosca.groups}Root")).setDescription("test").build();
    if (element.getTags() == null) {
        element.setTags(new ArrayList<>());
    }
    element.getTags().add(new TTag.Builder("test", "test").build());
    // Save group
    element.getTopologyTemplate().addGroup(testGroup);
    BackendUtils.persist(repository, id, element);
    // Assertions
    element = repository.getElement(id);
    assertNotNull(element.getTopologyTemplate());
    assertNotNull(element.getTopologyTemplate().getGroups());
    assertEquals(1, element.getTopologyTemplate().getGroups().size());
    TGroupDefinition actualGroup = element.getTopologyTemplate().getGroups().get(0);
    assertEquals(testGroup.getDescription(), actualGroup.getDescription());
    assertTrue(testGroup.getMembers().isEmpty());
    assertNotNull(element.getTags());
    assertEquals(1, element.getTags().size());
}
Also used : TGroupDefinition(org.eclipse.winery.model.tosca.TGroupDefinition) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) Test(org.junit.jupiter.api.Test)

Example 42 with ServiceTemplateId

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

Example 43 with ServiceTemplateId

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

Example 44 with ServiceTemplateId

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

the class InstanceModelUtilsTest method testGetSshProps.

@Test
void testGetSshProps() throws Exception {
    this.setRevisionTo("origin/plain");
    TServiceTemplate serviceTemplate = this.repository.getElement(new ServiceTemplateId("http://opentosca.org/servicetemplates", "SshTest_w1-wip1", false));
    Set<String> sshProps = InstanceModelUtils.getRequiredSSHInputs(serviceTemplate.getTopologyTemplate(), Collections.singletonList("OperatingSystem_0"));
    assertNotNull(sshProps);
    assertEquals(3, sshProps.size());
}
Also used : ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) Test(org.junit.jupiter.api.Test)

Example 45 with ServiceTemplateId

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

the class InstanceModelUtilsTest method executeCommandTest.

@Test
void executeCommandTest() throws Exception {
    this.setRevisionTo("origin/plain");
    TServiceTemplate serviceTemplate = this.repository.getElement(new ServiceTemplateId("http://opentosca.org/servicetemplates", "SshTest_w1-wip1", false));
    String expectedOutput = "success";
    sshd.setCommandFactory((channel, command) -> new SupportSuccessCommand(command) {

        @Override
        public String getReturnValue() {
            return expectedOutput;
        }
    });
    Session session = getSession(serviceTemplate);
    String pwd = InstanceModelUtils.executeCommand(session, "pwd");
    assertNotNull(pwd);
    assertEquals(expectedOutput, pwd);
}
Also used : ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) Session(com.jcraft.jsch.Session) Test(org.junit.jupiter.api.Test)

Aggregations

ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)126 Test (org.junit.jupiter.api.Test)73 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)44 ArrayList (java.util.ArrayList)41 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)40 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)35 QName (javax.xml.namespace.QName)25 IOException (java.io.IOException)24 IRepository (org.eclipse.winery.repository.backend.IRepository)19 List (java.util.List)17 POST (javax.ws.rs.POST)17 Path (javax.ws.rs.Path)16 Produces (javax.ws.rs.Produces)16 HashMap (java.util.HashMap)15 TopologyWrapper (org.eclipse.winery.repository.targetallocation.util.TopologyWrapper)15 Map (java.util.Map)14 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)14 URI (java.net.URI)13 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)13 TNodeType (org.eclipse.winery.model.tosca.TNodeType)13