diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-11-05 08:29:42 +0100 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2024-11-05 09:09:30 +0100 |
commit | fb570ad8ed1f56a3f7d10f6106d8110cb08820b2 (patch) | |
tree | b16b64c9b1d401bc8591a6433953a142f517eee3 | |
parent | a0e82faa88f67ea43bb651fc03fad81061339450 (diff) |
Issue-ID: SDC-4694
Change-Id: Iaae2e171e82cbfaeaa7c66aa441b0d5543b08f99
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
26 files changed, 355 insertions, 338 deletions
diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index 71df2ab0..981874fa 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -1,3 +1,4 @@ +six sphinx>=4.2.0 # BSD sphinx-rtd-theme>=1.0.0 # MIT sphinxcontrib-blockdiag # BSD diff --git a/docs/tox.ini b/docs/tox.ini index b9d7eb44..46075fa6 100644 --- a/docs/tox.ini +++ b/docs/tox.ini @@ -7,7 +7,7 @@ skipsdist = true basepython = python3.8 deps = -r{toxinidir}/requirements-docs.txt - -chttps://raw.githubusercontent.com/openstack/requirements/stable/yoga/upper-constraints.txt + -chttps://releases.openstack.org/constraints/upper/yoga -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt?h=master commands = sphinx-build -W -q -b html -n -d {envtmpdir}/doctrees {toxinidir} {toxinidir}/_build/html @@ -16,7 +16,7 @@ commands = basepython = python3.8 deps = -r{toxinidir}/requirements-docs.txt - -chttps://raw.githubusercontent.com/openstack/requirements/stable/yoga/upper-constraints.txt + -chttps://releases.openstack.org/constraints/upper/yoga -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt?h=master commands = sphinx-build -W -q -b linkcheck -d {envtmpdir}/doctrees {toxinidir} {toxinidir}/_build/linkcheck @@ -25,7 +25,7 @@ commands = basepython = python3.8 deps = -r{toxinidir}/requirements-docs.txt - -chttps://raw.githubusercontent.com/openstack/requirements/stable/yoga/upper-constraints.txt + -chttps://releases.openstack.org/constraints/upper/yoga -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt?h=master commands = sphinx-build -W -q -b spelling -d {envtmpdir}/doctrees {toxinidir} {toxinidir}/_build/spellcheck @@ -80,7 +80,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.22.2</version> + <version>3.1.2</version> </plugin> <plugin> <groupId>org.jacoco</groupId> diff --git a/sdc-workflow-designer-be/pom.xml b/sdc-workflow-designer-be/pom.xml index b55553f7..f5dce3d7 100644 --- a/sdc-workflow-designer-be/pom.xml +++ b/sdc-workflow-designer-be/pom.xml @@ -111,12 +111,6 @@ </dependency> <dependency> <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <version>${org.springframework.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework</groupId> <artifactId>spring-jcl</artifactId> <version>${org.springframework.version}</version> <scope>test</scope> @@ -382,10 +376,10 @@ <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> </exclusion> - <exclusion> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - </exclusion> + <exclusion> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + </exclusion> </exclusions> </dependency> <dependency> @@ -526,13 +520,6 @@ </exclusion> </exclusions> </dependency> - - <dependency> - <groupId>org.junit.vintage</groupId> - <artifactId>junit-vintage-engine</artifactId> - <version>${junitJupiter.version}</version> - <scope>test</scope> - </dependency> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-commons</artifactId> @@ -622,14 +609,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.22.2</version> - <dependencies> - <dependency> - <groupId>org.apache.maven.surefire</groupId> - <artifactId>surefire-junit-platform</artifactId> - <version>2.22.2</version> - </dependency> - </dependencies> + <version>3.1.2</version> </plugin> </plugins> </build> diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/ArtifactAssociationHandlerTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/ArtifactAssociationHandlerTest.java index b4d1180b..131e14be 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/ArtifactAssociationHandlerTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/ArtifactAssociationHandlerTest.java @@ -16,7 +16,7 @@ package org.onap.sdc.workflow.api; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; @@ -24,9 +24,8 @@ import static org.mockito.Mockito.when; import java.io.IOException; import java.io.InputStream; import org.apache.commons.io.IOUtils; -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.mockito.Mockito; import org.onap.sdc.workflow.api.types.dto.ArtifactDeliveriesRequestDto; import org.onap.sdc.workflow.persistence.types.ArtifactEntity; @@ -40,14 +39,12 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import org.springframework.web.client.RestTemplate; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration( +@SpringJUnitConfig( classes = {ArtifactAssociationHandlerTest.RestBuilderMockProvider.class, ArtifactAssociationService.class}) @TestPropertySource(locations = "classpath:application-test.properties") @Component("ArtifactAssociationHandlerTest") @@ -92,7 +89,7 @@ public class ArtifactAssociationHandlerTest { @Autowired private ArtifactAssociationService associationService; - @Before + @BeforeEach public void setUp() throws IOException { inputStreamMock = IOUtils.toInputStream("some test data for my input stream", "UTF-8"); artifactMock = new ArtifactEntity(FILE_NAME, inputStreamMock); diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/ExceptionsHandlerTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/ExceptionsHandlerTest.java index ee924007..71fe6844 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/ExceptionsHandlerTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/ExceptionsHandlerTest.java @@ -16,15 +16,15 @@ package org.onap.sdc.workflow.api; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +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.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; -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.InjectMocks; import org.onap.sdc.workflow.api.types.ErrorResponse; import org.onap.sdc.workflow.api.types.UnexpectedErrorResponse; @@ -33,9 +33,9 @@ import org.onap.sdc.workflow.services.exceptions.VersionModificationException; import org.onap.sdc.workflow.services.exceptions.VersionStateModificationMissingArtifactException; import org.onap.sdc.workflow.services.types.WorkflowVersionState; import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) public class ExceptionsHandlerTest { @InjectMocks diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java index 5e0f61d0..2368d683 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java @@ -17,7 +17,7 @@ package org.onap.sdc.workflow.api; import static org.hamcrest.Matchers.is; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; @@ -39,14 +39,14 @@ import com.amdocs.zusammen.datatypes.item.Item; import java.util.Arrays; import java.util.Collections; import java.util.List; -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.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.sdc.workflow.RestPath; import org.onap.sdc.workflow.server.resolvers.UserIdResolver; import org.onap.sdc.workflow.services.WorkflowManager; @@ -62,7 +62,7 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class WorkflowControllerTest { private static final String USER_ID = "userId"; @@ -78,7 +78,7 @@ public class WorkflowControllerTest { @InjectMocks private WorkflowController workflowController; - @Before + @BeforeEach public void setUp() { mockMvc = MockMvcBuilders.standaloneSetup(workflowController) .setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver()) diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java index a8813c05..732ae40d 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java @@ -18,7 +18,7 @@ package org.onap.sdc.workflow.api; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; import static org.springframework.http.MediaType.APPLICATION_JSON; @@ -31,12 +31,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import java.util.Arrays; import java.util.Collection; -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.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.sdc.workflow.RestPath; import org.onap.sdc.workflow.api.mappers.WorkflowVersionDtoMapper; import org.onap.sdc.workflow.api.types.Parameter; @@ -51,7 +51,7 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class WorkflowVersionControllerTest { private static final String USER_ID = "cs0008"; @@ -68,7 +68,7 @@ public class WorkflowVersionControllerTest { @InjectMocks private WorkflowVersionController workflowVersionController; - @Before + @BeforeEach public void setUp() { mockMvc = MockMvcBuilders.standaloneSetup(workflowVersionController).build(); } diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/swagger/UserIdReaderTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/swagger/UserIdReaderTest.java index b82cb438..73cfe40e 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/swagger/UserIdReaderTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/swagger/UserIdReaderTest.java @@ -24,18 +24,18 @@ import static org.mockito.Mockito.when; import com.fasterxml.classmate.TypeResolver; import java.util.Optional; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.lang.annotation.Annotation; -import org.junit.Test; -import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.onap.sdc.workflow.services.annotations.UserId; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import springfox.documentation.builders.ParameterBuilder; import springfox.documentation.service.ResolvedMethodParameter; import springfox.documentation.spi.service.contexts.ParameterContext; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) public class UserIdReaderTest { private static final UserId USER_ID_ANNOTATION = new UserId() { diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/PagingTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/PagingTest.java index a0392eb5..9c29c8e3 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/PagingTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/PagingTest.java @@ -16,16 +16,16 @@ package org.onap.sdc.workflow.api.types; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.onap.sdc.workflow.services.types.PagingConstants.MAX_LIMIT; -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.InjectMocks; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) public class PagingTest { @InjectMocks diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/SortingTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/SortingTest.java index 9cd95a5d..47570ac2 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/SortingTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/SortingTest.java @@ -16,17 +16,17 @@ package org.onap.sdc.workflow.api.types; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.Collections; -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.InjectMocks; import org.onap.sdc.workflow.services.types.Sort; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) public class SortingTest { @InjectMocks diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/VersionStatesFormatterTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/VersionStatesFormatterTest.java index 294577fe..bd11fb40 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/VersionStatesFormatterTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/types/VersionStatesFormatterTest.java @@ -16,20 +16,19 @@ package org.onap.sdc.workflow.api.types; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.onap.sdc.workflow.services.types.WorkflowVersionState.CERTIFIED; import static org.onap.sdc.workflow.services.types.WorkflowVersionState.DRAFT; import java.util.Collections; import java.util.stream.Collectors; import java.util.stream.Stream; -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.InjectMocks; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) public class VersionStatesFormatterTest { @InjectMocks diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ActivitySpecParameterNameValidatorTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ActivitySpecParameterNameValidatorTest.java index 75fb5a29..0e3a37fa 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ActivitySpecParameterNameValidatorTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ActivitySpecParameterNameValidatorTest.java @@ -16,22 +16,22 @@ package org.onap.sdc.workflow.api.validation; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import javax.validation.ConstraintValidatorContext; -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.extension.ExtendWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.onap.sdc.workflow.persistence.types.ActivitySpecParameter; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) public class ActivitySpecParameterNameValidatorTest { class AnnotationWrapper { @@ -53,7 +53,7 @@ public class ActivitySpecParameterNameValidatorTest { private ActivitySpecParameterNameValidator validator; - @Before + @BeforeEach public void setup() throws NoSuchFieldException { MockitoAnnotations.initMocks(this); when(context.buildConstraintViolationWithTemplate(anyString())).thenReturn(constraintViolationBuilder); diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidatorTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidatorTest.java index d5e5f20d..6d45164f 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidatorTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/ArchivingStatusValidatorTest.java @@ -16,21 +16,20 @@ package org.onap.sdc.workflow.api.validation; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import javax.validation.ConstraintValidatorContext; -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.extension.ExtendWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) public class ArchivingStatusValidatorTest { class AnnotationWrapper { @@ -48,7 +47,7 @@ public class ArchivingStatusValidatorTest { private ArchivingStatusValidator validator; - @Before + @BeforeEach public void setup() throws NoSuchFieldException { MockitoAnnotations.initMocks(this); when(context.buildConstraintViolationWithTemplate(anyString())).thenReturn(constraintViolationBuilder); diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidatorTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidatorTest.java index f8f6b743..e000455f 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidatorTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/validation/NoDuplicatesValidatorTest.java @@ -16,8 +16,8 @@ package org.onap.sdc.workflow.api.validation; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; @@ -26,8 +26,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import javax.validation.ConstraintValidatorContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.onap.sdc.workflow.api.types.Parameter; @@ -50,7 +50,7 @@ public class NoDuplicatesValidatorTest { private ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext nodeBuilderCustomizableContext; - @Before + @BeforeEach public void init() throws NoSuchFieldException { MockitoAnnotations.initMocks(this); when(context.buildConstraintViolationWithTemplate(anyString())).thenReturn(constraintViolationBuilder); diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImplTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImplTest.java index e69d4984..c01c2050 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImplTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ActivitySpecRepositoryImplTest.java @@ -18,6 +18,7 @@ package org.onap.sdc.workflow.persistence.impl; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.lenient; import static org.onap.sdc.common.zusammen.services.ZusammenElementUtil.ELEMENT_TYPE_PROPERTY; import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; @@ -35,13 +36,13 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.UUID; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.sdc.common.versioning.persistence.zusammen.ZusammenSessionContextCreator; import org.onap.sdc.common.zusammen.services.ZusammenAdaptor; import org.onap.sdc.workflow.persistence.impl.ActivitySpecRepositoryImpl.InfoPropertyName; @@ -51,7 +52,7 @@ import org.onap.sdc.workflow.persistence.types.ActivitySpecEntity; import org.onap.sdc.workflow.persistence.types.ActivitySpecParameter; import org.onap.sdc.workflow.services.utilities.JsonUtil; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ActivitySpecRepositoryImplTest { private static final String versionId = "1234"; @@ -68,7 +69,7 @@ public class ActivitySpecRepositoryImplTest { private final Map<String, Element> elementMap = new HashMap<>(); private String elementId; - @Before + @BeforeEach public void setUp() { daoImpl = new ActivitySpecRepositoryImpl(zusammenAdaptor, contextCreator); entity = new ActivitySpecEntity(); @@ -100,14 +101,14 @@ public class ActivitySpecRepositoryImplTest { Optional<ElementInfo> testElementInfo = zusammenAdaptor .getElementInfoByName(contextCreator.create(), elementContext, Id.ZERO, ActivitySpecElementType.ACTIVITYSPEC.name()); - Assert.assertTrue(testElementInfo.isPresent()); - Assert.assertEquals(testElementInfo.get().getInfo().getName(), ActivitySpecElementType.ACTIVITYSPEC.name()); - Assert.assertEquals(testElementInfo.get().getInfo() + Assertions.assertTrue(testElementInfo.isPresent()); + Assertions.assertEquals(testElementInfo.get().getInfo().getName(), ActivitySpecElementType.ACTIVITYSPEC.name()); + Assertions.assertEquals(testElementInfo.get().getInfo() .getProperty(ActivitySpecRepositoryImpl.InfoPropertyName.DESCRIPTION.getValue()), entity.getDescription()); - Assert.assertEquals(testElementInfo.get().getInfo().getProperty(InfoPropertyName.CATEGORY.getValue()), + Assertions.assertEquals(testElementInfo.get().getInfo().getProperty(InfoPropertyName.CATEGORY.getValue()), entity.getCategoryList()); - Assert.assertEquals(testElementInfo.get().getInfo() + Assertions.assertEquals(testElementInfo.get().getInfo() .getProperty(ActivitySpecRepositoryImpl.InfoPropertyName.NAME.getValue()), entity.getName()); @@ -115,15 +116,15 @@ public class ActivitySpecRepositoryImplTest { zusammenAdaptor.getElement(contextCreator.create(), elementContext, new Id(elementId)); final InputStream data = testElement.get().getData(); final ActivitySpecData activitySpecData = JsonUtil.json2Object(data, ActivitySpecData.class); - Assert.assertEquals(activitySpecData.getInputs().get(0).getName(), entity.getInputs().get(0).getName()); + Assertions.assertEquals(activitySpecData.getInputs().get(0).getName(), entity.getInputs().get(0).getName()); } @Test public void testGet() { final ActivitySpecEntity retrieved = daoImpl.get(entity); - Assert.assertEquals(retrieved.getName(), entity.getName()); - Assert.assertEquals(retrieved.getDescription(), entity.getDescription()); - Assert.assertEquals(retrieved.getCategoryList(), entity.getCategoryList()); + Assertions.assertEquals(retrieved.getName(), entity.getName()); + Assertions.assertEquals(retrieved.getDescription(), entity.getDescription()); + Assertions.assertEquals(retrieved.getCategoryList(), entity.getCategoryList()); } @Test @@ -131,20 +132,20 @@ public class ActivitySpecRepositoryImplTest { entity.setDescription("Update AS version1"); daoImpl.update(entity); final ActivitySpecEntity retrieved = daoImpl.get(entity); - Assert.assertEquals(retrieved.getName(), entity.getName()); - Assert.assertEquals(retrieved.getDescription(), entity.getDescription()); - Assert.assertEquals(retrieved.getCategoryList(), entity.getCategoryList()); + Assertions.assertEquals(retrieved.getName(), entity.getName()); + Assertions.assertEquals(retrieved.getDescription(), entity.getDescription()); + Assertions.assertEquals(retrieved.getCategoryList(), entity.getCategoryList()); } private void mockZusammenAdapter() { - doAnswer(invocationOnMock -> { + lenient().doAnswer(invocationOnMock -> { Id elementId = invocationOnMock.getArgument(2); return Optional.of(elementMap.get(elementId.getValue())); }).when(zusammenAdaptor).getElement(any(), any(), any()); - doAnswer(invocationOnMock -> { + lenient().doAnswer(invocationOnMock -> { ZusammenElement element = new ZusammenElement(); Info info = new Info(); element.setElementId(Id.ZERO); @@ -155,7 +156,7 @@ public class ActivitySpecRepositoryImplTest { return Optional.of(element); }).when(zusammenAdaptor).getElementByName(any(), any(), any(), any()); - doAnswer(invocationOnMock -> { + lenient().doAnswer(invocationOnMock -> { String elementName = invocationOnMock.getArgument(3); return elementMap.values().stream() .filter(element -> elementName.equals(element.getInfo().getProperty(ELEMENT_TYPE_PROPERTY))) @@ -167,7 +168,7 @@ public class ActivitySpecRepositoryImplTest { }).findAny(); }).when(zusammenAdaptor).getElementInfoByName(any(), any(), any(), any()); - doAnswer(invocationOnMock -> { + lenient().doAnswer(invocationOnMock -> { ZusammenElement element = invocationOnMock.getArgument(2); if (element.getAction().equals(Action.CREATE) || element.getAction().equals(Action.UPDATE)) { element.setElementId(new Id(UUID.randomUUID().toString())); diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryTest.java index 96f74d58..374ad144 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ArtifactRepositoryTest.java @@ -16,9 +16,9 @@ package org.onap.sdc.workflow.persistence.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; @@ -38,18 +38,18 @@ import java.io.IOException; import java.io.InputStream; import java.util.Optional; import org.apache.commons.io.IOUtils; -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.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.sdc.common.versioning.persistence.zusammen.ZusammenSessionContextCreator; import org.onap.sdc.common.zusammen.services.ZusammenAdaptor; import org.onap.sdc.workflow.persistence.impl.types.WorkflowElementType; import org.onap.sdc.workflow.persistence.types.ArtifactEntity; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ArtifactRepositoryTest { private static final String FILE_NAME_PROPERTY = "fileName"; @@ -66,7 +66,7 @@ public class ArtifactRepositoryTest { @InjectMocks private ArtifactRepositoryImpl artifactRepository; - @Before + @BeforeEach public void setUp() { doReturn(SESSION_CONTEXT).when(contextCreatorMock).create(); } diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryTest.java index 4112ab4e..c2d897c4 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/persistence/impl/ParameterRepositoryTest.java @@ -16,11 +16,12 @@ package org.onap.sdc.workflow.persistence.impl; -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.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; @@ -33,14 +34,14 @@ import com.amdocs.zusammen.datatypes.item.Info; import java.util.ArrayList; import java.util.Collection; import java.util.Optional; -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.extension.ExtendWith; import org.mapstruct.ap.internal.util.Collections; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.sdc.common.versioning.persistence.zusammen.ZusammenSessionContextCreator; import org.onap.sdc.common.zusammen.services.ZusammenAdaptor; import org.onap.sdc.workflow.persistence.impl.types.ParameterPropertyName; @@ -49,7 +50,7 @@ import org.onap.sdc.workflow.persistence.types.ParameterEntity; import org.onap.sdc.workflow.persistence.types.ParameterRole; import org.onap.sdc.workflow.persistence.types.ParameterType; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ParameterRepositoryTest { private static final String ITEM1_ID = "item_id_1"; @@ -67,7 +68,7 @@ public class ParameterRepositoryTest { @InjectMocks private ParameterRepositoryImpl parameterRepository; - @Before + @BeforeEach public void setUp() { doReturn(SESSION_CONTEXT).when(contextCreatorMock).create(); } @@ -181,12 +182,14 @@ public class ParameterRepositoryTest { eq("Delete all INPUT")); } - @Test(expected = IllegalStateException.class) + @Test public void shouldFailIfParentElementDoesNotExist() { - doReturn(Optional.empty()).when(zusammenAdaptorMock) - .getElementInfoByName(eq(SESSION_CONTEXT), any(ElementContext.class), isNull(), - eq(WorkflowElementType.INPUTS.name())); - parameterRepository.deleteAll(ITEM1_ID, VERSION1_ID, ParameterRole.INPUT); + assertThrows(IllegalStateException.class, () -> { + doReturn(Optional.empty()).when(zusammenAdaptorMock) + .getElementInfoByName(eq(SESSION_CONTEXT), any(ElementContext.class), isNull(), + eq(WorkflowElementType.INPUTS.name())); + parameterRepository.deleteAll(ITEM1_ID, VERSION1_ID, ParameterRole.INPUT); + }); } @Test diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/server/resolvers/UserIdResolverTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/server/resolvers/UserIdResolverTest.java index 464af465..5fcb11e7 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/server/resolvers/UserIdResolverTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/server/resolvers/UserIdResolverTest.java @@ -16,15 +16,16 @@ package org.onap.sdc.workflow.server.resolvers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +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.mock; import static org.mockito.Mockito.when; import static org.onap.sdc.workflow.api.RestParams.USER_ID_HEADER; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.sdc.workflow.services.annotations.UserId; import org.springframework.core.MethodParameter; import org.springframework.web.bind.ServletRequestBindingException; @@ -53,26 +54,32 @@ public class UserIdResolverTest { assertEquals(headerValue, resolved); } - @Test(expected = IllegalStateException.class) + @Test public void illegalTypeErrorThrownWhenAnnotatedParameterIsNotOfTypeString() { - MethodParameter methodParameterMock = mock(MethodParameter.class); - when(methodParameterMock.hasParameterAnnotation(UserId.class)).thenReturn(true); - //noinspection unchecked - when(methodParameterMock.getParameterType()).thenReturn((Class)String[].class); - new UserIdResolver().supportsParameter(methodParameterMock); + assertThrows(IllegalStateException.class, () -> { + MethodParameter methodParameterMock = mock(MethodParameter.class); + when(methodParameterMock.hasParameterAnnotation(UserId.class)).thenReturn(true); + //noinspection unchecked + when(methodParameterMock.getParameterType()).thenReturn((Class) String[].class); + new UserIdResolver().supportsParameter(methodParameterMock); + }); } - @Test(expected = ServletRequestBindingException.class) - public void missingHeaderErrorThrownWhenUserIdHeaderNotPopulated() throws ServletRequestBindingException { - NativeWebRequest webRequestMock = mock(NativeWebRequest.class); - when(webRequestMock.getNativeRequest(HttpServletRequest.class)).thenReturn(mock(HttpServletRequest.class)); - new UserIdResolver().resolveArgument(null, null, webRequestMock, null); + @Test + public void missingHeaderErrorThrownWhenUserIdHeaderNotPopulated() { + assertThrows(ServletRequestBindingException.class, () -> { + NativeWebRequest webRequestMock = mock(NativeWebRequest.class); + when(webRequestMock.getNativeRequest(HttpServletRequest.class)).thenReturn(mock(HttpServletRequest.class)); + new UserIdResolver().resolveArgument(null, null, webRequestMock, null); + }); } - @Test(expected = NullPointerException.class) - public void exceptionThrownWhenRequestTypeIsNotHttpRequest() throws ServletRequestBindingException { - NativeWebRequest webRequestMock = mock(NativeWebRequest.class); - new UserIdResolver().resolveArgument(null, null, webRequestMock, null); + @Test + public void exceptionThrownWhenRequestTypeIsNotHttpRequest() { + assertThrows(NullPointerException.class, () -> { + NativeWebRequest webRequestMock = mock(NativeWebRequest.class); + new UserIdResolver().resolveArgument(null, null, webRequestMock, null); + }); } @Test diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/UniqueValueServiceTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/UniqueValueServiceTest.java index da2d8fa5..b0996699 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/UniqueValueServiceTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/UniqueValueServiceTest.java @@ -16,8 +16,9 @@ package org.onap.sdc.workflow.services; -import static org.junit.Assert.assertFalse; -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.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doReturn; @@ -26,8 +27,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -48,7 +49,7 @@ public class UniqueValueServiceTest { @InjectMocks private UniqueValueService uniqueValueService; - @Before + @BeforeEach public void setUp() { MockitoAnnotations.initMocks(this); } @@ -66,10 +67,12 @@ public class UniqueValueServiceTest { verify(uniqueValueRepositoryMock, never()).findById(any(UniqueValueEntity.class)); } - @Test(expected = UniqueValueViolationException.class) + @Test public void shouldThrowExceptionIfValueIsNotUnique() { - doReturn(Optional.of("xxx")).when(uniqueValueRepositoryMock).findById(any()); - uniqueValueService.createUniqueValue(TYPE, DUMMY_COMBINATION); + assertThrows(UniqueValueViolationException.class, () -> { + doReturn(Optional.of("xxx")).when(uniqueValueRepositoryMock).findById(any()); + uniqueValueService.createUniqueValue(TYPE, DUMMY_COMBINATION); + }); } @Test diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImplTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImplTest.java index 3166e06f..55326e8a 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImplTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/ActivitySpecManagerImplTest.java @@ -16,6 +16,7 @@ package org.onap.sdc.workflow.services.impl; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -30,10 +31,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; @@ -78,12 +79,12 @@ public class ActivitySpecManagerImplTest { @Mock private ActivitySpecMapper activitySpecMapperMock; - @Before + @BeforeEach public void setUp() { MockitoAnnotations.initMocks(this); } - @After + @AfterEach public void tearDown() { activitySpecManager = null; } @@ -128,19 +129,19 @@ public class ActivitySpecManagerImplTest { ActivitySpecEntity activitySpec = activitySpecManager.createActivitySpec(activitySpecToCreate); - Assert.assertNotNull(activitySpec); + Assertions.assertNotNull(activitySpec); activitySpec.setId(itemId); activitySpec.setStatus(VersionStatus.Draft.name()); assertActivitySpecEquals(activitySpec, activitySpecToCreate); } private void assertActivitySpecEquals(ActivitySpecEntity actual, ActivitySpecEntity expected) { - Assert.assertEquals(actual.getId(), expected.getId()); - Assert.assertEquals(actual.getName(), expected.getName()); - Assert.assertEquals(actual.getDescription(), expected.getDescription()); - Assert.assertEquals(actual.getCategoryList(), expected.getCategoryList()); - Assert.assertEquals(actual.getInputs(), expected.getInputs()); - Assert.assertEquals(actual.getOutputs(), expected.getOutputs()); + Assertions.assertEquals(actual.getId(), expected.getId()); + Assertions.assertEquals(actual.getName(), expected.getName()); + Assertions.assertEquals(actual.getDescription(), expected.getDescription()); + Assertions.assertEquals(actual.getCategoryList(), expected.getCategoryList()); + Assertions.assertEquals(actual.getInputs(), expected.getInputs()); + Assertions.assertEquals(actual.getOutputs(), expected.getOutputs()); } @Test @@ -150,20 +151,20 @@ public class ActivitySpecManagerImplTest { doReturn(new ActivitySpecEntity(ID, null)).when(activitySpecMapperMock).itemToActivitySpec(item); final Collection<ActivitySpecEntity> activitySpecs = activitySpecManager.list("Certified"); - Assert.assertEquals(1, activitySpecs.size()); - Assert.assertEquals(ID, activitySpecs.iterator().next().getId()); + Assertions.assertEquals(1, activitySpecs.size()); + Assertions.assertEquals(ID, activitySpecs.iterator().next().getId()); } @Test public void testListInvalidFilter() { final Collection<ActivitySpecEntity> activitySpecs = activitySpecManager.list("invalid_status"); - Assert.assertEquals(0, activitySpecs.size()); + Assertions.assertEquals(0, activitySpecs.size()); } @Test public void testListNoFilter() { final Collection<ActivitySpecEntity> activitySpecs = activitySpecManager.list(null); - Assert.assertEquals(0, activitySpecs.size()); + Assertions.assertEquals(0, activitySpecs.size()); } @Test @@ -177,12 +178,12 @@ public class ActivitySpecManagerImplTest { doReturn(createRetrievedVersion(version01,VersionStatus.Draft)).when(versionManagerMock).get(any(), any()); ActivitySpecEntity retrieved = activitySpecManager.get(input); assertActivitySpecEquals(retrieved, input); - Assert.assertEquals(retrieved.getStatus(), VersionStatus.Draft.name()); + Assertions.assertEquals(retrieved.getStatus(), VersionStatus.Draft.name()); retrieved = activitySpecManager.get(input); assertActivitySpecEquals(retrieved, input); - Assert.assertEquals(retrieved.getStatus(), VersionStatus.Draft.name()); + Assertions.assertEquals(retrieved.getStatus(), VersionStatus.Draft.name()); } private void mockListVersions() { @@ -199,9 +200,9 @@ public class ActivitySpecManagerImplTest { Mockito.doThrow(new RuntimeException(TEST_ERROR_MSG)).when(activitySpecRepositoryMock).get(any()); try { activitySpecManager.get(input); - Assert.fail(); + Assertions.fail(); } catch (EntityNotFoundException exception) { - Assert.assertEquals(ACTIVITY_SPEC_NOT_FOUND, exception.getMessage()); + Assertions.assertEquals(ACTIVITY_SPEC_NOT_FOUND, exception.getMessage()); } } @@ -213,23 +214,27 @@ public class ActivitySpecManagerImplTest { Mockito.doThrow(new RuntimeException(TEST_ERROR_MSG)).when(versionManagerMock).list(any()); try { activitySpecManager.get(input); - Assert.fail(); + Assertions.fail(); } catch (EntityNotFoundException exception) { - Assert.assertEquals(ACTIVITY_SPEC_NOT_FOUND, exception.getMessage()); + Assertions.assertEquals(ACTIVITY_SPEC_NOT_FOUND, exception.getMessage()); } } - @Test(expected = VersionStatusModificationException.class) + @Test public void testInvalidDeprecate() { - InternalVersion version = createRetrievedVersion(version01, VersionStatus.Draft); - doReturn(version).when(versionManagerMock).get(ID, version01); - activitySpecManager.actOnAction(new ActivitySpecEntity(ID, version01), ActivitySpecAction.DEPRECATE); + assertThrows(VersionStatusModificationException.class, () -> { + InternalVersion version = createRetrievedVersion(version01, VersionStatus.Draft); + doReturn(version).when(versionManagerMock).get(ID, version01); + activitySpecManager.actOnAction(new ActivitySpecEntity(ID, version01), ActivitySpecAction.DEPRECATE); + }); } - @Test(expected = VersionStatusModificationException.class) + @Test public void testInvalidDelete() { - mockCertifiedVersion(); - activitySpecManager.actOnAction(new ActivitySpecEntity(ID, version01), ActivitySpecAction.DELETE); + assertThrows(VersionStatusModificationException.class, () -> { + mockCertifiedVersion(); + activitySpecManager.actOnAction(new ActivitySpecEntity(ID, version01), ActivitySpecAction.DELETE); + }); } private void mockCertifiedVersion() { @@ -237,10 +242,12 @@ public class ActivitySpecManagerImplTest { doReturn(version).when(versionManagerMock).get(ID, version01); } - @Test(expected = VersionStatusModificationException.class) + @Test public void testInvalidCertify() { - mockCertifiedVersion(); - activitySpecManager.actOnAction(new ActivitySpecEntity(ID, version01), ActivitySpecAction.CERTIFY); + assertThrows(VersionStatusModificationException.class, () -> { + mockCertifiedVersion(); + activitySpecManager.actOnAction(new ActivitySpecEntity(ID, version01), ActivitySpecAction.CERTIFY); + }); } @Test @@ -259,9 +266,9 @@ public class ActivitySpecManagerImplTest { mockListVersions(); try { activitySpecManager.actOnAction(new ActivitySpecEntity(ID, version01), ActivitySpecAction.CERTIFY); - Assert.fail(); + Assertions.fail(); } catch (EntityNotFoundException exception) { - Assert.assertEquals(ACTIVITY_SPEC_NOT_FOUND, exception.getMessage()); + Assertions.assertEquals(ACTIVITY_SPEC_NOT_FOUND, exception.getMessage()); } } diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java index 1db24092..218f443f 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImplTest.java @@ -16,8 +16,9 @@ package org.onap.sdc.workflow.services.impl; -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.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; @@ -38,8 +39,8 @@ import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; -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.InjectMocks; import org.mockito.Mock; import org.onap.sdc.common.versioning.services.ItemManager; @@ -58,9 +59,9 @@ import org.onap.sdc.workflow.services.types.Sort; import org.onap.sdc.workflow.services.types.SortingRequest; import org.onap.sdc.workflow.services.types.Workflow; import org.onap.sdc.workflow.services.types.WorkflowVersionState; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) public class WorkflowManagerImplTest { @@ -131,13 +132,15 @@ public class WorkflowManagerImplTest { assertPaging(workflows.getPaging(), requestSpec.getPaging().getOffset(), requestSpec.getPaging().getLimit(), 2); } - @Test(expected = EntityNotFoundException.class) + @Test public void shouldThrowExceptionWhenWorkflowDontExist() { - Workflow nonExistingWorkflow = new Workflow(); - nonExistingWorkflow.setId(ITEM1_ID); - doReturn(null).when(itemManagerMock).get(ITEM1_ID); - workflowManager.get(nonExistingWorkflow); - verify(workflowMapperMock, times(3)).fromItem(any(Item.class)); + assertThrows(EntityNotFoundException.class, () -> { + Workflow nonExistingWorkflow = new Workflow(); + nonExistingWorkflow.setId(ITEM1_ID); + doReturn(null).when(itemManagerMock).get(ITEM1_ID); + workflowManager.get(nonExistingWorkflow); + verify(workflowMapperMock, times(3)).fromItem(any(Item.class)); + }); } @Test @@ -170,10 +173,12 @@ public class WorkflowManagerImplTest { } - @Test(expected = EntityNotFoundException.class) + @Test public void shouldThrowExceptionWhenWorkflowToUpdateNotFound() { - doReturn(null).when(itemManagerMock).get(ITEM1_ID); - workflowManager.update(createWorkflow(1, true, ArchivingStatus.ACTIVE)); + assertThrows(EntityNotFoundException.class, () -> { + doReturn(null).when(itemManagerMock).get(ITEM1_ID); + workflowManager.update(createWorkflow(1, true, ArchivingStatus.ACTIVE)); + }); } @Test diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java index 6648f376..35ab8baa 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImplTest.java @@ -16,7 +16,9 @@ package org.onap.sdc.workflow.services.impl; -import static org.junit.Assert.assertEquals; +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.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -39,15 +41,13 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import org.apache.commons.io.IOUtils; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.sdc.common.versioning.persistence.types.InternalItem; import org.onap.sdc.common.versioning.persistence.types.InternalVersion; import org.onap.sdc.common.versioning.services.ItemManager; @@ -74,7 +74,7 @@ import org.onap.sdc.workflow.services.types.WorkflowVersion; import org.onap.sdc.workflow.services.types.WorkflowVersionState; import org.springframework.mock.web.MockMultipartFile; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class WorkflowVersionManagerImplTest { private static final String ITEM1_ID = "item_id_1"; @@ -93,53 +93,61 @@ public class WorkflowVersionManagerImplTest { private VersionMapper versionMapperMock; @Mock private VersionStateMapper versionStateMapperMock; - @Rule - public ExpectedException exceptionRule = ExpectedException.none(); @Spy @InjectMocks private WorkflowVersionManagerImpl workflowVersionManager; - @Test(expected = EntityNotFoundException.class) + @Test public void shouldThrowExceptionWhenVersionDontExist() { - doThrow(new RuntimeException()).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); - workflowVersionManager.get(ITEM1_ID, VERSION1_ID); + assertThrows(EntityNotFoundException.class, () -> { + doThrow(new RuntimeException()).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); + workflowVersionManager.get(ITEM1_ID, VERSION1_ID); + }); } - @Test(expected = WorkflowModificationException.class) + @Test public void shouldThrowExceptionWhenCreatingVersionForArchivedWorkflow() { - InternalItem mockItem = new InternalItem(); - mockItem.setId(ITEM1_ID); - mockItem.setStatus(ItemStatus.ARCHIVED); - doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); - workflowVersionManager.create(ITEM1_ID, null, new WorkflowVersion(VERSION1_ID)); + assertThrows(WorkflowModificationException.class, () -> { + InternalItem mockItem = new InternalItem(); + mockItem.setId(ITEM1_ID); + mockItem.setStatus(ItemStatus.ARCHIVED); + doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); + workflowVersionManager.create(ITEM1_ID, null, new WorkflowVersion(VERSION1_ID)); + }); } - @Test(expected = WorkflowModificationException.class) + @Test public void shouldThrowExceptionWhenUpdatingVersionForArchivedWorkflow() { - InternalItem mockItem = new InternalItem(); - mockItem.setId(ITEM1_ID); - mockItem.setStatus(ItemStatus.ARCHIVED); - doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); - workflowVersionManager.update(ITEM1_ID, new WorkflowVersion(VERSION1_ID)); + assertThrows(WorkflowModificationException.class, () -> { + InternalItem mockItem = new InternalItem(); + mockItem.setId(ITEM1_ID); + mockItem.setStatus(ItemStatus.ARCHIVED); + doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); + workflowVersionManager.update(ITEM1_ID, new WorkflowVersion(VERSION1_ID)); + }); } - @Test(expected = WorkflowModificationException.class) + @Test public void shouldThrowExceptionWhenUploadingArtifactForArchivedWorkflow() { - InternalItem mockItem = new InternalItem(); - mockItem.setId(ITEM1_ID); - mockItem.setStatus(ItemStatus.ARCHIVED); - doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); - MockMultipartFile mockFile = new MockMultipartFile("data", "filename.txt", "text/plain", "some xml".getBytes()); - workflowVersionManager.uploadArtifact(ITEM1_ID, VERSION1_ID, mockFile); + assertThrows(WorkflowModificationException.class, () -> { + InternalItem mockItem = new InternalItem(); + mockItem.setId(ITEM1_ID); + mockItem.setStatus(ItemStatus.ARCHIVED); + doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); + MockMultipartFile mockFile = new MockMultipartFile("data", "filename.txt", "text/plain", "some xml".getBytes()); + workflowVersionManager.uploadArtifact(ITEM1_ID, VERSION1_ID, mockFile); + }); } - @Test(expected = WorkflowModificationException.class) + @Test public void shouldThrowExceptionWhenDeletingArtifactForArchivedWorkflow() { - InternalItem mockItem = new InternalItem(); - mockItem.setId(ITEM1_ID); - mockItem.setStatus(ItemStatus.ARCHIVED); - doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); - workflowVersionManager.deleteArtifact(ITEM1_ID, VERSION1_ID); + assertThrows(WorkflowModificationException.class, () -> { + InternalItem mockItem = new InternalItem(); + mockItem.setId(ITEM1_ID); + mockItem.setStatus(ItemStatus.ARCHIVED); + doReturn(mockItem).when(itemManagerMock).get(ITEM1_ID); + workflowVersionManager.deleteArtifact(ITEM1_ID, VERSION1_ID); + }); } @Test @@ -277,35 +285,41 @@ public class WorkflowVersionManagerImplTest { workflowVersionManager.create(ITEM1_ID, null, versionRequest); } - @Test(expected = VersionCreationException.class) + @Test public void shouldTrowExceptionWhenDraftVersionExists() { - doNothing().when(workflowVersionManager).validateWorkflowStatus(ITEM1_ID); - WorkflowVersion versionRequestDto = new WorkflowVersion(); + assertThrows(VersionCreationException.class, () -> { + doNothing().when(workflowVersionManager).validateWorkflowStatus(ITEM1_ID); + WorkflowVersion versionRequestDto = new WorkflowVersion(); - Version baseVersion = createRetrievedVersion(VERSION2_ID, VersionStatus.Draft); - List<Version> versions = Collections.singletonList(baseVersion); - doReturn(versions).when(versioningManagerMock).list(ITEM1_ID); + Version baseVersion = createRetrievedVersion(VERSION2_ID, VersionStatus.Draft); + List<Version> versions = Collections.singletonList(baseVersion); + doReturn(versions).when(versioningManagerMock).list(ITEM1_ID); - workflowVersionManager.create(ITEM1_ID, VERSION2_ID, versionRequestDto); + workflowVersionManager.create(ITEM1_ID, VERSION2_ID, versionRequestDto); + }); } - @Test(expected = VersionCreationException.class) + @Test public void shouldTrowExceptionWhenInputsSupplied() { - doNothing().when(workflowVersionManager).validateWorkflowStatus(ITEM1_ID); - WorkflowVersion versionRequestDto = new WorkflowVersion(); - versionRequestDto.setInputs(Collections.singleton(new ParameterEntity())); - InternalVersion baseVersion = createRetrievedVersion(VERSION2_ID, VersionStatus.Draft); - List<Version> versions = Collections.singletonList(baseVersion); - doReturn(versions).when(versioningManagerMock).list(ITEM1_ID); - - workflowVersionManager.create(ITEM1_ID, VERSION2_ID, versionRequestDto); + assertThrows(VersionCreationException.class, () -> { + doNothing().when(workflowVersionManager).validateWorkflowStatus(ITEM1_ID); + WorkflowVersion versionRequestDto = new WorkflowVersion(); + versionRequestDto.setInputs(Collections.singleton(new ParameterEntity())); + InternalVersion baseVersion = createRetrievedVersion(VERSION2_ID, VersionStatus.Draft); + List<Version> versions = Collections.singletonList(baseVersion); + doReturn(versions).when(versioningManagerMock).list(ITEM1_ID); + + workflowVersionManager.create(ITEM1_ID, VERSION2_ID, versionRequestDto); + }); } - @Test(expected = EntityNotFoundException.class) + @Test public void getStateOfNonExisting() { - doThrow(new RuntimeException()).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); - workflowVersionManager.getState(ITEM1_ID, VERSION1_ID); + assertThrows(EntityNotFoundException.class, () -> { + doThrow(new RuntimeException()).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); + workflowVersionManager.getState(ITEM1_ID, VERSION1_ID); + }); } @Test @@ -318,43 +332,49 @@ public class WorkflowVersionManagerImplTest { assertEquals(CERTIFIED, state); } - @Test(expected = EntityNotFoundException.class) + @Test public void updateStateOfNonExisting() { - doThrow(new RuntimeException()).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); - workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, CERTIFIED); + assertThrows(EntityNotFoundException.class, () -> { + doThrow(new RuntimeException()).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); + workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, CERTIFIED); + }); } - @Test(expected = VersionStateModificationException.class) + @Test public void updateStateToCurrentState() { - InternalVersion version = createRetrievedVersion(VERSION1_ID, VersionStatus.Draft); - doReturn(version).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); - doReturn(DRAFT).when(versionStateMapperMock).versionStatusToWorkflowVersionState(version.getStatus()); + assertThrows(VersionStateModificationException.class, () -> { + InternalVersion version = createRetrievedVersion(VERSION1_ID, VersionStatus.Draft); + doReturn(version).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); + doReturn(DRAFT).when(versionStateMapperMock).versionStatusToWorkflowVersionState(version.getStatus()); - workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, DRAFT); + workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, DRAFT); + }); } - @Test(expected = VersionStateModificationMissingArtifactException.class) + @Test public void updateStateWhenCertified() { - InternalVersion version = createRetrievedVersion(VERSION1_ID, VersionStatus.Certified); - doReturn(version).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); - doReturn(CERTIFIED).when(versionStateMapperMock).versionStatusToWorkflowVersionState(version.getStatus()); + assertThrows(VersionStateModificationMissingArtifactException.class, () -> { + InternalVersion version = createRetrievedVersion(VERSION1_ID, VersionStatus.Certified); + doReturn(version).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); + doReturn(CERTIFIED).when(versionStateMapperMock).versionStatusToWorkflowVersionState(version.getStatus()); - workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, CERTIFIED); + workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, CERTIFIED); + }); } @Test public void shouldFailUpdateStateWhenNoArtifact() { - InternalVersion retrievedVersion = createRetrievedVersion(VERSION1_ID, VersionStatus.Draft); - doReturn(retrievedVersion).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); - doReturn(DRAFT).when(versionStateMapperMock).versionStatusToWorkflowVersionState(VersionStatus.Draft); - - exceptionRule.expect(VersionStateModificationMissingArtifactException.class); - exceptionRule.expectMessage(String.format( + Throwable exception = assertThrows(VersionStateModificationMissingArtifactException.class, () -> { + InternalVersion retrievedVersion = createRetrievedVersion(VERSION1_ID, VersionStatus.Draft); + doReturn(retrievedVersion).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); + doReturn(DRAFT).when(versionStateMapperMock).versionStatusToWorkflowVersionState(VersionStatus.Draft); + workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, CERTIFIED); + + verify(versioningManagerMock).updateStatus(ITEM1_ID, VERSION1_ID, VersionStatus.Certified, anyString()); + }); + assertTrue(exception.getMessage().contains(String.format( VersionStateModificationMissingArtifactException.WORKFLOW_MODIFICATION_STATE_MISSING_ARTIFACT_TEMPLATE, - ITEM1_ID, VERSION1_ID, DRAFT, CERTIFIED)); - workflowVersionManager.updateState(ITEM1_ID, VERSION1_ID, CERTIFIED); - - verify(versioningManagerMock).updateStatus(ITEM1_ID, VERSION1_ID, VersionStatus.Certified, anyString()); + ITEM1_ID, VERSION1_ID, DRAFT, CERTIFIED))); } @Test @@ -384,12 +404,14 @@ public class WorkflowVersionManagerImplTest { verify(artifactRepositoryMock).update(eq(ITEM1_ID), eq(VERSION1_ID), any(ArtifactEntity.class)); } - @Test(expected = EntityNotFoundException.class) + @Test public void shouldThrowExceptionWhenArtifactNotFound() { - doReturn(new Version()).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); + assertThrows(EntityNotFoundException.class, () -> { + doReturn(new Version()).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); - doReturn(Optional.empty()).when(artifactRepositoryMock).get(ITEM1_ID, VERSION1_ID); - workflowVersionManager.getArtifact(ITEM1_ID, VERSION1_ID); + doReturn(Optional.empty()).when(artifactRepositoryMock).get(ITEM1_ID, VERSION1_ID); + workflowVersionManager.getArtifact(ITEM1_ID, VERSION1_ID); + }); } @Test @@ -403,15 +425,17 @@ public class WorkflowVersionManagerImplTest { assertEquals(artifactMock, returnedArtifact); } - @Test(expected = VersionModificationException.class) + @Test public void shouldThrowExceptionInDeleteArtifactWhenVersionIsCertified() { - doNothing().when(workflowVersionManager).validateWorkflowStatus(ITEM1_ID); - Version version = new Version(); - doReturn(version).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); - WorkflowVersion workflowVersion = new WorkflowVersion(VERSION1_ID); - workflowVersion.setState(WorkflowVersionState.CERTIFIED); - doReturn(workflowVersion).when(versionMapperMock).fromVersion(version); - workflowVersionManager.deleteArtifact(ITEM1_ID, VERSION1_ID); + assertThrows(VersionModificationException.class, () -> { + doNothing().when(workflowVersionManager).validateWorkflowStatus(ITEM1_ID); + Version version = new Version(); + doReturn(version).when(versioningManagerMock).get(ITEM1_ID, VERSION1_ID); + WorkflowVersion workflowVersion = new WorkflowVersion(VERSION1_ID); + workflowVersion.setState(WorkflowVersionState.CERTIFIED); + doReturn(workflowVersion).when(versionMapperMock).fromVersion(version); + workflowVersionManager.deleteArtifact(ITEM1_ID, VERSION1_ID); + }); } @Test diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapperTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapperTest.java index 8bffc3e1..f8eb7900 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapperTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionMapperTest.java @@ -16,11 +16,10 @@ package org.onap.sdc.workflow.services.impl.mappers; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Date; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.onap.sdc.common.versioning.persistence.types.InternalVersion; import org.onap.sdc.common.versioning.services.types.Version; import org.onap.sdc.common.versioning.services.types.VersionStatus; @@ -29,11 +28,9 @@ import org.onap.sdc.workflow.services.types.WorkflowVersionState; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@ContextConfiguration(classes = VersionMapperTest.VersionMapperSpringTestConfig.class) -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig(classes = VersionMapperTest.VersionMapperSpringTestConfig.class) public class VersionMapperTest { @Configuration diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapperTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapperTest.java index c0804eb8..dfe2ccc1 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapperTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/VersionStateMapperTest.java @@ -16,20 +16,17 @@ package org.onap.sdc.workflow.services.impl.mappers; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.onap.sdc.workflow.services.types.WorkflowVersionState; import org.onap.sdc.common.versioning.services.types.VersionStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@ContextConfiguration(classes = VersionStateMapperTest.VersionStatusMapperSpringTestConfig.class) -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig(classes = VersionStateMapperTest.VersionStatusMapperSpringTestConfig.class) public class VersionStateMapperTest { @Configuration diff --git a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java index ef84190a..7f5d9fe7 100644 --- a/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java +++ b/sdc-workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/mappers/WorkflowMapperTest.java @@ -17,12 +17,11 @@ package org.onap.sdc.workflow.services.impl.mappers; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.onap.sdc.workflow.TestUtil.createItem; import static org.onap.sdc.workflow.TestUtil.createWorkflow; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.onap.sdc.common.versioning.services.types.Item; import org.onap.sdc.common.versioning.services.types.ItemStatus; import org.onap.sdc.workflow.services.impl.ItemType; @@ -31,11 +30,9 @@ import org.onap.sdc.workflow.services.types.Workflow; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -@ContextConfiguration(classes = WorkflowMapperTest.WorkflowMapperSpringTestConfig.class) -@RunWith(SpringJUnit4ClassRunner.class) +@SpringJUnitConfig(classes = WorkflowMapperTest.WorkflowMapperSpringTestConfig.class) public class WorkflowMapperTest { @Configuration |