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