<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
- <!-- Enables any legacy JUnit 3 and JUnit 4 tests you may have. Not needed for JUnit 5 tests. -->
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<reporting>
*/
package org.onap.sdc.toscaparser.api;
-import org.junit.Test;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.toscaparser.api.common.JToscaException;
import org.onap.sdc.toscaparser.api.elements.DataType;
import org.onap.sdc.toscaparser.api.elements.PropertyDef;
import org.onap.sdc.toscaparser.api.parameters.Input;
import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
-import java.io.File;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.*;
-
public class JToscaImportTest {
@Test
public void testNoMissingTypeValidationError() throws JToscaException {
String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/sdc-onboarding_csar.csar")
- .getFile();
+ .getFile();
File file = new File(fileStr);
new ToscaTemplate(file.getAbsolutePath(), null, true, null);
List<String> missingTypeErrors = ThreadLocalsHolder.getCollector().getValidationIssueReport().stream()
- .filter(s -> s.contains("JE136")).collect(Collectors.toList());
+ .filter(s -> s.contains("JE136")).collect(Collectors.toList());
assertEquals(0, missingTypeErrors.size());
}
Exception jte = null;
try {
String fileStr = JToscaImportTest.class.getClassLoader().getResource("csars/sdc-onboarding_csar.csar")
- .getFile();
+ .getFile();
File file = new File(fileStr);
new ToscaTemplate(file.getAbsolutePath(), null, true, null);
} catch (Exception e) {
File file = new File(fileStr);
new ToscaTemplate(file.getAbsolutePath(), null, true, null);
List<String> invalidImportErrors = ThreadLocalsHolder.getCollector().getValidationIssueReport().stream()
- .filter(s -> s.contains("JE195")).collect(Collectors.toList());
+ .filter(s -> s.contains("JE195")).collect(Collectors.toList());
assertEquals(0, invalidImportErrors.size());
}
}
private void validateInputsAnnotations(List<Input> inputs) {
List<Input> inputsWithAnnotations = inputs.stream().filter(i -> i.getAnnotations() != null)
- .collect(Collectors.toList());
+ .collect(Collectors.toList());
assertTrue(!inputs.isEmpty());
inputsWithAnnotations.stream().forEach(i -> validateAnnotations(i));
}
assertEquals(annotation.getType().toLowerCase(), "org.openecomp.annotations.source");
assertNotNull(annotation.getProperties());
Optional<Property> source_type = annotation.getProperties().stream()
- .filter(p -> p.getName().equals("source_type")).findFirst();
+ .filter(p -> p.getName().equals("source_type")).findFirst();
assertTrue(source_type.isPresent());
assertEquals(source_type.get().getValue(), "HEAT");
}
assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.LIST));
assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA), is(TEST_DATATYPE_TEST1));
- assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1), notNullValue());
- assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2), notNullValue());
+ assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1),
+ notNullValue());
+ assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2),
+ notNullValue());
assertThat(toscaTemplate.toString(), containsString(TEST_DATATYPE_TOSTRING));
}
}
assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_TYPE), is(Schema.LIST));
assertThat(property.getSchema().get(TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA), is(TEST_DATATYPE_TEST1));
- assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1), notNullValue());
- assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2), notNullValue());
+ assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST1),
+ notNullValue());
+ assertThat((LinkedHashMap<String, Object>) toscaTemplate.getTopologyTemplate().getCustomDefs().get(TEST_DATATYPE_TEST2),
+ notNullValue());
assertThat(toscaTemplate.toString(), containsString(TEST_DATATYPE_TOSTRING));
}
}
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
-
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.toscaparser.api.common.JToscaException;
import org.onap.sdc.toscaparser.api.common.JToscaValidationIssue;
import org.onap.sdc.toscaparser.api.utils.JToscaErrorCodes;
private File loadCsar(final String csarFilePath) {
final URL resourceUrl = JToscaMetadataParse.class.getClassLoader().getResource(csarFilePath);
- assertNotNull(String.format("Could not load CSAR file '%s'", csarFilePath), resourceUrl);
+ assertNotNull(resourceUrl, String.format("Could not load CSAR file '%s'", csarFilePath));
return new File(resourceUrl.getFile());
}
package org.onap.sdc.toscaparser.api.elements;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.toscaparser.api.JToscaImportTest;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Property;
import java.net.URL;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class CalculatePropertyByPathTest {
private static ToscaTemplate toscaTemplate;
- @BeforeClass
+ @BeforeAll
public static void setUpClass() throws JToscaException {
URL scarUrl = JToscaImportTest.class.getClassLoader().getResource("csars/service-NetworkCloudVnfServiceMock-csar.csar");
if (scarUrl != null) {
package org.onap.sdc.toscaparser.api.elements;
-import org.junit.After;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class EntityTypeTest {
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
EntityType.TOSCA_DEF = (LinkedHashMap<String, Object>) origMap;
}
*/
package org.onap.sdc.toscaparser.api.functions;
-import org.junit.Test;
-import org.onap.sdc.toscaparser.api.*;
-import org.onap.sdc.toscaparser.api.common.JToscaException;
-import org.onap.sdc.toscaparser.api.elements.constraints.Schema;
-import org.onap.sdc.toscaparser.api.parameters.Input;
-import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import org.onap.sdc.toscaparser.api.JToscaImportTest;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.ToscaTemplate;
+import org.onap.sdc.toscaparser.api.common.JToscaException;
+import org.onap.sdc.toscaparser.api.elements.constraints.Schema;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
public class GetInputTest {
<artifactId>junit-jupiter</artifactId>
<version>${junitJupiter.version}</version>
</dependency>
- <!--JUnit Jupiter Engine to depend on the JUnit4 engine and JUnit 4 API -->
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>${junitJupiter.version}</version>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<!-- TEST -->
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.10.19</version>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
+
<!-- Provides everything you need to write JUnit 5 Jupiter tests. -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
- <!-- Enables any legacy JUnit 3 and JUnit 4 tests you may have. Not needed for JUnit 5 tests. -->
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<reporting>
package org.onap.sdc.impl;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
import java.net.URL;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class CapReqWithSameNamesTest {
private static ISdcCsarHelper helper = null;
- @BeforeClass
+ @BeforeAll
public static void setUpClass() {
try {
URL resource = GetEntityPortMirroringTest.class.getClassLoader()
* ============LICENSE_END=========================================================
*/
package org.onap.sdc.impl;
-import org.junit.Test;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.URL;
-import java.util.*;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.assertj.core.api.Assertions.assertThat;
-
public class GetCvfcWithVfcTest {
+
private static final String SERVICE_WITH_SINGLE_VF_CSAR = "csars/service-JennyVtsbcVlanSvc-csar.csar";
private static final String SERVICE_WITH_DOUBLE_VF_CSAR = "csars/service-Metaswitch1-csar.csar";
private static final String ABSTRACT_RTP_MSC = "abstract_rtp_msc";
private ISdcCsarHelper helper;
private static Logger log = LoggerFactory.getLogger(GetCvfcWithVfcTest.class.getName());
- public void setUp(String path) {
+ public void setUp(String path) {
try {
URL resource = GetCvfcWithVfcTest.class.getClassLoader().getResource(path);
if (resource != null) {
}
@Test
- public void getCvfcsWithVfcsFromServiceWithSingleVfTest(){
+ public void getCvfcsWithVfcsFromServiceWithSingleVfTest() {
setUp(SERVICE_WITH_SINGLE_VF_CSAR);
List<IEntityDetails> entities = helper.getVFModule();
List<String> actualMembersList = newArrayList();
}
@Test
- public void getCvfcsWithVfcsFromVfiSingleVfTest(){
+ public void getCvfcsWithVfcsFromVfiSingleVfTest() {
setUp(SERVICE_WITH_SINGLE_VF_CSAR);
List<IEntityDetails> entities = helper.getVFModule("05e77410-a1d8-44fe-8440-b9410c8f98ee");
List<String> actualMembersList = newArrayList();
}
@Test
- public void getCvfcsWithVfcsFromServiceWithDuplicateVfTest(){
+ public void getCvfcsWithVfcsFromServiceWithDuplicateVfTest() {
setUp(SERVICE_WITH_DOUBLE_VF_CSAR);
List<IEntityDetails> entities = helper.getVFModule();
List<String> actualMembersList = newArrayList();
@Test
- public void getCvfcsWithVfcsFromVfiOnServiceWithDuplicateVfTest(){
+ public void getCvfcsWithVfcsFromVfiOnServiceWithDuplicateVfTest() {
setUp(SERVICE_WITH_DOUBLE_VF_CSAR);
List<IEntityDetails> entities = helper.getVFModule("2b5f00de-8816-465c-b7bc-c36e26775e1e");
List<String> actualMembersList = newArrayList();
package org.onap.sdc.impl;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
import java.util.Map;
import java.util.stream.Collectors;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class GetEntityPortMirroringTest {
private final static String cap1 = "radcomfnvlbavf11_3_3vepdg0.abstract_vlbagentbase_eph_aff.port_mirroring_vlbagentbase_eph_aff_vlbagentbase_eph_aff_int_pktmirror_1_port";
private static ISdcCsarHelper helper = null;
- @BeforeClass
+ @BeforeAll
public static void setUpClass() {
try {
URL resource = GetEntityPortMirroringTest.class.getClassLoader()
package org.onap.sdc.impl;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
import java.net.URL;
import java.util.List;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class GetEntityTest {
private static ISdcCsarHelper helper = null;
- @BeforeClass
+ @BeforeAll
public static void setUpClass() {
try {
URL resource = GetEntityTest.class.getClassLoader().getResource("csars/service-JennyVtsbcVlanSvc-csar.csar");
*/
package org.onap.sdc.impl;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
*/
package org.onap.sdc.impl;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.tosca.parser.api.IEntityDetails;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
package org.onap.sdc.impl;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import java.util.HashSet;
import java.util.LinkedHashMap;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNull.notNullValue;
private static final String TEST_DATATYPE_PROPERTY_TYPE = "type";
private static final String TEST_DATATYPE_PROPERTY_ENTRY_SCHEMA = "entry_schema";
- @BeforeClass
+ @BeforeAll
public static void setUpClass() {
try {
URL resource = GetEntityPortMirroringTest.class.getClassLoader()
package org.onap.sdc.tosca.parser.elements;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.when;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Policy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class EntityDetailsFactoryTest {
@Mock
assertEquals(null, EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, null));
}
- @Test(expected = ClassCastException.class)
+ @Test
public void createWrongEntityDetails() {
- EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, group);
+ assertThrows(ClassCastException.class, () -> {
+ EntityDetailsFactory.createEntityDetails(EntityTemplateType.POLICY, group);
+ });
}
package org.onap.sdc.tosca.parser.elements.queries;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
import org.onap.sdc.toscaparser.api.elements.Metadata;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.eq;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class EntityQueryTest {
@Mock
private Metadata metadata;
package org.onap.sdc.tosca.parser.elements.queries;
-import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.elements.Metadata;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class TopologyTemplateQueryTest {
@Mock
@Mock
private NodeTemplate nodeTemplate;
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void objectIsNotTopologyTemplate() {
- TopologyTemplateQuery.newBuilder(SdcTypes.CP)
- .build();
+ assertThrows(IllegalArgumentException.class, () -> {
+ TopologyTemplateQuery.newBuilder(SdcTypes.CP).build();
+ });
}
@Test
TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE)
.build();
when(nodeTemplate.getMetaData()).thenReturn(metadata);
- when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345");
when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.SERVICE.getValue());
assertTrue(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
}
.build();
when(nodeTemplate.getMetaData()).thenReturn(metadata);
when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn(SdcTypes.CVFC.getValue());
- when(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)).thenReturn("345");
assertFalse(topologyTemplateQuery.isMatchingSearchCriteria(nodeTemplate));
}
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
package org.onap.sdc.tosca.parser.impl;
+
import org.apache.commons.lang3.StringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.enums.PropertySchemaType;
import org.onap.sdc.tosca.parser.utils.PropertyUtils;
import java.util.LinkedHashMap;
import java.util.NoSuchElementException;
-import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class ToscaParserNodeTemplateMockTest {
+
@Mock
private NodeTemplate nodeTemplate;
-
@Mock
private Metadata metadata;
-
@Mock
private ToscaTemplate toscaTemplate;
-
@Mock
private Property property;
private static final String dataTypeD = String.format(".%s.ddd", PropertySchemaType.DATATYPE.getSchemaTypeName());
private static final String dataTypeR = String.format(".%s.rrr", PropertySchemaType.DATATYPE.getSchemaTypeName());
- @Before
- public void setUp() {
- when(property.getType()).thenReturn(dataTypeA);
+ @BeforeEach
+ public void setUp(TestInfo info) {
+ if (!info.getDisplayName().equals("verifyNodeTypeIsNotSupported()")) {
+ when(property.getType()).thenReturn(dataTypeA);
+ }
}
-
@Test
public void verifyCorrectPropertyPath() {
String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#");
LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "q", PropertySchemaType.STRING.getSchemaTypeName());
when(nodeTemplate.getCustomDef())
- .thenReturn(bProp)
- .thenReturn(cProp)
- .thenReturn(dProp);
+ .thenReturn(bProp)
+ .thenReturn(cProp)
+ .thenReturn(dProp);
assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
}
String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#");
LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.MAP.getSchemaTypeName());
- LinkedHashMap<String, Object> dProp = fillDataTypeEntry(PropertySchemaType.MAP.getSchemaTypeName(), "q", PropertySchemaType.STRING.getSchemaTypeName());
+ LinkedHashMap<String, Object> dProp = fillDataTypeEntry(PropertySchemaType.MAP.getSchemaTypeName(), "q",
+ PropertySchemaType.STRING.getSchemaTypeName());
when(nodeTemplate.getCustomDef())
- .thenReturn(bProp)
- .thenReturn(cProp)
- .thenReturn(dProp);
+ .thenReturn(bProp)
+ .thenReturn(cProp)
+ .thenReturn(dProp);
assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
}
LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.MAP.getSchemaTypeName());
when(nodeTemplate.getCustomDef())
- .thenReturn(bProp)
- .thenReturn(cProp);
+ .thenReturn(bProp)
+ .thenReturn(cProp);
assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
}
LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(), dataTypeR);
when(nodeTemplate.getCustomDef())
- .thenReturn(bProp)
- .thenReturn(cProp)
- .thenReturn(dProp);
+ .thenReturn(bProp)
+ .thenReturn(cProp)
+ .thenReturn(dProp);
assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
}
String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "m").split("#");
LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
LinkedHashMap<String, Object> cProp = fillDataTypeEntry(dataTypeB, "z", dataTypeD);
- LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(), PropertySchemaType.INTEGER.getSchemaTypeName());
+ LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeD, "m", PropertySchemaType.LIST.getSchemaTypeName(),
+ PropertySchemaType.INTEGER.getSchemaTypeName());
when(nodeTemplate.getCustomDef())
- .thenReturn(bProp)
- .thenReturn(cProp)
- .thenReturn(dProp);
+ .thenReturn(bProp)
+ .thenReturn(cProp)
+ .thenReturn(dProp);
assertTrue(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
}
LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.STRING.getSchemaTypeName());
when(nodeTemplate.getCustomDef())
- .thenReturn(bProp)
- .thenReturn(dProp);
+ .thenReturn(bProp)
+ .thenReturn(dProp);
assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
}
- @Test(expected = NoSuchElementException.class)
+ @Test
public void propertyPathIsRejectedAsLongerThanExpected() {
String[] path = String.format("%s#%s#%s#%s", "x", "y", "z", "q").split("#");
LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "y", dataTypeB);
LinkedHashMap<String, Object> dProp = fillDataTypeEntry(dataTypeB, "z", PropertySchemaType.STRING.getSchemaTypeName());
when(nodeTemplate.getCustomDef())
- .thenReturn(bProp)
- .thenReturn(dProp);
+ .thenReturn(bProp)
+ .thenReturn(dProp);
- PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property);
+ assertThrows(NoSuchElementException.class, () -> {
+ PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property);
+ });
}
- @Test(expected = NoSuchElementException.class)
+ @Test
public void propertyPathIsRejectedAsPropertyIsNotFound() {
String[] path = String.format("%s#%s", "x", "y").split("#");
LinkedHashMap<String, Object> bProp = fillDataTypeEntry(dataTypeA, "t", dataTypeB);
- when(nodeTemplate.getCustomDef())
- .thenReturn(bProp);
+ when(nodeTemplate.getCustomDef()).thenReturn(bProp);
- assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+ assertThrows(NoSuchElementException.class, () -> {
+ assertFalse(PropertyUtils.isPropertyTypeSimpleOrListOfSimpleTypes(nodeTemplate, path, property));
+ });
}
@Test
PropertySchemaType propertySchemaType = PropertySchemaType.getEnumByValue(type);
if (!StringUtils.isEmpty(entrySchemaType) &&
- (propertySchemaType.getSchemaTypeComplexity() == PropertySchemaType.PropertySchemaComplexity.Complex)) {
+ (propertySchemaType.getSchemaTypeComplexity() == PropertySchemaType.PropertySchemaComplexity.Complex)) {
LinkedHashMap<String, Object> entry_schema = new LinkedHashMap<>();
entry_schema.put(SdcPropertyNames.PROPERTY_NAME_TYPE, entrySchemaType);
property.put(SdcPropertyNames.PROPERTY_NAME_ENTRY_SCHEMA, entry_schema);
}
properties.put(propertyName, property);
- dataType.put(SdcPropertyNames.PROPERTY_NAME_PROPERTIES, properties);
+ dataType.put(SdcPropertyNames.PROPERTY_NAME_PROPERTIES, properties);
dataTypes.put(dataTypeName, dataType);
return dataTypes;
}
-
}