diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/test')
-rw-r--r-- | openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java index d9e77e1f84..0f79ed05d6 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/test/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImplTest.java @@ -44,6 +44,11 @@ import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class ToscaAnalyzerServiceImplTest { + + public static final String CAPABILITY_TYPE_A = "capabilityTypeA"; + public static final String CAPABILITY_TYPE_B = "capabilityTypeB"; + public static final String TOSCA_CAPABILITIES_ROOT = "tosca.capabilities.Root"; + /* Dictionary: SrvTmp: ServiceTemplate @@ -874,4 +879,39 @@ public class ToscaAnalyzerServiceImplTest { // not found at all should throw core exception + + @Test + public void capabilityDefinitionIsTypeOfDirectTypeFound() { + CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); + capabilityDefinition.setType(CAPABILITY_TYPE_A); + assertTrue(toscaAnalyzerService.isTypeOf(capabilityDefinition, CAPABILITY_TYPE_A, new ServiceTemplate(), + toscaServiceModelMock)); + } + + @Test + public void capabilityDefinitionIsTypeOfReturnNo() { + CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); + capabilityDefinition.setType(CAPABILITY_TYPE_A); + ServiceTemplate serviceTemplate = new ServiceTemplate(); + serviceTemplate.setCapability_types(new HashMap<>()); + CapabilityType capabilityType = new CapabilityType(); + capabilityType.setDerived_from(TOSCA_CAPABILITIES_ROOT); + serviceTemplate.getCapability_types().put(CAPABILITY_TYPE_A, capabilityType); + assertFalse(toscaAnalyzerService + .isTypeOf(capabilityDefinition, CAPABILITY_TYPE_B, serviceTemplate, toscaServiceModelMock)); + } + + @Test + public void capabilityDefinitionIsTypeOfInheritanceTypeFound() { + CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); + capabilityDefinition.setType(CAPABILITY_TYPE_A); + ServiceTemplate serviceTemplate = new ServiceTemplate(); + serviceTemplate.setCapability_types(new HashMap<>()); + CapabilityType capabilityType = new CapabilityType(); + capabilityType.setDerived_from(CAPABILITY_TYPE_B); + serviceTemplate.getCapability_types().put(CAPABILITY_TYPE_A, capabilityType); + assertTrue(toscaAnalyzerService + .isTypeOf(capabilityDefinition, CAPABILITY_TYPE_B, serviceTemplate, toscaServiceModelMock)); + } + } |