Search in sources :

Example 1 with TGroupDefinition

use of org.eclipse.winery.model.tosca.TGroupDefinition 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 2 with TGroupDefinition

use of org.eclipse.winery.model.tosca.TGroupDefinition in project winery by eclipse.

the class YamlRepositoryIntegrationTests method testGroupDefinitions.

@Test
public void testGroupDefinitions() throws Exception {
    this.setRevisionTo("origin/yaml");
    // Setup test
    ServiceTemplateId id = new ServiceTemplateId(QName.valueOf("{example.org.tosca.servicetemplates}demo_w1-wip1"));
    TServiceTemplate element = repository.getElement(id);
    assertNotNull(element.getTopologyTemplate());
    TNodeTemplate nodeTemplate = element.getTopologyTemplate().getNodeTemplate("compute_w1-wip1_0");
    assertNotNull(nodeTemplate);
    TGroupDefinition testGroup = new TGroupDefinition.Builder("test", QName.valueOf("{tosca.groups}Root")).setDescription("This is a description").addMembers(QName.valueOf(nodeTemplate.getId())).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());
    assertEquals(testGroup.getMembers().get(0), actualGroup.getMembers().get(0));
}
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 3 with TGroupDefinition

use of org.eclipse.winery.model.tosca.TGroupDefinition in project winery by eclipse.

the class YamlRepositoryIntegrationTests method testCreateGroupWithNoType.

@Test
public void testCreateGroupWithNoType() throws Exception {
    this.setRevisionTo("origin/yaml");
    // Setup test
    ServiceTemplateId id = new ServiceTemplateId(QName.valueOf("{example.org.tosca.servicetemplates}demo_w1-wip1"));
    TServiceTemplate element = repository.getElement(id);
    assertNotNull(element.getTopologyTemplate());
    TNodeTemplate nodeTemplate = element.getTopologyTemplate().getNodeTemplate("compute_w1-wip1_0");
    assertNotNull(nodeTemplate);
    TGroupDefinition testGroup = new TGroupDefinition.Builder("test", null).setDescription("This is a description").addMembers(QName.valueOf(nodeTemplate.getId())).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(QName.valueOf("{tosca.groups}Root"), actualGroup.getType());
}
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)

Aggregations

ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)3 TGroupDefinition (org.eclipse.winery.model.tosca.TGroupDefinition)3 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)3 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)3 Test (org.junit.jupiter.api.Test)3