blob: 42b6db0e71f668739f605528a412ccce20020b50 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package org.openecomp.sdc.translator.services.heattotosca.impl;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.translator.services.heattotosca.helper.ContrailTranslationHelper;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import java.util.HashMap;
import java.util.Map;
/**
* @author shiria
* @since August 09, 2016.
*/
public class ResourceTranslationContrailServiceTemplateImplTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testStaticGetComputeNodeTypeId() throws Exception {
Resource serviceTemplate = new Resource();
serviceTemplate.setProperties(new HashMap<>());
serviceTemplate.getProperties().put("image_name", "aaaa");
String computeNodeTypeId =
new ContrailTranslationHelper().getComputeNodeTypeId("123", serviceTemplate);
Assert.assertEquals("org.openecomp.resource.vfc.nodes.heat.compute_123", computeNodeTypeId);
}
@Test
public void testNamingConventionGetComputeNodeTypeId() throws Exception {
Resource serviceTemplate = new Resource();
serviceTemplate.setProperties(new HashMap<>());
Map image = new HashMap<>();
image.put("get_param", "bbb_image_name");
serviceTemplate.getProperties().put("image_name", image);
String computeNodeTypeId =
new ContrailTranslationHelper().getComputeNodeTypeId("123", serviceTemplate);
Assert.assertEquals(computeNodeTypeId, "org.openecomp.resource.vfc.nodes.heat.bbb");
}
@Test
public void testNoNamingConventionGetComputeNodeTypeId() throws Exception {
Resource serviceTemplate = new Resource();
serviceTemplate.setProperties(new HashMap<>());
Map image = new HashMap<>();
image.put("get_file", "bbb_image");
serviceTemplate.getProperties().put("image_name", image);
String computeNodeTypeId =
new ContrailTranslationHelper().getComputeNodeTypeId("123", serviceTemplate);
Assert.assertEquals(computeNodeTypeId, "org.openecomp.resource.vfc.nodes.heat.compute_123");
}
}
|