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());
}
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));
}
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());
}
Aggregations