use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.
the class DefaultNodeMatcherTest method setUp.
@Before
public void setUp() throws Exception {
this.nodeMatcher = new DefaultNodeMatcher();
this.computeNodeType = nodeType("org.alien4cloud.nodes.mock.aws.Compute", "tosca.nodes.Compute");
this.computeNodeTemplate = nodeTemplate("org.alien4cloud.nodes.mock.aws.Compute");
NodeType mongoDbNodeType = nodeType("alien.service.MongoDB", "", "tosca.service.ServiceType", "test.nodes.DB");
NodeTemplate mongoDbNodeTemplate = nodeTemplate("alien.service.MongoDB");
LocationResourceTemplate mongoDbLocationTemplate = locationResourceTemplate(mongoDbNodeTemplate);
mongoDbLocationTemplate.setService(true);
locationResources = new LocationResources();
//
locationResources.setNodeTemplates(//
Arrays.asList(//
locationResourceTemplate(computeNodeTemplate), //
mongoDbLocationTemplate));
//
locationResources.setNodeTypes(//
ImmutableMap.of(//
computeNodeType.getElementId(), //
computeNodeType, //
mongoDbNodeType.getElementId(), //
mongoDbNodeType));
}
use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.
the class DefaultNodeMatcherTest method abstract_template_should_be_matched_if_service_is_available.
@Test
public void abstract_template_should_be_matched_if_service_is_available() throws Exception {
// Given
Map<String, MatchingConfiguration> emptyMatchingConfigurations = new HashMap<>();
// When
NodeTemplate wantedNodeTemplate = nodeTemplate("test.nodes.DB");
NodeType wantedNodeType = new NodeType();
wantedNodeType.setAbstract(true);
List<LocationResourceTemplate> proposition = nodeMatcher.matchNode(wantedNodeTemplate, wantedNodeType, locationResources, emptyMatchingConfigurations);
// Then
assertThat(proposition).hasSize(1);
assertThat(proposition.get(0).isService()).isTrue();
}
use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.
the class DefaultNodeMatcherTest method locationResourceTemplate.
private LocationResourceTemplate locationResourceTemplate(NodeTemplate nodeTemplate) {
LocationResourceTemplate locationResourceTemplate = new LocationResourceTemplate();
locationResourceTemplate.setTemplate(nodeTemplate);
return locationResourceTemplate;
}
use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.
the class LocationResourceServiceTest method getResourcesOfTypeForUnconfiguredTypeShouldReturnEmptyList.
@Test
public void getResourcesOfTypeForUnconfiguredTypeShouldReturnEmptyList() {
ILocationResourceAccessor accessor = locationResourceService.accessor(LOCATION_ID);
List<LocationResourceTemplate> resources = accessor.getResources(UNCONFIGURED_TYPE);
Assert.assertEquals(0, resources.size());
}
use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.
the class LocationResourceServiceTest method initLocation.
private void initLocation(String locationId) {
Location location = new Location();
location.setId(LOCATION_ID);
alienDAO.save(location);
location.setId(UNCONFIGURED_LOCATION_ID);
alienDAO.save(location);
for (int i = 0; i < 5; i++) {
for (int j = 0; j < TYPE_CONFIGURED_ELEMENTS; j++) {
String type = i == 0 ? CONFIGURED_TYPE : CONFIGURED_TYPE + "." + i;
NodeTemplate template = new NodeTemplate();
template.setType(type);
template.setName("template_" + i + "_" + j);
LocationResourceTemplate lrt = new LocationResourceTemplate();
lrt.setId(UUID.randomUUID().toString());
lrt.setLocationId(locationId);
lrt.setGenerated(false);
lrt.setEnabled(true);
lrt.setService(false);
lrt.setTemplate(template);
lrt.setTypes(Lists.newArrayList(template.getType()));
alienDAO.save(lrt);
}
}
}
Aggregations