use of org.alien4cloud.tosca.model.instances.NodeInstance in project alien4cloud by alien4cloud.
the class ServiceResourceServiceTest method testGetByNodeTypes.
@Test
public void testGetByNodeTypes() {
ServiceResource serviceResource = new ServiceResource();
serviceResource.setId("service1");
serviceResource.setNodeInstance(new NodeInstance());
serviceResource.getNodeInstance().setTypeVersion("1.0.0-SNAPSHOT");
serviceResource.getNodeInstance().setNodeTemplate(new NodeTemplate());
serviceResource.getNodeInstance().getNodeTemplate().setType("org.alien4cloud.nodes.MyType");
alienDao.save(serviceResource);
ServiceResource[] services = serviceResourceService.getByNodeTypes("org.alien4cloud.nodes.MyType", "1.0.0-SNAPSHOT");
Assert.assertNotNull(services);
Assert.assertEquals(1, services.length);
services = serviceResourceService.getByNodeTypes("org.alien4cloud.nodes.UnusedType", "1.0.0-SNAPSHOT");
Assert.assertNotNull(services);
Assert.assertEquals(0, services.length);
services = serviceResourceService.getByNodeTypes("org.alien4cloud.nodes.MyType", "1.0.0");
Assert.assertNotNull(services);
Assert.assertEquals(0, services.length);
}
use of org.alien4cloud.tosca.model.instances.NodeInstance in project alien4cloud by alien4cloud.
the class NodeInstanceService method create.
/**
* Create a new instance of a given node type based on default generated template.
*
* @param nodeType The node type out of which to create the version.
* @param typeVersion The node instance type's version.
* @return An instance that matches the given type created from a default template (default values). Note that the node instance may be constructed from an
* invalid template (missing required properties) without errors. State of the node is set to initial.
*/
@ToscaContextual
public NodeInstance create(NodeType nodeType, String typeVersion) {
NodeTemplate nodeTemplate = TemplateBuilder.buildNodeTemplate(nodeType, null);
NodeInstance instance = new NodeInstance();
instance.setAttribute(ToscaNodeLifecycleConstants.ATT_STATE, ToscaNodeLifecycleConstants.INITIAL);
instance.setNodeTemplate(nodeTemplate);
instance.setTypeVersion(typeVersion);
return instance;
}
Aggregations