diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/catalog/impl/DmaapProducerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/catalog/impl/DmaapProducerTest.java
index cd0c321..be84780 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/catalog/impl/DmaapProducerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/catalog/impl/DmaapProducerTest.java
@@ -20,14 +20,25 @@
 
 package org.openecomp.sdc.be.catalog.impl;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+import static org.mockito.Mockito.mock;
+import static org.openecomp.sdc.be.catalog.enums.ResultStatusEnum.FAIL;
+import static org.openecomp.sdc.be.catalog.enums.ResultStatusEnum.SERVICE_DISABLED;
+
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openecomp.sdc.be.catalog.api.IComponentMessage;
 import org.openecomp.sdc.be.catalog.api.IStatus;
 import org.openecomp.sdc.be.catalog.enums.ChangeTypeEnum;
+import org.openecomp.sdc.be.components.distribution.engine.DmaapClientFactory;
+import org.openecomp.sdc.be.config.Configuration;
 import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.config.DmaapProducerConfiguration;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
 import org.openecomp.sdc.be.model.CatalogUpdateTimestamp;
@@ -35,41 +46,42 @@
 import org.openecomp.sdc.be.model.Resource;
 import org.openecomp.sdc.be.model.category.CategoryDefinition;
 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
+import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.impl.ExternalConfiguration;
+import org.openecomp.sdc.common.impl.FSConfigurationSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-import static org.openecomp.sdc.be.catalog.enums.ResultStatusEnum.FAIL;
-import static org.openecomp.sdc.be.catalog.enums.ResultStatusEnum.SERVICE_DISABLED;
-import static org.openecomp.sdc.be.config.ConfigurationManager.getConfigurationManager;
-
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration("classpath:application-context-test.xml")
-public class DmaapProducerTest {
-    private static final Logger LOG = LoggerFactory.getLogger(DmaapProducer.class);
+class DmaapProducerTest {
 
-    @Autowired
-    ConfigurationManager configurationManager;
- 
-    @Autowired
+    private static final Logger LOG = LoggerFactory.getLogger(DmaapProducerTest.class);
+
+    private ConfigurationManager configurationManager;
     private DmaapProducer dmaapProducer;
-   
+    private DmaapClientFactory dmaapClientFactory;
 
-    //actually sends the message
-
+    @BeforeEach
+    public void setup() {
+        final ConfigurationSource configurationSource = new FSConfigurationSource(
+            ExternalConfiguration.getChangeListener(),
+            "src/test/resources/config/catalog-be");
+        configurationManager = new ConfigurationManager(configurationSource);
+        final Configuration configuration = new Configuration();
+        final DmaapProducerConfiguration dmaapProducerConfiguration = new DmaapProducerConfiguration();
+        dmaapProducerConfiguration.setActive(true);
+        configuration.setJanusGraphInMemoryGraph(true);
+        configurationManager.setConfiguration(configuration);
+        configurationManager.getConfiguration().setDmaapProducerConfiguration(dmaapProducerConfiguration);
+        ExternalConfiguration.setAppName("catalog-be");
+        dmaapProducer = new DmaapProducer(mock(DmaapClientFactory.class), mock(DmaapProducerHealth.class));
+    }
 
     @Test
-    public void pushComponentMessageTest() {
+    void pushComponentMessageTest() {
         boolean oldVal = isActive();
-
-        Resource resource = new Resource();
+        final Resource resource = new Resource();
         resource.setUniqueId("mockUniqueId");
         resource.setUUID("mockNameUUID");
         resource.setResourceType(ResourceTypeEnum.VF);
@@ -84,56 +96,51 @@
         resource.setHighestVersion(true);
         resource.setArchived(false);
 
-        List<CategoryDefinition> categories = new ArrayList<>();
-        CategoryDefinition cat = new CategoryDefinition();
-        cat.setName("mockCategory");
-        cat.setNormalizedName("mockCategory");
-        cat.setUniqueId("uniqueId");
-        SubCategoryDefinition subcat = new SubCategoryDefinition();
-        subcat.setName("mockSubCategory");
-        subcat.setNormalizedName("mockSubCategory");
-        subcat.setUniqueId("mockSubCategoryUniqueId");
-        cat.addSubCategory(subcat);
-        categories.add(cat);
+        final List<CategoryDefinition> categories = new ArrayList<>();
+        final CategoryDefinition categoryDefinition = new CategoryDefinition();
+        categoryDefinition.setName("mockCategory");
+        categoryDefinition.setNormalizedName("mockCategory");
+        categoryDefinition.setUniqueId("uniqueId");
+        final SubCategoryDefinition subCategoryDefinition = new SubCategoryDefinition();
+        subCategoryDefinition.setName("mockSubCategory");
+        subCategoryDefinition.setNormalizedName("mockSubCategory");
+        subCategoryDefinition.setUniqueId("mockSubCategoryUniqueId");
+        categoryDefinition.addSubCategory(subCategoryDefinition);
+        categories.add(categoryDefinition);
         resource.setCategories(categories);
 
-        IComponentMessage message = new ComponentMessage(resource, ChangeTypeEnum.LIFECYCLE, new CatalogUpdateTimestamp(123, 1234));
-        ObjectMapper mapper = new ObjectMapper();
+        final IComponentMessage message = new ComponentMessage(resource, ChangeTypeEnum.LIFECYCLE,
+            new CatalogUpdateTimestamp(123, 1234));
         try {
-            String jsonInString = mapper.writeValueAsString(message);
-            LOG.info("[DmaapProducer] pushing message =>{}",jsonInString);
-            //push msg by configuration => will send the message if configuration enables
-            //IStatus status = dmaapProducer.pushComponentMessage(message);
+            LOG.info("[DmaapProducer] pushing message =>{}", new ObjectMapper().writeValueAsString(message));
+            //push message by configuration => will send the message if configuration enables
             //will not test network connectivity to avoid build server automation fail
-
             toggleInactive();
             IStatus status = dmaapProducer.pushMessage(message);
             assertThat(status.getResultStatus()).isEqualTo(SERVICE_DISABLED);
-
             toggleActive();
             dmaapProducer.shutdown();
             status = dmaapProducer.pushMessage(message);
             assertThat(status.getResultStatus()).isEqualTo(FAIL);
-
-        } catch (JsonProcessingException e) {
+        } catch (final JsonProcessingException e) {
             fail("'JsonProcessingException' detected!", e);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             fail("Unknown exception detected", e);
-        }finally {
+        } finally {
             configurationManager.getConfiguration().getDmaapProducerConfiguration().setActive(oldVal);
         }
     }
 
-    private boolean isActive(){
+    private boolean isActive() {
         return configurationManager.getConfiguration().getDmaapProducerConfiguration().getActive();
     }
 
-    private void toggleInactive(){
+    private void toggleInactive() {
         configurationManager.getConfiguration().getDmaapProducerConfiguration().setActive(false);
     }
 
-    private void toggleActive(){
+    private void toggleActive() {
         configurationManager.getConfiguration().getDmaapProducerConfiguration().setActive(true);
     }
 
-}
\ No newline at end of file
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java
index 68fa486..9b6a26d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceDistributionBLTest.java
@@ -28,8 +28,8 @@
 import static org.mockito.Mockito.when;
 
 import fj.data.Either;
-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.Mockito;
 import org.mockito.MockitoAnnotations;
@@ -57,10 +57,7 @@
 import org.openecomp.sdc.common.util.ThreadLocalsHolder;
 import org.openecomp.sdc.exception.ResponseFormat;
 
-/**
- * Created by chaya on 10/26/2017.
- */
-public class ServiceDistributionBLTest extends ComponentBusinessLogicMock {
+class ServiceDistributionBLTest extends ComponentBusinessLogicMock {
 
     private final ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class);
     private final DistributionEngine distributionEngine = Mockito.mock(DistributionEngine.class);
@@ -70,9 +67,8 @@
     private final ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class);
     private final UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class);
 
-
     @InjectMocks
-    ServiceBusinessLogic bl = new ServiceBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
+    private final ServiceBusinessLogic bl = new ServiceBusinessLogic(elementDao, groupOperation, groupInstanceOperation,
         groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation,
         artifactsBusinessLogic, distributionEngine, componentInstanceBusinessLogic,
         serviceDistributionValidation, forwardingPathValidator, uiComponentDataConverter,
@@ -80,8 +76,6 @@
         componentNameValidator, componentTagsValidator, componentValidator, componentIconValidator,
         componentProjectCodeValidator, componentDescriptionValidator);
 
-    ComponentsUtils componentsUtils;
-
     private Service serviceToActivate;
     private ActivationRequestInformation activationRequestInformation;
     private String WORKLOAD_CONTEXT = "vnfContext";
@@ -89,46 +83,42 @@
     private String DID = "distributionId";
     private User modifier;
 
-
-    public ServiceDistributionBLTest() {
-    }
-
-    @Before
+    @BeforeEach
     public void setup() {
 
         ExternalConfiguration.setAppName("catalog-be");
         MockitoAnnotations.initMocks(this);
-        componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
+        final ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
         bl.setComponentsUtils(componentsUtils);
         serviceToActivate = new Service();
         serviceToActivate.setDistributionStatus(DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED);
         activationRequestInformation = new ActivationRequestInformation(serviceToActivate, WORKLOAD_CONTEXT, TENANT);
         when(toscaOperationFacade.getToscaElement(anyString(), any(ComponentParametersView.class)))
-                .thenReturn(Either.left(serviceToActivate));
+            .thenReturn(Either.left(serviceToActivate));
         when(distributionEngine.buildServiceForDistribution(any(Service.class), anyString(), anyString()))
-                .thenReturn(new NotificationDataImpl());
+            .thenReturn(new NotificationDataImpl());
         modifier = new User();
         modifier.setUserId("uid");
         modifier.setFirstName("user");
     }
 
     @Test
-    public void testActivateServiceOnTenantValidationFails() {
+    void testActivateServiceOnTenantValidationFails() {
         int VALIDATION_FAIL_STATUS = 666;
         when(serviceDistributionValidation.validateActivateServiceRequest
-                (anyString(), anyString(),any(User.class), any(ServiceDistributionReqInfo.class)))
-                .thenReturn(Either.right(new ResponseFormat(VALIDATION_FAIL_STATUS)));
+            (anyString(), anyString(), any(User.class), any(ServiceDistributionReqInfo.class)))
+            .thenReturn(Either.right(new ResponseFormat(VALIDATION_FAIL_STATUS)));
         Either<String, ResponseFormat> stringResponseFormatEither = callActivateServiceOnTenantWIthDefaults();
         assertTrue(stringResponseFormatEither.isRight());
         assertEquals((int) stringResponseFormatEither.right().value().getStatus(), VALIDATION_FAIL_STATUS);
     }
 
     //TODO see if we want to add ActionStatus.AUTHENTICATION_ERROR to error-configuration.yaml
-    @Test
-    public void testDistributionAuthenticationFails() {
+    @Test()
+    void testDistributionAuthenticationFails() {
         mockAllMethodsUntilDENotification();
-        when(distributionEngine.notifyService(anyString(),any(Service.class), any(INotificationData.class), anyString(),any(User.class)))
-                .thenReturn(ActionStatus.AUTHENTICATION_ERROR);
+        when(distributionEngine.notifyService(anyString(), any(Service.class), any(INotificationData.class), anyString(), any(User.class)))
+            .thenReturn(ActionStatus.AUTHENTICATION_ERROR);
         Either<String, ResponseFormat> stringResponseFormatEither = callActivateServiceOnTenantWIthDefaults();
         assertTrue(stringResponseFormatEither.isRight());
         assertEquals(502, (int) stringResponseFormatEither.right().value().getStatus());
@@ -136,11 +126,11 @@
     }
 
     //TODO see if we want to add ActionStatus.AUTHENTICATION_ERROR to error-configuration.yaml
-    @Test
-    public void testDistributionUnknownHostFails() {
+    @Test()
+    void testDistributionUnknownHostFails() {
         mockAllMethodsUntilDENotification();
-        when(distributionEngine.notifyService(anyString(),any(Service.class), any(INotificationData.class), anyString(), any(User.class)))
-                .thenReturn(ActionStatus.UNKNOWN_HOST);
+        when(distributionEngine.notifyService(anyString(), any(Service.class), any(INotificationData.class), anyString(), any(User.class)))
+            .thenReturn(ActionStatus.UNKNOWN_HOST);
         Either<String, ResponseFormat> stringResponseFormatEither = callActivateServiceOnTenantWIthDefaults();
         assertTrue(stringResponseFormatEither.isRight());
         assertEquals(502, (int) stringResponseFormatEither.right().value().getStatus());
@@ -148,11 +138,11 @@
     }
 
     //TODO see if we want to add ActionStatus.AUTHENTICATION_ERROR to error-configuration.yaml
-    @Test
-    public void testDistributionConnectionErrorFails() {
+    @Test()
+    void testDistributionConnectionErrorFails() {
         mockAllMethodsUntilDENotification();
-        when(distributionEngine.notifyService(anyString(),any(Service.class), any(INotificationData.class), anyString(), any(User.class)))
-                .thenReturn(ActionStatus.CONNNECTION_ERROR);
+        when(distributionEngine.notifyService(anyString(), any(Service.class), any(INotificationData.class), anyString(), any(User.class)))
+            .thenReturn(ActionStatus.CONNNECTION_ERROR);
         Either<String, ResponseFormat> stringResponseFormatEither = callActivateServiceOnTenantWIthDefaults();
         assertTrue(stringResponseFormatEither.isRight());
         assertEquals(502, (int) stringResponseFormatEither.right().value().getStatus());
@@ -160,11 +150,22 @@
     }
 
     //TODO see if we want to add ActionStatus.AUTHENTICATION_ERROR to error-configuration.yaml
-    @Test
-    public void testDistributionObjectNotFoundFails() {
+    @Test()
+    void testDistributionObjectNotFoundFails() {
         mockAllMethodsUntilDENotification();
-        when(distributionEngine.notifyService(anyString(),any(Service.class), any(INotificationData.class), anyString(), any(User.class)))
-                .thenReturn(ActionStatus.OBJECT_NOT_FOUND);
+        when(distributionEngine.notifyService(anyString(), any(Service.class), any(INotificationData.class), anyString(), any(User.class)))
+            .thenReturn(ActionStatus.OBJECT_NOT_FOUND);
+        Either<String, ResponseFormat> stringResponseFormatEither = callActivateServiceOnTenantWIthDefaults();
+        assertTrue(stringResponseFormatEither.isRight());
+        assertEquals(502, (int) stringResponseFormatEither.right().value().getStatus());
+        assertEquals("SVC4676", stringResponseFormatEither.right().value().getMessageId());
+    }
+
+    @Test()
+    void testDistributionGeneralFails() {
+        mockAllMethodsUntilDENotification();
+        when(distributionEngine.notifyService(anyString(), any(Service.class), any(INotificationData.class), anyString(), any(User.class)))
+            .thenReturn(ActionStatus.GENERAL_ERROR);
         Either<String, ResponseFormat> stringResponseFormatEither = callActivateServiceOnTenantWIthDefaults();
         assertTrue(stringResponseFormatEither.isRight());
         assertEquals(502, (int) stringResponseFormatEither.right().value().getStatus());
@@ -172,22 +173,12 @@
     }
 
     @Test
-    public void testDistributionGeneralFails() {
-        mockAllMethodsUntilDENotification();
-        when(distributionEngine.notifyService(anyString(),any(Service.class), any(INotificationData.class), anyString(), any(User.class)))
-                .thenReturn(ActionStatus.GENERAL_ERROR);
-        Either<String, ResponseFormat> stringResponseFormatEither = callActivateServiceOnTenantWIthDefaults();
-        assertTrue(stringResponseFormatEither.isRight());
-        assertEquals(502, (int) stringResponseFormatEither.right().value().getStatus());
-        assertEquals("SVC4676", stringResponseFormatEither.right().value().getMessageId());
-    }
-
-    @Test
-    public void testDistributionOk() {
+    void testDistributionOk() {
         mockAllMethodsUntilDENotification();
         ThreadLocalsHolder.setUuid(DID);
-        when(distributionEngine.notifyService(anyString(),any(Service.class), any(INotificationData.class), anyString(), anyString(), any(User.class)))
-                .thenReturn(ActionStatus.OK);
+        when(distributionEngine
+            .notifyService(anyString(), any(Service.class), any(INotificationData.class), anyString(), anyString(), any(User.class)))
+            .thenReturn(ActionStatus.OK);
         Either<String, ResponseFormat> stringResponseFormatEither = callActivateServiceOnTenantWIthDefaults();
         assertTrue(stringResponseFormatEither.isLeft());
         assertEquals(stringResponseFormatEither.left().value(), DID);
@@ -195,8 +186,8 @@
 
     private void mockAllMethodsUntilDENotification() {
         when(serviceDistributionValidation.validateActivateServiceRequest
-                (anyString(), anyString(),any(User.class), any(ServiceDistributionReqInfo.class)))
-                .thenReturn(Either.left(activationRequestInformation));
+            (anyString(), anyString(), any(User.class), any(ServiceDistributionReqInfo.class)))
+            .thenReturn(Either.left(activationRequestInformation));
         when(healthCheckBusinessLogic.isDistributionEngineUp()).thenReturn(true);
     }
 
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java
index f331e07..6239d33 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogicTest.java
@@ -21,16 +21,22 @@
  */
 package org.openecomp.sdc.be.components.impl;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+
 import fj.data.Either;
+import java.util.HashMap;
+import java.util.Map;
 import org.apache.commons.lang3.RandomStringUtils;
-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.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
-import org.openecomp.sdc.be.config.ConfigurationManager;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -42,223 +48,214 @@
 import org.openecomp.sdc.be.model.operations.impl.ConsumerOperation;
 import org.openecomp.sdc.be.resources.data.ConsumerData;
 import org.openecomp.sdc.be.user.UserBusinessLogic;
-import org.openecomp.sdc.common.impl.ExternalConfiguration;
-import org.openecomp.sdc.common.impl.FSConfigurationSource;
 import org.openecomp.sdc.exception.ResponseFormat;
 
-import java.util.HashMap;
-import java.util.Map;
+class ConsumerBusinessLogicTest extends BaseBusinessLogicMock {
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
+    private User user;
+    private ConsumerDefinition consumer;
+    private ConsumerDataDefinition consumerDataDefinition;
 
-public class ConsumerBusinessLogicTest extends BaseBusinessLogicMock {
+    @InjectMocks
+    private ConsumerBusinessLogic consumerBusinessLogic;
 
-	private User user;
-	private ConsumerDefinition consumer;
-	private ConsumerDataDefinition consumerDataDefinition;
+    @Mock
+    private ComponentsUtils componentsUtils;
 
-	@InjectMocks
-	private ConsumerBusinessLogic consumerBusinessLogic;
+    @Mock
+    private UserBusinessLogic UserBusinessLogic;
 
-	@Mock
-	private ComponentsUtils componentsUtils;
+    @Mock
+    private IGraphLockOperation iGraphLockOperation;
 
-	@Mock
-	private UserBusinessLogic UserBusinessLogic;
+    @Mock
+    private ConsumerOperation consumerOperation;
 
-	@Mock
-	private IGraphLockOperation iGraphLockOperation;
+    @Mock
+    private ConsumerData consumerData;
 
-	@Mock
-	private ConsumerOperation consumerOperation;
+    @BeforeEach
+    public void setUp() {
+        consumerBusinessLogic = new ConsumerBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+            interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
+        consumerDataDefinition = new ConsumerDataDefinition();
+        consumer = new ConsumerDefinition();
+        MockitoAnnotations.initMocks(this);
+        user = new User("Stan", "Lee", "stan.lee",
+            "stan.lee@marvel.com", "ADMIN", 1542024000L);
+    }
 
-	@Mock
-	private ConsumerData consumerData;
+    @Test
+    void testCreateConsumer_givenMissingUser_thenReturnsError() {
+        User user = new User();
+        ConsumerDefinition consumerDefinition = new ConsumerDefinition();
+        Mockito.when(componentsUtils.getResponseFormat(ActionStatus.MISSING_INFORMATION))
+            .thenReturn(new ResponseFormat());
+        assertTrue(consumerBusinessLogic.createConsumer(user, consumerDefinition).isRight());
+    }
 
-	@Before
-	public void setUp(){
-		consumerBusinessLogic = new ConsumerBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
-			interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
-		consumerDataDefinition = new ConsumerDataDefinition();
-		consumer = new ConsumerDefinition();
-		MockitoAnnotations.initMocks(this);
-		user = new User("Stan", "Lee", "stan.lee",
-				"stan.lee@marvel.com", "ADMIN", 1542024000L);
-	}
+    @Test
+    void testCreateConsumer_givenNonListedUser_thenReturnsError() {
+        ConsumerDefinition consumerDefinition = new ConsumerDefinition();
+        Mockito.when(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_ACCESS))
+            .thenReturn(new ResponseFormat());
+        Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false))
+            .thenThrow(new ByActionStatusComponentException(ActionStatus.RESTRICTED_OPERATION));
+        assertTrue(consumerBusinessLogic.createConsumer(user, consumerDefinition).isRight());
+    }
 
-	@Test
-	public void testCreateConsumer_givenMissingUser_thenReturnsError() {
-		User user = new User();
-		ConsumerDefinition consumerDefinition = new ConsumerDefinition();
-		Mockito.when(componentsUtils.getResponseFormat(ActionStatus.MISSING_INFORMATION))
-				.thenReturn(new ResponseFormat());
-		assertTrue(consumerBusinessLogic.createConsumer(user, consumerDefinition).isRight());
-	}
+    @Test
+    void testCreateConsumer_givenNonAdminUser_thenReturnsError() {
+        user.setRole("DESIGNER");
+        Mockito.when(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION))
+            .thenReturn(new ResponseFormat());
+        Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+        assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
+    }
 
-	@Test
-	public void testCreateConsumer_givenNonListedUser_thenReturnsError() {
-		ConsumerDefinition consumerDefinition = new ConsumerDefinition();
-		Mockito.when(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_ACCESS))
-				.thenReturn(new ResponseFormat());
-		Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenThrow(new ByActionStatusComponentException(ActionStatus.RESTRICTED_OPERATION));
-		assertTrue(consumerBusinessLogic.createConsumer(user, consumerDefinition).isRight());
-	}
+    @Test
+    void testCreateConsumer_givenInvalidConsumerNames_thenReturnsError() {
+        Map<String, ActionStatus> invalidConsumerNames = new HashMap<>();
+        invalidConsumerNames.put(null, ActionStatus.MISSING_DATA);
+        invalidConsumerNames.put(".#()", ActionStatus.INVALID_CONTENT);
+        invalidConsumerNames.put(RandomStringUtils.random(256, true, false), ActionStatus.EXCEEDS_LIMIT);
+        for (Map.Entry<String, ActionStatus> e : invalidConsumerNames.entrySet()) {
+            consumer.setConsumerName(e.getKey());
+            Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+            Mockito.when(componentsUtils.getResponseFormat(e.getValue(), "Consumer name"))
+                .thenReturn(new ResponseFormat());
+            assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
+        }
+    }
 
-	@Test
-	public void testCreateConsumer_givenNonAdminUser_thenReturnsError() {
-		user.setRole("DESIGNER");
-		Mockito.when(componentsUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION))
-				.thenReturn(new ResponseFormat());
-		Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-		assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
-	}
+    @Test
+    void testCreateConsumer_givenInvalidConsumerPasswords_thenReturnsError() {
+        Map<String, ActionStatus> invalidPasswordResults = new HashMap<>();
+        invalidPasswordResults.put(null, ActionStatus.MISSING_DATA);
+        invalidPasswordResults.put(RandomStringUtils.random(64, '*'), ActionStatus.INVALID_CONTENT_PARAM);
+        invalidPasswordResults.put("password", ActionStatus.INVALID_LENGTH);
+        for (Map.Entry<String, ActionStatus> e : invalidPasswordResults.entrySet()) {
+            consumer.setConsumerName("_marvel");
+            consumer.setConsumerPassword(e.getKey());
+            Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+            Mockito.when(componentsUtils.getResponseFormat(e.getValue(), "Consumer password"))
+                .thenReturn(new ResponseFormat());
+            assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
+        }
+    }
 
-	@Test
-	public void testCreateConsumer_givenInvalidConsumerNames_thenReturnsError() {
-		Map<String, ActionStatus> invalidConsumerNames = new HashMap<>();
-		invalidConsumerNames.put(null, ActionStatus.MISSING_DATA);
-		invalidConsumerNames.put(".#()", ActionStatus.INVALID_CONTENT);
-		invalidConsumerNames.put(RandomStringUtils.random(256, true, false), ActionStatus.EXCEEDS_LIMIT);
-		for(Map.Entry<String, ActionStatus> e: invalidConsumerNames.entrySet()){
-			consumer.setConsumerName(e.getKey());
-			Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-			Mockito.when(componentsUtils.getResponseFormat(e.getValue(), "Consumer name"))
-					.thenReturn(new ResponseFormat());
-			assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
-		}
-	}
+    @Test
+    void testCreateConsumer_givenInvalidConsumerSalts_thenReturnsError() {
+        consumer.setConsumerPassword(RandomStringUtils.random(64, true, true));
+        Map<String, ActionStatus> invalidPasswordSalts = new HashMap<>();
+        invalidPasswordSalts.put(null, ActionStatus.MISSING_DATA);
+        invalidPasswordSalts.put(RandomStringUtils.random(32, "*"), ActionStatus.INVALID_CONTENT_PARAM);
+        invalidPasswordSalts.put("password", ActionStatus.INVALID_LENGTH);
+        for (Map.Entry<String, ActionStatus> e : invalidPasswordSalts.entrySet()) {
+            consumer.setConsumerName("_marvel");
+            consumer.setConsumerSalt(e.getKey());
+            Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+            Mockito.when(componentsUtils.getResponseFormat(e.getValue(), "Consumer salt"))
+                .thenReturn(new ResponseFormat());
+            assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
+        }
+    }
 
-	@Test
-	public void testCreateConsumer_givenInvalidConsumerPasswords_thenReturnsError() {
-		Map<String, ActionStatus> invalidPasswordResults = new HashMap<>();
-		invalidPasswordResults.put(null, ActionStatus.MISSING_DATA);
-		invalidPasswordResults.put(RandomStringUtils.random(64, '*' ), ActionStatus.INVALID_CONTENT_PARAM);
-		invalidPasswordResults.put("password", ActionStatus.INVALID_LENGTH);
-		for(Map.Entry<String, ActionStatus> e: invalidPasswordResults.entrySet()){
-			consumer.setConsumerName("_marvel");
-			consumer.setConsumerPassword(e.getKey());
-			Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-			Mockito.when(componentsUtils.getResponseFormat(e.getValue(), "Consumer password"))
-					.thenReturn(new ResponseFormat());
-			assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
-		}
-	}
+    @Test
+    void testCreateConsumer_givenConsumerNotLocked_thenReturnsError() {
+        consumer.setConsumerName("_marvel");
+        consumer.setConsumerPassword(RandomStringUtils.random(64, true, true));
+        consumer.setConsumerSalt(RandomStringUtils.random(32, 'a'));
+        Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+        Mockito.when(iGraphLockOperation.lockComponent(anyString(), any(NodeTypeEnum.class)))
+            .thenReturn(StorageOperationStatus.GENERAL_ERROR);
+        assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
+    }
 
-	@Test
-	public void testCreateConsumer_givenInvalidConsumerSalts_thenReturnsError() {
-		consumer.setConsumerPassword(RandomStringUtils.random(64, true,true));
-		Map<String, ActionStatus> invalidPasswordSalts = new HashMap<>();
-		invalidPasswordSalts.put(null, ActionStatus.MISSING_DATA);
-		invalidPasswordSalts.put(RandomStringUtils.random(32, "*" ), ActionStatus.INVALID_CONTENT_PARAM);
-		invalidPasswordSalts.put("password", ActionStatus.INVALID_LENGTH);
-		for(Map.Entry<String, ActionStatus> e: invalidPasswordSalts.entrySet()){
-			consumer.setConsumerName("_marvel");
-			consumer.setConsumerSalt(e.getKey());
-			Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-			Mockito.when(componentsUtils.getResponseFormat(e.getValue(), "Consumer salt"))
-					.thenReturn(new ResponseFormat());
-			assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
-		}
-	}
+    @Test
+    void testCreateConsumer_givenUnableToCreateCredentials_thenReturnsError() {
+        ConsumerDataDefinition consumerDataDefinition = new ConsumerDataDefinition();
+        consumerDataDefinition.setConsumerName("_marvel");
+        consumerDataDefinition.setConsumerPassword(RandomStringUtils.random(64, true, true));
+        consumerDataDefinition.setConsumerSalt(RandomStringUtils.random(32, 'a'));
+        ConsumerDefinition consumer = new ConsumerDefinition(consumerDataDefinition);
+        Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+        Mockito.when(iGraphLockOperation.lockComponent(anyString(), any(NodeTypeEnum.class)))
+            .thenReturn(StorageOperationStatus.OK);
+        Mockito.when(consumerOperation.getCredentials(anyString()))
+            .thenReturn(Either.right(StorageOperationStatus.OK));
+        Mockito.when(consumerOperation.createCredentials(any(ConsumerData.class)))
+            .thenReturn(Either.right(StorageOperationStatus.USER_NOT_FOUND));
+        assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
+    }
 
-	@Test
-	public void testCreateConsumer_givenConsumerNotLocked_thenReturnsError() {
-		consumer.setConsumerName("_marvel");
-		consumer.setConsumerPassword(RandomStringUtils.random(64, true,true));
-		consumer.setConsumerSalt(RandomStringUtils.random(32, 'a'));
-		Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-		Mockito.when(iGraphLockOperation.lockComponent(anyString(), any(NodeTypeEnum.class)))
-				.thenReturn(StorageOperationStatus.GENERAL_ERROR);
-		assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
-	}
+    @Test
+    void testCreateConsumer_givenValidUserAndConsumer_thenReturnsConsumer() {
+        ConsumerDataDefinition consumerDataDefinition = new ConsumerDataDefinition();
+        consumerDataDefinition.setConsumerName("_marvel");
+        consumerDataDefinition.setConsumerPassword(RandomStringUtils.random(64, true, true));
+        consumerDataDefinition.setConsumerSalt(RandomStringUtils.random(32, 'a'));
+        ConsumerDefinition consumer = new ConsumerDefinition(consumerDataDefinition);
+        Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+        Mockito.when(iGraphLockOperation.lockComponent(anyString(), any(NodeTypeEnum.class)))
+            .thenReturn(StorageOperationStatus.OK);
+        Mockito.when(consumerOperation.getCredentials(anyString()))
+            .thenReturn(Either.right(StorageOperationStatus.OK));
+        Mockito.when(consumerOperation.createCredentials(any(ConsumerData.class)))
+            .thenReturn(Either.left(new ConsumerData(consumerDataDefinition)));
+        assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isLeft());
+    }
 
-	@Test
-	public void testCreateConsumer_givenUnableToCreateCredentials_thenReturnsError() {
-		ConsumerDataDefinition consumerDataDefinition = new ConsumerDataDefinition();
-		consumerDataDefinition.setConsumerName("_marvel");
-		consumerDataDefinition.setConsumerPassword(RandomStringUtils.random(64, true,true));
-		consumerDataDefinition.setConsumerSalt(RandomStringUtils.random(32, 'a'));
-		ConsumerDefinition consumer = new ConsumerDefinition(consumerDataDefinition);
-		Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-		Mockito.when(iGraphLockOperation.lockComponent(anyString(), any(NodeTypeEnum.class)))
-				.thenReturn(StorageOperationStatus.OK);
-		Mockito.when(consumerOperation.getCredentials(anyString()))
-				.thenReturn(Either.right(StorageOperationStatus.OK));
-		Mockito.when(consumerOperation.createCredentials(any(ConsumerData.class)))
-				.thenReturn(Either.right(StorageOperationStatus.USER_NOT_FOUND));
-		assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isRight());
-	}
+    @Test
+    void testGetConsumer_givenNullUser_thenReturnsError() {
+        Mockito.when(consumerOperation.getCredentials("marvel123"))
+            .thenReturn(Either.right(StorageOperationStatus.USER_NOT_FOUND));
+        assertTrue(consumerBusinessLogic.getConsumer("marvel123", null).isRight());
+    }
 
-	@Test
-	public void testCreateConsumer_givenValidUserAndConsumer_thenReturnsConsumer() {
-		ConsumerDataDefinition consumerDataDefinition = new ConsumerDataDefinition();
-		consumerDataDefinition.setConsumerName("_marvel");
-		consumerDataDefinition.setConsumerPassword(RandomStringUtils.random(64, true,true));
-		consumerDataDefinition.setConsumerSalt(RandomStringUtils.random(32, 'a'));
-		ConsumerDefinition consumer = new ConsumerDefinition(consumerDataDefinition);
-		Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-		Mockito.when(iGraphLockOperation.lockComponent(anyString(), any(NodeTypeEnum.class)))
-				.thenReturn(StorageOperationStatus.OK);
-		Mockito.when(consumerOperation.getCredentials(anyString()))
-				.thenReturn(Either.right(StorageOperationStatus.OK));
-		Mockito.when(consumerOperation.createCredentials(any(ConsumerData.class)))
-				.thenReturn(Either.left(new ConsumerData(consumerDataDefinition)));
-		assertTrue(consumerBusinessLogic.createConsumer(user, consumer).isLeft());
-	}
+    @Test
+    void testGetConsumer_givenValidUserAndConsumerId_thenReturnsConsumer() {
+        Mockito.when(consumerOperation.getCredentials("marvel123"))
+            .thenReturn(Either.left(new ConsumerData()));
+        Mockito.when(consumerData.getConsumerDataDefinition())
+            .thenReturn(consumerDataDefinition);
+        Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+        assertTrue(consumerBusinessLogic.getConsumer("marvel123", user).isLeft());
+    }
 
-	@Test
-	public void testGetConsumer_givenNullUser_thenReturnsError() {
-		Mockito.when(consumerOperation.getCredentials("marvel123"))
-				.thenReturn(Either.right(StorageOperationStatus.USER_NOT_FOUND));
-		assertTrue(consumerBusinessLogic.getConsumer("marvel123", null).isRight());
-	}
+    @Test
+    void testUpdateConsumer_givenValidConsumer_thenReturnsUpdatedConsumer() {
+        ConsumerDefinition updatedConsumer = new ConsumerDefinition(consumerDataDefinition);
+        updatedConsumer.setConsumerName("marvel2");
+        ConsumerDataDefinition updatedConsumerDataDef = new ConsumerDataDefinition();
+        updatedConsumerDataDef.setConsumerName("marvel2");
+        ConsumerData consumerData = new ConsumerData(updatedConsumerDataDef);
+        Mockito.when(consumerOperation.updateCredentials(any(ConsumerData.class)))
+            .thenReturn(Either.left(consumerData));
+        assertEquals(updatedConsumer.getConsumerName(), consumerBusinessLogic.updateConsumer(consumer).left().value().getConsumerName());
+    }
 
-	@Test
-	public void testGetConsumer_givenValidUserAndConsumerId_thenReturnsConsumer() {
-		Mockito.when(consumerOperation.getCredentials("marvel123"))
-				.thenReturn(Either.left(new ConsumerData()));
-		Mockito.when(consumerData.getConsumerDataDefinition())
-				.thenReturn(consumerDataDefinition);
-		Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-		assertTrue(consumerBusinessLogic.getConsumer("marvel123", user).isLeft());
-	}
+    @Test
+    void testUpdateConsumer_givenUpdateFailure_thenReturnsError() {
+        Mockito.when(consumerOperation.updateCredentials(any(ConsumerData.class)))
+            .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+        assertTrue(consumerBusinessLogic.updateConsumer(consumer).isRight());
+    }
 
-	@Test
-	public void testUpdateConsumer_givenValidConsumer_thenReturnsUpdatedConsumer() {
-		ConsumerDefinition updatedConsumer = new ConsumerDefinition(consumerDataDefinition);
-		updatedConsumer.setConsumerName("marvel2");
-		ConsumerDataDefinition updatedConsumerDataDef = new ConsumerDataDefinition();
-		updatedConsumerDataDef.setConsumerName("marvel2");
-		ConsumerData consumerData = new ConsumerData(updatedConsumerDataDef);
-		Mockito.when(consumerOperation.updateCredentials(any(ConsumerData.class)))
-				.thenReturn(Either.left(consumerData));
-		assertEquals(updatedConsumer.getConsumerName(), consumerBusinessLogic.updateConsumer(consumer).left().value().getConsumerName());
-	}
+    @Test
+    void testDeleteConsumer_givenValidUserAndConsumerId_thenReturnsSuccessful() {
+        ConsumerData consumerData = new ConsumerData(new ConsumerDataDefinition());
+        Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+        Mockito.when(consumerOperation.deleteCredentials("marvel123"))
+            .thenReturn(Either.left(consumerData));
+        assertTrue(consumerBusinessLogic.deleteConsumer("marvel123", user).isLeft());
+    }
 
-	@Test
-	public void testUpdateConsumer_givenUpdateFailure_thenReturnsError() {
-		Mockito.when(consumerOperation.updateCredentials(any(ConsumerData.class)))
-				.thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
-		assertTrue(consumerBusinessLogic.updateConsumer(consumer).isRight());
-	}
-
-	@Test
-	public void testDeleteConsumer_givenValidUserAndConsumerId_thenReturnsSuccessful() {
-		ConsumerData consumerData = new ConsumerData(new ConsumerDataDefinition());
-		Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-		Mockito.when(consumerOperation.deleteCredentials("marvel123"))
-				.thenReturn(Either.left(consumerData));
-		assertTrue(consumerBusinessLogic.deleteConsumer("marvel123", user).isLeft());
-	}
-
-	@Test
-	public void testDeleteConsumer_givenInvalidUser_thenReturnsError() {
-		Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
-		Mockito.when(consumerOperation.deleteCredentials("marvel123"))
-				.thenReturn(Either.right(StorageOperationStatus.USER_NOT_FOUND));
-		assertTrue(consumerBusinessLogic.deleteConsumer("marvel123", user).isRight());
-	}
-}
\ No newline at end of file
+    @Test
+    void testDeleteConsumer_givenInvalidUser_thenReturnsError() {
+        Mockito.when(UserBusinessLogic.getUser(user.getUserId(), false)).thenReturn(user);
+        Mockito.when(consumerOperation.deleteCredentials("marvel123"))
+            .thenReturn(Either.right(StorageOperationStatus.USER_NOT_FOUND));
+        assertTrue(consumerBusinessLogic.deleteConsumer("marvel123", user).isRight());
+    }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
index cd0b1c9..ebc5702 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogicTest.java
@@ -29,14 +29,30 @@
  */
 package org.openecomp.sdc.be.components.impl;
 
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import org.junit.Assert;
-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.openecomp.sdc.be.components.impl.exceptions.ComponentException;
 import org.openecomp.sdc.be.components.impl.policy.PolicyTargetsUpdateHandler;
 import org.openecomp.sdc.be.components.validation.AccessValidations;
@@ -70,29 +86,14 @@
 import org.openecomp.sdc.common.impl.FSConfigurationSource;
 import org.openecomp.sdc.exception.ResponseFormat;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+@ExtendWith(MockitoExtension.class)
+class GroupBusinessLogicTest {
 
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.anyObject;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.when;
-
-
-@RunWith(MockitoJUnitRunner.class)
-public class GroupBusinessLogicTest {
-
+    static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+        "src/test/resources/config/catalog-be");
+    static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
     @InjectMocks
     private GroupBusinessLogic test;
-
     @Mock
     private ApplicationDataTypeCache dataTypeCache;
     @Mock
@@ -110,13 +111,9 @@
     @Mock
     private JanusGraphDao janusGraphDao;
     @Mock
-    PolicyTargetsUpdateHandler policyTargetsUpdateHandler;
+    private PolicyTargetsUpdateHandler policyTargetsUpdateHandler;
 
-    static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
-            "src/test/resources/config/catalog-be");
-    static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
-
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         test.setDataTypeCache(dataTypeCache);
         test.setToscaOperationFacade(toscaOperationFacade);
@@ -126,7 +123,7 @@
     }
 
     @Test
-    public void testCreateGroups_NoDataType() {
+    void testCreateGroups_NoDataType() {
         Either<List<GroupDefinition>, ResponseFormat> result;
         Component component = new Resource();
         List<GroupDefinition> groupDefinitions = new ArrayList<>();
@@ -138,7 +135,7 @@
     }
 
     @Test
-    public void testCreateGroups() {
+    void testCreateGroups() {
         Either<List<GroupDefinition>, ResponseFormat> result;
         Component component = new Resource();
         component.setUniqueId("id");
@@ -158,7 +155,7 @@
     }
 
     @Test
-    public void testValidUpdateVfGrpNameOnGraph() {
+    void testValidUpdateVfGrpNameOnGraph() {
         Either<List<GroupDefinition>, ResponseFormat> result;
         Component component = new Resource();
         component.setSystemName("name");
@@ -175,7 +172,7 @@
     }
 
     @Test
-    public void testValidAndUpdateGrpInstancePropValues_fail() {
+    void testValidAndUpdateGrpInstancePropValues_fail() {
         Either<GroupInstance, ResponseFormat> result;
         String componentId = "id";
         String instanceId = "id";
@@ -186,13 +183,13 @@
         oldGroupInstance.setProperties(properties);
         try {
             result = test.validateAndUpdateGroupInstancePropertyValues(componentId, instanceId, oldGroupInstance, newProperties);
-        }catch (ComponentException e){
+        } catch (ComponentException e) {
             assertThat(e.getActionStatus()).isEqualTo(ActionStatus.GENERAL_ERROR);
         }
     }
 
     @Test
-    public void testCreateGroup() {
+    void testCreateGroup() {
         GroupDefinition result;
         String componentId = "id";
         String grpType = "grpType";
@@ -214,7 +211,7 @@
         configurationManager.getConfiguration().setExcludedGroupTypesMapping(excludedGroupTypesMap);
 
         List<PropertyDefinition> properties = asList(
-                buildProperty("network_collection_type", "l3-network", "network collection type, defined with default value"));
+            buildProperty("network_collection_type", "l3-network", "network collection type, defined with default value"));
         groupTypeDefinition.setProperties(properties);
         when(groupTypeOperation.getLatestGroupTypeByType(grpType, false)).thenReturn(Either.left(groupTypeDefinition));
         when(toscaOperationFacade.canAddGroups(componentId)).thenReturn(true);
@@ -238,9 +235,9 @@
     }
 
     @Test
-    public void testUpdateGroup() throws Exception {
+    void testUpdateGroup() throws Exception {
 
-        Component component= new Resource();
+        Component component = new Resource();
         GroupDefinition updatedGroup = new GroupDefinition();
         List<GroupDefinition> grpdefList = new ArrayList<>();
         updatedGroup.setName("GRP.01");
@@ -251,15 +248,14 @@
         when(accessValidations.validateUserCanWorkOnComponent("compid", ComponentTypeEnum.SERVICE, "USR01", "UpdateGroup")).thenReturn(component);
         when(groupsOperation.updateGroup(component, updatedGroup)).thenReturn(Either.left(updatedGroup));
         GroupDefinition Gdefinition = test.updateGroup("compid", ComponentTypeEnum.SERVICE, "GRP.01",
-                "USR01", updatedGroup);
-        Assert.assertEquals(Gdefinition,updatedGroup);
+            "USR01", updatedGroup);
+        Assert.assertEquals(Gdefinition, updatedGroup);
     }
 
+    @Test
+    void testUpdateGroup_Invalidname() throws Exception {
 
-    @Test(expected = ComponentException.class)
-    public void testUpdateGroup_Invalidname() throws Exception {
-
-        Component component= new Resource();
+        Component component = new Resource();
         GroupDefinition updatedGroup = new GroupDefinition();
         List<GroupDefinition> grpdefList = new ArrayList<>();
         updatedGroup.setName("GRP~01");
@@ -268,15 +264,16 @@
         component.setUniqueId("GRP.01");
         component.setGroups(grpdefList);
         when(accessValidations.validateUserCanWorkOnComponent("compid", ComponentTypeEnum.SERVICE, "USR01", "UpdateGroup")).thenReturn(component);
-        GroupDefinition Gdefinition = test.updateGroup("compid", ComponentTypeEnum.SERVICE, "GRP.01",
+        assertThrows(ComponentException.class, () -> {
+            GroupDefinition Gdefinition = test.updateGroup("compid", ComponentTypeEnum.SERVICE, "GRP.01",
                 "USR01", updatedGroup);
-
+        });
     }
 
-    @Test(expected = ComponentException.class)
-    public void testDeleteGroup_exception() throws Exception {
+    @Test
+    void testDeleteGroup_exception() throws Exception {
 
-        Component component= new Resource();
+        Component component = new Resource();
         GroupDefinition updatedGroup = new GroupDefinition();
         List<GroupDefinition> grpdefList = new ArrayList<>();
         updatedGroup.setName("GRP~01");
@@ -285,17 +282,19 @@
         component.setUniqueId("GRP.01");
         component.setGroups(grpdefList);
         when(accessValidations.validateUserCanWorkOnComponent("compid", ComponentTypeEnum.SERVICE, "USR01", "DeleteGroup")).thenReturn(component);
-        when(groupsOperation.deleteGroups(anyObject(),anyList())).thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
+        when(groupsOperation.deleteGroups(anyObject(), anyList())).thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
 
         when(janusGraphDao.rollback()).thenReturn(JanusGraphOperationStatus.OK);
-        GroupDefinition Gdefinition = test.deleteGroup("compid", ComponentTypeEnum.SERVICE, "GRP.01",
+        assertThrows(ComponentException.class, () -> {
+            GroupDefinition Gdefinition = test.deleteGroup("compid", ComponentTypeEnum.SERVICE, "GRP.01",
                 "USR01");
+        });
     }
 
     @Test
-    public void testDeleteGroup(){
+    void testDeleteGroup() {
 
-        Component component= new Resource();
+        Component component = new Resource();
         List<GroupDefinition> groupDefList = new ArrayList<>();
         GroupDefinition updatedGroup = new GroupDefinition();
         updatedGroup.setName("GRP~01");
@@ -306,12 +305,12 @@
         List<GroupDefinition> groupDefListCopy = new ArrayList<>();
         groupDefListCopy.add(updatedGroup);
         when(accessValidations.validateUserCanWorkOnComponent("compid", ComponentTypeEnum.SERVICE, "USR01", "DeleteGroup")).thenReturn(component);
-        when(groupsOperation.deleteGroups(anyObject(),anyList())).thenReturn(Either.left(groupDefListCopy));
+        when(groupsOperation.deleteGroups(anyObject(), anyList())).thenReturn(Either.left(groupDefListCopy));
         when(groupsOperation.deleteCalculatedCapabilitiesWithProperties(anyString(), anyObject())).thenReturn(StorageOperationStatus.OK);
-        when(policyTargetsUpdateHandler.removePoliciesTargets(anyObject(),anyString(),anyObject())).thenReturn(ActionStatus.OK);
+        when(policyTargetsUpdateHandler.removePoliciesTargets(anyObject(), anyString(), anyObject())).thenReturn(ActionStatus.OK);
 
         GroupDefinition Gdefinition = test.deleteGroup("compid", ComponentTypeEnum.SERVICE, "GRP.01",
-                "USR01");
-        Assert.assertEquals(Gdefinition,updatedGroup);
+            "USR01");
+        Assert.assertEquals(Gdefinition, updatedGroup);
     }
 }
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java
index c8dde95..eedd44d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstancePropsAndInputsMergeTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,9 +20,19 @@
 
 package org.openecomp.sdc.be.components.merge.instance;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
-import org.junit.Before;
-import org.junit.Test;
+import java.util.List;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
@@ -48,16 +58,7 @@
 import org.openecomp.sdc.common.impl.FSConfigurationSource;
 import org.openecomp.sdc.exception.ResponseFormat;
 
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-public class ComponentInstancePropsAndInputsMergeTest {
+class ComponentInstancePropsAndInputsMergeTest {
 
     private static final String INSTANCE_ID1 = "inst1";
     private static final User USER = new User();
@@ -84,16 +85,16 @@
 
     private DataForMergeHolder oldDataHolder;
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        resourceToUpdate =  new ResourceBuilder().addInstanceInput(INSTANCE_ID1, "instInput1")
-                .addInstanceInput(INSTANCE_ID1, "instInput2")
-                .addInstanceProperty(INSTANCE_ID1, "instProp1")
-                .addInstanceProperty(INSTANCE_ID1, "instProp2")
-                .addInput("input1")
-                .addInput("input2")
-                .setUniqueId("resourceId").build();
+        resourceToUpdate = new ResourceBuilder().addInstanceInput(INSTANCE_ID1, "instInput1")
+            .addInstanceInput(INSTANCE_ID1, "instInput2")
+            .addInstanceProperty(INSTANCE_ID1, "instProp1")
+            .addInstanceProperty(INSTANCE_ID1, "instProp2")
+            .addInput("input1")
+            .addInput("input2")
+            .setUniqueId("resourceId").build();
 
         List<InputDefinition> oldInputs = ObjectGenerator.buildInputs("input1");
         List<ComponentInstanceProperty> oldInstProps = ObjectGenerator.buildInstanceProperties("instProp1", "instProp3");
@@ -107,7 +108,7 @@
     }
 
     @Test
-    public void mergeDataAfterCreate() throws Exception {
+    void mergeDataAfterCreate() {
         List<InputDefinition> oldInputs = ObjectGenerator.buildInputs("input1");
         List<ComponentInstanceProperty> oldInstProps = ObjectGenerator.buildInstanceProperties("instProp1", "instProp3");
         List<ComponentInstanceInput> oldInstInputs = ObjectGenerator.buildInstanceInputs("instInput1", "instInput3");
@@ -121,46 +122,66 @@
 
         ArgumentCaptor<ComponentParametersView> parametersViewCaptor = ArgumentCaptor.forClass(ComponentParametersView.class);
 
-        when(toscaOperationFacade.getToscaElement(Mockito.eq("resourceId"), parametersViewCaptor.capture())).thenReturn(Either.left(resourceToUpdate));
-        when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(oldInstInputs, oldInputs, resourceToUpdate, INSTANCE_ID1)).thenReturn(ActionStatus.OK);
-        when(componentInstancePropertiesMergeBL.mergeComponentInstanceProperties(oldInstProps, oldInputs, resourceToUpdate, INSTANCE_ID1)).thenReturn(ActionStatus.OK);
-        when(componentInstanceInputsRedeclareHandler.redeclareComponentInputsForInstance(resourceToUpdate, INSTANCE_ID1, currInstanceOriginType, oldInputs)).thenReturn(ActionStatus.OK);
+        when(toscaOperationFacade.getToscaElement(Mockito.eq("resourceId"), parametersViewCaptor.capture()))
+            .thenReturn(Either.left(resourceToUpdate));
+        when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(oldInstInputs, oldInputs, resourceToUpdate, INSTANCE_ID1))
+            .thenReturn(ActionStatus.OK);
+        when(componentInstancePropertiesMergeBL.mergeComponentInstanceProperties(oldInstProps, oldInputs, resourceToUpdate, INSTANCE_ID1))
+            .thenReturn(ActionStatus.OK);
+        when(componentInstanceInputsRedeclareHandler
+            .redeclareComponentInputsForInstance(resourceToUpdate, INSTANCE_ID1, currInstanceOriginType, oldInputs)).thenReturn(ActionStatus.OK);
         Component mergeResult = testInstance.mergeDataAfterCreate(USER, dataForMergeHolder, resourceToUpdate, INSTANCE_ID1);
         assertEquals(mergeResult, resourceToUpdate);
         assertComponentFilter(parametersViewCaptor.getValue());
     }
 
-    @Test(expected = ComponentException.class)
-    public void mergeDataAfterCreate_failedToMergeComponentInstanceInputs() throws Exception {
-        ResponseFormat errorResponse = new ResponseFormat();
+    @Test
+    void mergeDataAfterCreate_failedToMergeComponentInstanceInputs() {
+        final ResponseFormat errorResponse = new ResponseFormat();
         when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(errorResponse);
-        when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(anyList(), anyList(), any(Component.class), anyString())).thenReturn(ActionStatus.GENERAL_ERROR);
-        testInstance.mergeDataAfterCreate(USER, new DataForMergeHolder(), new Service(), "inst1");
+        when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(anyList(), anyList(), any(Component.class), anyString()))
+            .thenReturn(ActionStatus.GENERAL_ERROR);
+        final DataForMergeHolder dataHolder = new DataForMergeHolder();
+        final Service service = new Service();
+        assertThrows(ComponentException.class, () -> {
+            testInstance.mergeDataAfterCreate(USER, dataHolder, service, "inst1");
+        });
         verifyZeroInteractions(componentInstanceInputsRedeclareHandler, componentInstancePropertiesMergeBL, toscaOperationFacade);
     }
 
-    @Test(expected = ComponentException.class)
-    public void mergeDataAfterCreate_failedToMergeComponentInstProps() throws Exception {
-        ResponseFormat errorResponse = new ResponseFormat();
-        when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(anyList(), anyList(), any(Component.class), anyString())).thenReturn(ActionStatus.OK);
-        when(componentInstancePropertiesMergeBL.mergeComponentInstanceProperties(anyList(), anyList(), any(Component.class), anyString())).thenReturn(ActionStatus.GENERAL_ERROR);
+    @Test
+    void mergeDataAfterCreate_failedToMergeComponentInstProps() {
+        final ResponseFormat errorResponse = new ResponseFormat();
+        when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(anyList(), anyList(), any(Component.class), anyString()))
+            .thenReturn(ActionStatus.OK);
+        when(componentInstancePropertiesMergeBL.mergeComponentInstanceProperties(anyList(), anyList(), any(Component.class), anyString()))
+            .thenReturn(ActionStatus.GENERAL_ERROR);
         when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(errorResponse);
-        testInstance.mergeDataAfterCreate(USER, new DataForMergeHolder(), new Service(), "inst1");
+        final DataForMergeHolder dataHolder = new DataForMergeHolder();
+        final Service service = new Service();
+        assertThrows(ComponentException.class, () -> {
+            testInstance.mergeDataAfterCreate(USER, dataHolder, service, "inst1");
+        });
         verifyZeroInteractions(componentInstanceInputsRedeclareHandler, toscaOperationFacade);
     }
 
-
-    @Test(expected = ComponentException.class)
-    public void mergeDataAfterCreate_mergeInputs_FailedToFetchResource() throws Exception {
-        ResponseFormat errorResponse = new ResponseFormat();
-        when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(anyList(), anyList(), any(Component.class), anyString())).thenReturn(ActionStatus.OK);
-        when(componentInstancePropertiesMergeBL.mergeComponentInstanceProperties(anyList(), anyList(), any(Component.class), anyString())).thenReturn(ActionStatus.OK);
-        when(toscaOperationFacade.getToscaElement(any(), any(ComponentParametersView.class))).thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
+    @Test
+    void mergeDataAfterCreate_mergeInputs_FailedToFetchResource() {
+        final ResponseFormat errorResponse = new ResponseFormat();
+        when(componentInstanceInputsMergeBL.mergeComponentInstanceInputs(anyList(), anyList(), any(Component.class), anyString()))
+            .thenReturn(ActionStatus.OK);
+        when(componentInstancePropertiesMergeBL.mergeComponentInstanceProperties(anyList(), anyList(), any(Component.class), anyString()))
+            .thenReturn(ActionStatus.OK);
+        when(toscaOperationFacade.getToscaElement(any(), any(ComponentParametersView.class)))
+            .thenReturn(Either.right(StorageOperationStatus.GENERAL_ERROR));
         when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.GENERAL_ERROR)).thenReturn(ActionStatus.GENERAL_ERROR);
         when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(errorResponse);
-        DataForMergeHolder dataHolder = new DataForMergeHolder();
+        final DataForMergeHolder dataHolder = new DataForMergeHolder();
         dataHolder.setOrigComponentInputs(ObjectGenerator.buildInputs("input1", "input2"));
-        testInstance.mergeDataAfterCreate(USER, dataHolder, new Service(), "inst1");
+        final Service service = new Service();
+        assertThrows(ComponentException.class, () -> {
+            testInstance.mergeDataAfterCreate(USER, dataHolder, service, "inst1");
+        });
         verifyZeroInteractions(componentInstanceInputsRedeclareHandler);
     }
 
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java
index 40341be..40dd38a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServletTest.java
@@ -30,8 +30,19 @@
 
 package org.openecomp.sdc.be.externalapi.servlet;
 
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
 
 import fj.data.Either;
+import java.util.Arrays;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.apache.http.HttpStatus;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
 import org.glassfish.jersey.server.ResourceConfig;
@@ -39,11 +50,19 @@
 import org.glassfish.jersey.test.TestProperties;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
 import org.mockito.Mockito;
 import org.mockito.stubbing.Answer;
-import org.openecomp.sdc.be.components.impl.*;
+import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ElementBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ResourceImportManager;
+import org.openecomp.sdc.be.components.impl.ServiceBusinessLogic;
 import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
 import org.openecomp.sdc.be.config.ConfigurationManager;
 import org.openecomp.sdc.be.config.SpringConfig;
@@ -68,48 +87,31 @@
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.Arrays;
-import java.util.List;
+@TestInstance(Lifecycle.PER_CLASS)
+class AbstractTemplateServletTest extends JerseyTest {
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.when;
+    private final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+    private final HttpSession session = Mockito.mock(HttpSession.class);
+    private final ServletContext servletContext = Mockito.mock(ServletContext.class);
+    private final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
+    private final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
+    private final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
+    private final ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
+    private final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
+    private final ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
+    private final ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
+    private final ElementBusinessLogic elementBusinessLogic = Mockito.mock(ElementBusinessLogic.class);
+    private final Resource resource = Mockito.mock(Resource.class);
+    private final CategoryDefinition categoryDefinition = Mockito.mock(CategoryDefinition.class);
+    private final SubCategoryDefinition subCategoryDefinition = Mockito.mock(SubCategoryDefinition.class);
+    private final AssetMetadataConverter assetMetadataConverter = Mockito.mock(AssetMetadataConverter.class);
+    private final ResourceAssetMetadata resourceAssetMetadata = new ResourceAssetMetadata();
+    private final LifecycleBusinessLogic lifecycleBusinessLogic = Mockito.mock(LifecycleBusinessLogic.class);
+    private final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
+    private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
 
-public class AbstractTemplateServletTest extends JerseyTest {
-
-    private static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-    private static final HttpSession session = Mockito.mock(HttpSession.class);
-    private static final ServletContext servletContext = Mockito.mock(ServletContext.class);
-    private static final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
-    private static final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
-    private static final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
-    private static final ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
-    private static final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
-    private static final ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
-    private static final ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
-    private static final ElementBusinessLogic elementBusinessLogic = Mockito.mock(ElementBusinessLogic.class);
-    private static final Resource resource = Mockito.mock(Resource.class);
-    private static final CategoryDefinition categoryDefinition = Mockito.mock(CategoryDefinition.class);
-    private static final SubCategoryDefinition subCategoryDefinition = Mockito.mock(SubCategoryDefinition.class);
-    private static final AssetMetadataConverter assetMetadataConverter = Mockito.mock(AssetMetadataConverter.class);
-    private static final ResourceAssetMetadata resourceAssetMetadata = new ResourceAssetMetadata();
-    private static final LifecycleBusinessLogic lifecycleBusinessLogic = Mockito.mock(LifecycleBusinessLogic.class);
-    private static final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
-    private static final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
-    private static String serviceVertexUuid;
-
-
-    @BeforeClass
-    public static void setup() {
+    @BeforeAll
+    public void setup() {
         ExternalConfiguration.setAppName("catalog-be");
         when(request.getSession()).thenReturn(session);
         when(request.getHeader(Constants.X_ECOMP_INSTANCE_ID_HEADER)).thenReturn("mockXEcompInstanceId");
@@ -117,7 +119,8 @@
         when(request.getRequestURL()).thenReturn(new StringBuffer("sdc/v1/catalog/abstract"));
 
         when(session.getServletContext()).thenReturn(servletContext);
-        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+            .thenReturn(webAppContextWrapper);
         when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
 
         when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
@@ -129,23 +132,31 @@
         when(resource.getName()).thenReturn("MockVFCMT");
         when(resource.getSystemName()).thenReturn("mockvfcmt");
         Either<Resource, ResponseFormat> eitherRet = Either.left(resource);
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(Mockito.any(), Mockito.any(), Mockito.eq(Resource.class), Mockito.any(), Mockito.eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherRet);
+        when(componentsUtils
+            .convertJsonToObjectUsingObjectMapper(Mockito.any(), Mockito.any(), Mockito.eq(Resource.class),
+                Mockito.any(),
+                Mockito.eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherRet);
 
         when(webApplicationContext.getBean(ResourceImportManager.class)).thenReturn(resourceImportManager);
         when(webApplicationContext.getBean(ElementBusinessLogic.class)).thenReturn(elementBusinessLogic);
         when(categoryDefinition.getName()).thenReturn("Template");
         when(subCategoryDefinition.getName()).thenReturn("Monitoring Template");
         when(categoryDefinition.getSubcategories()).thenReturn(Arrays.asList(subCategoryDefinition));
-        when(elementBusinessLogic.getAllResourceCategories()).thenReturn(Either.left(Arrays.asList(categoryDefinition)));
-        when(resourceBusinessLogic.createResource(Mockito.eq(resource), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(resource);
+        when(elementBusinessLogic.getAllResourceCategories())
+            .thenReturn(Either.left(Arrays.asList(categoryDefinition)));
+        when(resourceBusinessLogic
+            .createResource(Mockito.eq(resource), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+            .thenReturn(resource);
         when(webApplicationContext.getBean(AssetMetadataConverter.class)).thenReturn(assetMetadataConverter);
         when(request.isUserInRole(anyString())).thenReturn(true);
 
-        Mockito.doReturn(Either.left(resourceAssetMetadata)).when(assetMetadataConverter).convertToSingleAssetMetadata(Mockito.eq(resource), Mockito.anyString(),
+        Mockito.doReturn(Either.left(resourceAssetMetadata)).when(assetMetadataConverter)
+            .convertToSingleAssetMetadata(Mockito.eq(resource), Mockito.anyString(),
                 Mockito.eq(true));
 
         String appConfigDir = "src/test/abstract/config";
-        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+            appConfigDir);
         ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
 
         org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
@@ -154,49 +165,64 @@
         configurationManager.setConfiguration(configuration);
     }
 
-    private static void mockResponseFormat() {
-        when(componentsUtils.getResponseFormat(Mockito.any(ActionStatus.class), Mockito.any(String[].class))).thenAnswer((Answer<ResponseFormat>) invocation -> {
-            ResponseFormat ret;
-            final ActionStatus actionStatus = invocation.getArgument(0);
-            switch( actionStatus ){
-                case CREATED :{
-                    ret = new ResponseFormat(HttpStatus.SC_CREATED);
-                    break;
-                }
-                default :{
-                    ret = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-                    break;
-                }
-            }
-            return ret;
-        });
+    @BeforeEach
+    public void beforeEach() throws Exception {
+        super.setUp();
     }
-    @Test
-    public void createVfcmtHappyScenario() {
-        final JSONObject createRequest = buildCreateJsonRequest();
-        Response response = target().path("/v1/catalog/abstract").request(MediaType.APPLICATION_JSON).header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId").header(Constants.USER_ID_HEADER, "mockAttID")
-                .post(Entity.json(createRequest.toJSONString()), Response.class);
-        assertEquals(response.getStatus(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
 
+    @AfterEach
+    public void afterEach() throws Exception {
+        super.tearDown();
     }
+
+    private void mockResponseFormat() {
+        when(componentsUtils.getResponseFormat(Mockito.any(ActionStatus.class), Mockito.any(String[].class)))
+            .thenAnswer((Answer<ResponseFormat>) invocation -> {
+                ResponseFormat ret;
+                final ActionStatus actionStatus = invocation.getArgument(0);
+                switch (actionStatus) {
+                    case CREATED: {
+                        ret = new ResponseFormat(HttpStatus.SC_CREATED);
+                        break;
+                    }
+                    default: {
+                        ret = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+                        break;
+                    }
+                }
+                return ret;
+            });
+    }
+
+    @Test
+    void createVfcmtHappyScenario() {
+        final JSONObject createRequest = buildCreateJsonRequest();
+        Response response = target().path("/v1/catalog/abstract").request(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, "mockAttID")
+            .post(Entity.json(createRequest.toJSONString()), Response.class);
+        assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
+    }
+
     private static final String BASIC_CREATE_REQUEST = "{\r\n" +
-            "  \"name\": \"VFCMT_1\",\r\n" +
-            "  \"description\": \"VFCMT Description\",\r\n" +
-            "  \"resourceType\" : \"VFCMT\",\r\n" +
-            "  \"category\": \"Template\",\r\n" +
-            "  \"subcategory\": \"Monitoring Template\",\r\n" +
-            "  \"vendorName\" : \"DCAE\",\r\n" +
-            "  \"vendorRelease\" : \"1.0\",\r\n" +
-            "  \"tags\": [\r\n" +
-            "    \"VFCMT_1\"\r\n" +
-            "  ],\r\n" +
-            "  \"icon\" : \"defaulticon\",\r\n" +
-            "  \"contactId\": \"cs0008\"\r\n" +
-            "}";
+        "  \"name\": \"VFCMT_1\",\r\n" +
+        "  \"description\": \"VFCMT Description\",\r\n" +
+        "  \"resourceType\" : \"VFCMT\",\r\n" +
+        "  \"category\": \"Template\",\r\n" +
+        "  \"subcategory\": \"Monitoring Template\",\r\n" +
+        "  \"vendorName\" : \"DCAE\",\r\n" +
+        "  \"vendorRelease\" : \"1.0\",\r\n" +
+        "  \"tags\": [\r\n" +
+        "    \"VFCMT_1\"\r\n" +
+        "  ],\r\n" +
+        "  \"icon\" : \"defaulticon\",\r\n" +
+        "  \"contactId\": \"cs0008\"\r\n" +
+        "}";
+
     private JSONObject buildCreateJsonRequest() {
 
         JSONParser parser = new JSONParser();
-        return (JSONObject) FunctionalInterfaces.swallowException( () -> parser.parse(BASIC_CREATE_REQUEST));
+        return (JSONObject) FunctionalInterfaces.swallowException(() -> parser.parse(BASIC_CREATE_REQUEST));
 
     }
 
@@ -205,15 +231,29 @@
         ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
         forceSet(TestProperties.CONTAINER_PORT, "0");
         return new ResourceConfig()
-                .register(new CrudExternalServlet(userBusinessLogic, componentInstanceBusinessLogic,componentsUtils,servletUtils,resourceImportManager, elementBusinessLogic, assetMetadataConverter, lifecycleBusinessLogic, resourceBusinessLogic, serviceBusinessLogic))
-                .register(new AbstractBinder() {
+            .register(createMockServlet())
+            .register(new AbstractBinder() {
 
-                    @Override
-                    protected void configure() {
-                        bind(request).to(HttpServletRequest.class);
-                    }
-                })
-                .property("contextConfig", context);
+                @Override
+                protected void configure() {
+                    bind(request).to(HttpServletRequest.class);
+                }
+            })
+            .property("contextConfig", context);
     }
 
-}
\ No newline at end of file
+    private CrudExternalServlet createMockServlet() {
+        return new CrudExternalServlet(
+            userBusinessLogic,
+            componentInstanceBusinessLogic,
+            componentsUtils,
+            servletUtils,
+            resourceImportManager,
+            elementBusinessLogic,
+            assetMetadataConverter,
+            lifecycleBusinessLogic,
+            resourceBusinessLogic,
+            serviceBusinessLogic);
+    }
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
index ae8d294..a2673ea 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -21,7 +21,19 @@
 package org.openecomp.sdc.be.externalapi.servlet;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
+import java.util.Arrays;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.apache.http.HttpStatus;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
 import org.glassfish.jersey.server.ResourceConfig;
@@ -29,8 +41,10 @@
 import org.glassfish.jersey.test.TestProperties;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.mockito.stubbing.Answer;
 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
@@ -62,20 +76,7 @@
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.when;
-
-public class AssetsDataServletTest extends JerseyTest {
+class AssetsDataServletTest extends JerseyTest {
 
     private static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     private static final HttpSession session = Mockito.mock(HttpSession.class);
@@ -95,11 +96,11 @@
     private static final ResourceAssetMetadata resourceAssetMetadata = new ResourceAssetMetadata();
     private static final LifecycleBusinessLogic lifecycleBusinessLogic = Mockito.mock(LifecycleBusinessLogic.class);
     private static final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
-    private static final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
+    private static final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito
+        .mock(ComponentInstanceBusinessLogic.class);
 
 
-
-    @BeforeClass
+    @BeforeAll
     public static void setup() {
         ExternalConfiguration.setAppName("catalog-be");
         when(request.getSession()).thenReturn(session);
@@ -108,7 +109,8 @@
         when(request.getRequestURL()).thenReturn(new StringBuffer("sdc/v1/catalog/resources"));
 
         when(session.getServletContext()).thenReturn(servletContext);
-        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+            .thenReturn(webAppContextWrapper);
         when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
 
         when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
@@ -119,24 +121,31 @@
 
         when(resource.getName()).thenReturn("MockVFCMT");
         when(resource.getSystemName()).thenReturn("mockvfcmt");
-        Either<Resource, ResponseFormat>  eitherRet = Either.left(resource);
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(Mockito.any(), Mockito.any(), Mockito.eq(Resource.class), Mockito.any(), Mockito.eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherRet);
+        Either<Resource, ResponseFormat> eitherRet = Either.left(resource);
+        when(componentsUtils
+            .convertJsonToObjectUsingObjectMapper(Mockito.any(), Mockito.any(), Mockito.eq(Resource.class),
+                Mockito.any(), Mockito.eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherRet);
 
         when(webApplicationContext.getBean(ResourceImportManager.class)).thenReturn(resourceImportManager);
         when(webApplicationContext.getBean(ElementBusinessLogic.class)).thenReturn(elementBusinessLogic);
         when(categoryDefinition.getName()).thenReturn("Template");
         when(subCategoryDefinition.getName()).thenReturn("Monitoring Template");
         when(categoryDefinition.getSubcategories()).thenReturn(Arrays.asList(subCategoryDefinition));
-        when(elementBusinessLogic.getAllResourceCategories()).thenReturn(Either.left(Arrays.asList(categoryDefinition)));
-        when(resourceBusinessLogic.createResource(Mockito.eq(resource), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(resource);
+        when(elementBusinessLogic.getAllResourceCategories())
+            .thenReturn(Either.left(Arrays.asList(categoryDefinition)));
+        when(resourceBusinessLogic
+            .createResource(Mockito.eq(resource), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+            .thenReturn(resource);
         when(webApplicationContext.getBean(AssetMetadataConverter.class)).thenReturn(assetMetadataConverter);
         when(request.isUserInRole(anyString())).thenReturn(true);
 
-        Mockito.doReturn(Either.left(resourceAssetMetadata)).when(assetMetadataConverter).convertToSingleAssetMetadata(Mockito.eq(resource), Mockito.anyString(),
+        Mockito.doReturn(Either.left(resourceAssetMetadata)).when(assetMetadataConverter)
+            .convertToSingleAssetMetadata(Mockito.eq(resource), Mockito.anyString(),
                 Mockito.eq(true));
 
         String appConfigDir = "src/test/resources/config/catalog-be";
-        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+            appConfigDir);
         ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
 
         org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
@@ -145,53 +154,66 @@
         configurationManager.setConfiguration(configuration);
     }
 
-
-    private static void mockResponseFormat() {
-        when(componentsUtils.getResponseFormat(Mockito.any(ActionStatus.class), Mockito.any(String[].class))).thenAnswer((Answer<ResponseFormat>) invocation -> {
-            ResponseFormat ret;
-            final ActionStatus actionStatus = invocation.getArgument(0);
-            switch( actionStatus ){
-            case CREATED :{
-                ret = new ResponseFormat(HttpStatus.SC_CREATED);
-                break;
-            }
-            default :{
-                ret = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-                break;
-            }
-            }
-            return ret;
-        });
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
     }
 
+    @AfterEach
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    private static void mockResponseFormat() {
+        when(componentsUtils.getResponseFormat(Mockito.any(ActionStatus.class), Mockito.any(String[].class)))
+            .thenAnswer((Answer<ResponseFormat>) invocation -> {
+                ResponseFormat ret;
+                final ActionStatus actionStatus = invocation.getArgument(0);
+                switch (actionStatus) {
+                    case CREATED: {
+                        ret = new ResponseFormat(HttpStatus.SC_CREATED);
+                        break;
+                    }
+                    default: {
+                        ret = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+                        break;
+                    }
+                }
+                return ret;
+            });
+    }
 
 
     @Test
-    public void createVfcmtHappyScenario() {
+    void createVfcmtHappyScenario() {
         final JSONObject createRequest = buildCreateJsonRequest();
-        Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON).header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId").header(Constants.USER_ID_HEADER, "mockAttID")
-                .post(Entity.json(createRequest.toJSONString()), Response.class);
-        assertEquals(response.getStatus(), HttpStatus.SC_CREATED);
+        Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, "mockAttID")
+            .post(Entity.json(createRequest.toJSONString()), Response.class);
+        assertEquals(HttpStatus.SC_CREATED, response.getStatus());
 
     }
+
     private static final String BASIC_CREATE_REQUEST = "{\r\n" +
-            "  \"name\": \"VFCMT_1\",\r\n" +
-            "  \"description\": \"VFCMT Description\",\r\n" +
-            "  \"resourceType\" : \"VFCMT\",\r\n" +
-            "  \"category\": \"Template\",\r\n" +
-            "  \"subcategory\": \"Monitoring Template\",\r\n" +
-            "  \"vendorName\" : \"DCAE\",\r\n" +
-            "  \"vendorRelease\" : \"1.0\",\r\n" +
-            "  \"tags\": [\r\n" +
-            "    \"VFCMT_1\"\r\n" +
-            "  ],\r\n" +
-            "  \"icon\" : \"defaulticon\",\r\n" +
-            "  \"contactId\": \"cs0008\"\r\n" +
-            "}";
+        "  \"name\": \"VFCMT_1\",\r\n" +
+        "  \"description\": \"VFCMT Description\",\r\n" +
+        "  \"resourceType\" : \"VFCMT\",\r\n" +
+        "  \"category\": \"Template\",\r\n" +
+        "  \"subcategory\": \"Monitoring Template\",\r\n" +
+        "  \"vendorName\" : \"DCAE\",\r\n" +
+        "  \"vendorRelease\" : \"1.0\",\r\n" +
+        "  \"tags\": [\r\n" +
+        "    \"VFCMT_1\"\r\n" +
+        "  ],\r\n" +
+        "  \"icon\" : \"defaulticon\",\r\n" +
+        "  \"contactId\": \"cs0008\"\r\n" +
+        "}";
+
     private JSONObject buildCreateJsonRequest() {
 
         JSONParser parser = new JSONParser();
-        return (JSONObject) FunctionalInterfaces.swallowException( () -> parser.parse(BASIC_CREATE_REQUEST));
+        return (JSONObject) FunctionalInterfaces.swallowException(() -> parser.parse(BASIC_CREATE_REQUEST));
 
     }
 
@@ -200,14 +222,16 @@
         ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
         forceSet(TestProperties.CONTAINER_PORT, "0");
         return new ResourceConfig()
-                .register(new CrudExternalServlet(userBusinessLogic, componentInstanceBusinessLogic,componentsUtils,servletUtils,resourceImportManager, elementBusinessLogic, assetMetadataConverter, lifecycleBusinessLogic, resourceBusinessLogic, serviceBusinessLogic))
-                .register(new AbstractBinder() {
+            .register(new CrudExternalServlet(userBusinessLogic, componentInstanceBusinessLogic, componentsUtils,
+                servletUtils, resourceImportManager, elementBusinessLogic, assetMetadataConverter,
+                lifecycleBusinessLogic, resourceBusinessLogic, serviceBusinessLogic))
+            .register(new AbstractBinder() {
 
-                    @Override
-                    protected void configure() {
-                        bind(request).to(HttpServletRequest.class);
-                    }
-                })
-                .property("contextConfig", context);
+                @Override
+                protected void configure() {
+                    bind(request).to(HttpServletRequest.class);
+                }
+            })
+            .property("contextConfig", context);
     }
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefServletTest.java
index a7db4ba..22f5de6 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefServletTest.java
@@ -22,13 +22,37 @@
 
 package org.openecomp.sdc.be.externalapi.servlet;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mockito;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openecomp.sdc.be.components.impl.ComponentLocker;
 import org.openecomp.sdc.be.components.impl.ExternalRefsBusinessLogic;
 import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
@@ -82,46 +106,16 @@
 import org.springframework.http.HttpStatus;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.when;
-
-public class ExternalRefServletTest extends JerseyTest {
-
-    private static boolean setupDone = false;
-    private static String serviceVertexUuid;
-    private static String resourceVertexUuid;
-    private static final ServletContext servletContext = Mockito.mock(ServletContext.class);
-    public static final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
-    private static final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
-    private static final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
-    private static final UserBusinessLogic userAdmin = Mockito.mock(UserBusinessLogic.class);
-    private static final ComponentsUtils componentUtils = Mockito.mock(ComponentsUtils.class);
-    private static final ResponseFormat responseFormat = Mockito.mock(ResponseFormat.class);
-    private static final ResponseFormat notFoundResponseFormat = Mockito.mock(ResponseFormat.class);
-    private static final ResponseFormat badRequestResponseFormat = Mockito.mock(ResponseFormat.class);
-    private static final ToscaOperationFacade toscaOperationFacadeMock = Mockito.mock(ToscaOperationFacade.class);
-    private static final AccessValidations accessValidationsMock = Mockito.mock(AccessValidations.class);
-    private static final ComponentLocker componentLocker = Mockito.mock(ComponentLocker.class);
-    private static final HealingJanusGraphGenericDao janusGraphGenericDao = Mockito.mock(HealingJanusGraphGenericDao.class);
-    private static final IGraphLockOperation graphLockOperation = Mockito.mock(IGraphLockOperation.class);
+@TestInstance(Lifecycle.PER_CLASS)
+@ExtendWith(MockitoExtension.class)
+@Disabled("Investigate 'org.springframework.beans.factory.UnsatisfiedDependencyException: "
+    + "Error creating bean with name 'externalRefServletTest.TestSpringConfig': "
+    + "Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: "
+    + "No qualifying bean of type 'org.openecomp.sdc.be.externalapi.servlet.ExternalRefServletTest' available: expected at least 1 bean which qualifies as autowire candidate."
+    + "Dependency annotations: {}'")
+class ExternalRefServletTest extends JerseyTest {
 
     private static final String COMPONENT_ID = "ci-MyComponentName";
-
     private static final String FAKE_COMPONENT_ID = "ci-MyFAKEComponentName";
     private static final String MONITORING_OBJECT_TYPE = "monitoring";
     private static final String WORKFLOW_OBJECT_TYPE = "workflow";
@@ -134,15 +128,543 @@
     private static final String REF_5 = "ref5";
     //workflow
     private static final String REF_6 = "ref6";
+    private static boolean setupDone = false;
+    private static String serviceVertexUuid;
+    private static String resourceVertexUuid;
+    /* Users */
+    private static final User adminUser = new User("admin", "admin", "admin", "admin@email.com", Role.ADMIN.name(),
+        System.currentTimeMillis());
+    private static final User designerUser = new User("designer", "designer", "designer", "designer@email.com",
+        Role.DESIGNER.name(), System
+        .currentTimeMillis());
+    private static final User otherDesignerUser = new User("otherDesigner", "otherDesigner", "otherDesigner",
+        "otherDesigner@email.com", Role.DESIGNER
+        .name(), System.currentTimeMillis());
+    private static final User otherUser = new User("other", "other", "other", "other@email.com", Role.DESIGNER.name(),
+        System.currentTimeMillis());
+
+    @Mock
+    public WebAppContextWrapper webAppContextWrapper;
+    @Mock
+    private ServletContext servletContext;
+    @Mock
+    private WebApplicationContext webApplicationContext;
+    @Mock
+    private ServletUtils servletUtils;
+    @Mock
+    private UserBusinessLogic userAdmin;
+    @Mock
+    private ComponentsUtils componentUtils;
+    @Mock
+    private ResponseFormat responseFormat;
+    @Mock
+    private ResponseFormat notFoundResponseFormat;
+    @Mock
+    private ResponseFormat badRequestResponseFormat;
+    @Mock
+    private ToscaOperationFacade toscaOperationFacadeMock;
+    @Mock
+    private AccessValidations accessValidationsMock;
+    @Mock
+    private ComponentLocker componentLocker;
+    @Mock
+    private HealingJanusGraphGenericDao janusGraphGenericDao;
+    @Mock
+    private IGraphLockOperation graphLockOperation;
+    @Mock
+    private HttpServletRequest request;
+    @Mock
+    private ByResponseFormatComponentException ce;
+    @Mock
+    private Component resourceComponentMock;
+    @Mock
+    private Component serviceComponentMock;
+
+    @BeforeAll
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+
+        //Needed for User Authorization
+        //========================================================================================================================
+        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+            .thenReturn(webAppContextWrapper);
+        when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
+        when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
+        when(servletUtils.getUserAdmin()).thenReturn(userAdmin);
+        when(servletUtils.getComponentsUtils()).thenReturn(componentUtils);
+        when(componentUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION)).thenReturn(responseFormat);
+        when(responseFormat.getStatus()).thenReturn(HttpStatus.UNAUTHORIZED.value());
+
+        String[] params = {otherDesignerUser.getUserId()};
+        when(ce.getResponseFormat()).thenReturn(responseFormat);
+        doThrow(ce).when(accessValidationsMock)
+            .validateUserCanWorkOnComponent(any(), any(), eq(otherDesignerUser.getUserId()), any());
+        doThrow(ce).when(accessValidationsMock)
+            .validateUserCanWorkOnComponent(any(), any(), eq(otherUser.getUserId()), any());
+
+        //Needed for error configuration
+        when(notFoundResponseFormat.getStatus()).thenReturn(HttpStatus.NOT_FOUND.value());
+        when(badRequestResponseFormat.getStatus()).thenReturn(HttpStatus.BAD_REQUEST.value());
+        when(componentUtils.getResponseFormat(eq(ActionStatus.RESOURCE_NOT_FOUND), (String[]) any()))
+            .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.COMPONENT_VERSION_NOT_FOUND), (String[]) any()))
+            .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND), (String[]) any()))
+            .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.EXT_REF_NOT_FOUND), (String[]) any()))
+            .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID), (String[]) any()))
+            .thenReturn(badRequestResponseFormat);
+        when(userAdmin.getUser(adminUser.getUserId(), false)).thenReturn(adminUser);
+        when(userAdmin.getUser(designerUser.getUserId(), false)).thenReturn(designerUser);
+        when(userAdmin.getUser(otherUser.getUserId(), false)).thenReturn(otherUser);
+        //========================================================================================================================
+
+        String appConfigDir = "src/test/resources/config/catalog-be";
+        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+            appConfigDir);
+        ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+
+        org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
+        configuration.setJanusGraphInMemoryGraph(true);
+        org.openecomp.sdc.be.config.Configuration.HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new org.openecomp.sdc.be.config.Configuration.HeatDeploymentArtifactTimeout();
+        heatDeploymentArtifactTimeout.setDefaultMinutes(30);
+        configuration.setAafAuthNeeded(false);
+        configuration.setHeatArtifactDeploymentTimeout(heatDeploymentArtifactTimeout);
+        configurationManager.setConfiguration(configuration);
+        ExternalConfiguration.setAppName("catalog-be");
+    }
+
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
+
+        when(resourceComponentMock.getVersion()).thenReturn(VERSION);
+        when(resourceComponentMock.getUniqueId()).thenReturn(resourceVertexUuid);
+
+        when(serviceComponentMock.getVersion()).thenReturn(VERSION);
+        when(serviceComponentMock.getUniqueId()).thenReturn(serviceVertexUuid);
+
+        List<Component> listComponents = new LinkedList<>();
+        listComponents.add(serviceComponentMock);
+
+        when(toscaOperationFacadeMock.getComponentListByUuid(eq(serviceVertexUuid), any()))
+            .thenReturn(Either.left(listComponents));
+        when(toscaOperationFacadeMock.getComponentByUuidAndVersion(serviceVertexUuid, VERSION))
+            .thenReturn(Either.left(serviceComponentMock));
+        when(toscaOperationFacadeMock.getComponentByUuidAndVersion(resourceVertexUuid, VERSION))
+            .thenReturn(Either.left(resourceComponentMock));
+        when(toscaOperationFacadeMock.getLatestComponentByUuid(eq(serviceVertexUuid), any()))
+            .thenReturn(Either.left(listComponents.get(0)));
+        when(toscaOperationFacadeMock.getLatestComponentByUuid(eq(resourceVertexUuid), any()))
+            .thenReturn(Either.left(resourceComponentMock));
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
+
+    @Test
+    void testGetExternalRefsForExistingComponentInstance() {
+        String path = String
+            .format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid,
+                VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
+
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
+
+        List<String> dto = response.readEntity(new GenericType<List<String>>() {
+        });
+        assertThat(dto).containsExactly(REF_1, REF_2, REF_3, REF_5);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
+    }
+
+    @Test
+    void testGetExternalRefsForAsset() {
+        String path = String
+            .format("/v1/catalog/services/%s/version/%s/externalReferences/%s", serviceVertexUuid, VERSION,
+                MONITORING_OBJECT_TYPE);
+
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
+
+        Map<String, List<String>> dtoMap = response.readEntity(new GenericType<HashMap<String, List<String>>>() {
+        });
+        assertThat(dtoMap.get(COMPONENT_ID)).containsExactly(REF_1, REF_2, REF_3, REF_5);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
+    }
+
+    @Test
+    void testGetExternalRefsForAssetWithMissingEcompHeader() {
+        String path = String
+            .format("/v1/catalog/services/%s/version/%s/externalReferences/%s", serviceVertexUuid, VERSION,
+                MONITORING_OBJECT_TYPE);
+
+        //No X-Ecomp-Instance-ID header
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST.value());
+    }
+
+    @Test
+    void testAddExternalRefForResource() {
+        String path = String
+            .format("/v1/catalog/resources/%s/resourceInstances/%s/externalReferences/%s", resourceVertexUuid,
+                COMPONENT_ID, MONITORING_OBJECT_TYPE);
+        String getPath = String
+            .format("/v1/catalog/resources/%s/version/%s/externalReferences/%s", resourceVertexUuid, VERSION,
+                MONITORING_OBJECT_TYPE);
+
+        Response response = target()
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(new ExternalRefDTO(REF_1)));
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED.value());
+
+        //Check that GET will include the new reference
+        response = target()
+            .path(getPath)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, adminUser.getUserId())
+            .get();
+
+        Map<String, List<String>> dto = response.readEntity(new GenericType<Map<String, List<String>>>() {
+        });
+        assertThat(dto.get(COMPONENT_ID)).containsExactlyInAnyOrder(REF_1);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
+    }
+
+    @Test
+    void testAddExternalRefForExistingComponentInstance() {
+        String path = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid,
+                COMPONENT_ID, MONITORING_OBJECT_TYPE);
+        String getPath = String
+            .format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid,
+                VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
+        Response response = target()
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(new ExternalRefDTO(REF_4)));
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED.value());
+
+        //Check that GET will include the new reference
+        response = target()
+            .path(getPath)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, adminUser.getUserId())
+            .get();
+
+        List<String> dto = response.readEntity(new GenericType<List<String>>() {
+        });
+        assertThat(dto).containsExactlyInAnyOrder(REF_1, REF_2, REF_3, REF_4, REF_5);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
+    }
+
+    @Test
+    void testDeleteExternalRefForExistingComponentInstance() {
+        String deletePath = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid,
+                COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
+        String getPath = String
+            .format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid,
+                VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
+        Response response = target()
+            .path(deletePath)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
+
+        //Verify that the deleted reference is returned in body
+        ExternalRefDTO dto = response.readEntity(ExternalRefDTO.class);
+        assertThat(dto.getReferenceUUID()).isEqualTo(REF_5);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
+
+        //Check that GET will NOT include the deleted reference
+        response = target()
+            .path(getPath)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
+
+        List<String> getResponse = response.readEntity(new GenericType<List<String>>() {
+        });
+        assertThat(getResponse).containsExactlyInAnyOrder(REF_1, REF_2, REF_3);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
+    }
+
+    @Test
+    void testUpdateExternalRefForExistingComponentInstance() {
+        String updatePath = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid,
+                COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
+        String getPath = String
+            .format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid,
+                VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
+        Response response = target()
+            .path(updatePath)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .put(Entity.json(new ExternalRefDTO(REF_4)));
+
+        //Verify that the updated reference is returned in body
+        ExternalRefDTO putResponseBody = response.readEntity(ExternalRefDTO.class);
+        assertThat(putResponseBody.getReferenceUUID()).isEqualTo(REF_4);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
+
+        //Check that GET will include the updated reference
+        response = target()
+            .path(getPath)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
+
+        List<String> dto = response.readEntity(new GenericType<List<String>>() {
+        });
+        assertThat(dto).containsExactlyInAnyOrder(REF_1, REF_2, REF_3, REF_4);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
+    }
+
+    /*
+     * Rainy Scenarios
+     */
+    @Test
+    void testAddExternalRefForNonExistingAssetId() {
+        String path = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s", "non-existing-uuid",
+                COMPONENT_ID, MONITORING_OBJECT_TYPE);
+        Response response = target()
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(new ExternalRefDTO(REF_4)));
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
+    }
+
+    @Test
+    void testAddExternalRefForNonExistingCompInstId() {
+        String path = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid,
+                "FAKE_COM_ID", MONITORING_OBJECT_TYPE);
+        Response response = target()
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(new ExternalRefDTO(REF_4)));
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
+    }
+
+    @Test
+    void testAddExistingExternalRef() {
+        String path = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid,
+                COMPONENT_ID, MONITORING_OBJECT_TYPE);
+        Response response = target()
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(new ExternalRefDTO(REF_1)));
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); //Ref not created but still OK is returned
+    }
+
+    @Test
+    void testUpdateExternalRefForNonExistingAssetId() {
+        String updatePath = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s",
+            "nonExistingServiceVertexUuid", COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
+
+        Response response = target()
+            .path(updatePath)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .put(Entity.json(new ExternalRefDTO(REF_4)));
+
+        //Verify that the 404 is returned
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
+
+    }
+
+    @Test
+    void testUpdateExternalRefForNonExistingObjectIdOrOldRef() {
+        String updatePath = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid,
+                COMPONENT_ID, "FAKE_OBJ_TYPE", REF_5);
+
+        Response response = target()
+            .path(updatePath)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .put(Entity.json(new ExternalRefDTO(REF_4)));
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
+    }
+
+    @Test
+    void testDeleteExternalRefForNonExistingAssetId() {
+        String deletePath = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", "non-existing-asset",
+                COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
+        Response response = target()
+            .path(deletePath)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
+    }
+
+    @Test
+    void testDeleteExternalRefForNonExistingRef() {
+        String deletePath = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid,
+                COMPONENT_ID, MONITORING_OBJECT_TYPE, "FAKE_REF");
+        Response response = target()
+            .path(deletePath)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .delete();
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
+    }
+
+    @Test
+    void testGetExternalRefsForNonExistingAsset() {
+        String path = String
+            .format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", "fake-asset-id",
+                VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
+
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
+    }
+
+    @Test
+    void testGetExternalRefsForNonExistingVersion() {
+        String path = String
+            .format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid,
+                FAKE_VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
+
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
+    }
+
+    @Test
+    void testDeleteExternalRefsForExistingComponentInstanceWithUnauthorizedUser() {
+        String path = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid,
+                COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
+
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, otherUser.getUserId())
+            .delete();
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.UNAUTHORIZED.value());
+    }
+
+    @Test
+    void testDeleteExternalRefForUserWhichIsNotCurrentUpdater() {
+        String deletePath = String
+            .format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid,
+                COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
+        Response response = target()
+            .path(deletePath)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
+            .header(Constants.USER_ID_HEADER, otherDesignerUser.getUserId())
+            .delete();
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.UNAUTHORIZED.value());
+    }
+
+    @Override
+    protected Application configure() {
+        ApplicationContext context = new AnnotationConfigApplicationContext(TestSpringConfig.class);
+        return new ResourceConfig(ExternalRefsServlet.class)
+            .register(DefaultExceptionMapper.class)
+            .register(ComponentExceptionMapper.class)
+            .register(StorageExceptionMapper.class)
+            .property("contextConfig", context);
+    }
 
     @Configuration
     @PropertySource("classpath:dao.properties")
-    static class TestSpringConfig {
+    public class TestSpringConfig {
 
         private GraphVertex serviceVertex;
         private GraphVertex resourceVertex;
         private ExternalReferencesOperation externalReferenceOperation;
         private HealingJanusGraphDao janusGraphDao;
+        @Mock
+        private IdMapper idMapper;
 
         @Bean
         ExternalRefsServlet externalRefsServlet() {
@@ -150,7 +672,9 @@
         }
 
         @Bean
-        OperationUtils operationUtils() {return new OperationUtils(janusGraphDao());}
+        OperationUtils operationUtils() {
+            return new OperationUtils(janusGraphDao());
+        }
 
         @Bean
         ComponentExceptionMapper componentExceptionMapper() {
@@ -169,7 +693,8 @@
 
         @Bean
         ExternalRefsBusinessLogic externalRefsBusinessLogic() {
-            return new ExternalRefsBusinessLogic(externalReferencesOperation(), toscaOperationFacade(), accessValidations(), componentLocker());
+            return new ExternalRefsBusinessLogic(externalReferencesOperation(), toscaOperationFacade(),
+                accessValidations(), componentLocker());
         }
 
         @Bean
@@ -179,7 +704,8 @@
 
         @Bean
         ExternalReferencesOperation externalReferencesOperation() {
-            this.externalReferenceOperation = new ExternalReferencesOperation(janusGraphDao(), nodeTypeOpertaion(), topologyTemplateOperation(), idMapper());
+            this.externalReferenceOperation = new ExternalReferencesOperation(janusGraphDao(), nodeTypeOpertaion(),
+                topologyTemplateOperation(), idMapper());
             this.externalReferenceOperation.setHealingPipelineDao(healingPipelineDao());
             GraphTestUtils.clearGraph(janusGraphDao);
             initGraphForTest();
@@ -193,16 +719,17 @@
 
         @Bean
         IdMapper idMapper() {
-            IdMapper idMapper = Mockito.mock(IdMapper.class);
-            when(idMapper.mapComponentNameToUniqueId(eq(COMPONENT_ID), any(GraphVertex.class))).thenReturn(COMPONENT_ID);
-            when(idMapper.mapUniqueIdToComponentNameTo(eq(COMPONENT_ID), any(GraphVertex.class))).thenReturn(COMPONENT_ID);
+            when(idMapper.mapComponentNameToUniqueId(eq(COMPONENT_ID), any(GraphVertex.class)))
+                .thenReturn(COMPONENT_ID);
+            when(idMapper.mapUniqueIdToComponentNameTo(eq(COMPONENT_ID), any(GraphVertex.class)))
+                .thenReturn(COMPONENT_ID);
             when(idMapper.mapComponentNameToUniqueId(eq(FAKE_COMPONENT_ID), any(GraphVertex.class))).thenReturn(null);
             return idMapper;
         }
 
         @Bean
         TopologyTemplateOperation topologyTemplateOperation() {
-           return new TopologyTemplateOperation();
+            return new TopologyTemplateOperation();
         }
 
         @Bean
@@ -232,7 +759,7 @@
 
         @Bean
         HealingJanusGraphDao janusGraphDao() {
-            this.janusGraphDao = new HealingJanusGraphDao(healingPipelineDao(),janusGraphClient());
+            this.janusGraphDao = new HealingJanusGraphDao(healingPipelineDao(), janusGraphClient());
             return janusGraphDao;
         }
 
@@ -263,7 +790,7 @@
 
         @Bean("healingPipelineDao")
         HealingPipelineDao healingPipelineDao() {
-            HealingPipelineDao healingPipelineDao = new HealingPipelineDao() ;
+            HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
             healingPipelineDao.setHealVersion(1);
             healingPipelineDao.initHealVersion();
             return healingPipelineDao;
@@ -277,7 +804,8 @@
         private void initGraphForTest() {
             if (!setupDone) {
 
-                resourceVertex = GraphTestUtils.createResourceVertex(janusGraphDao, new HashMap<>(), ResourceTypeEnum.VF);
+                resourceVertex = GraphTestUtils
+                    .createResourceVertex(janusGraphDao, new HashMap<>(), ResourceTypeEnum.VF);
                 resourceVertexUuid = resourceVertex.getUniqueId();
 
                 //create a service and add ref
@@ -285,13 +813,18 @@
                 serviceVertexUuid = this.serviceVertex.getUniqueId();
 
                 //monitoring references
-                externalReferenceOperation.addExternalReference(serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_1);
-                externalReferenceOperation.addExternalReference(serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_2);
-                externalReferenceOperation.addExternalReference(serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_3);
-                externalReferenceOperation.addExternalReference(serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
+                externalReferenceOperation
+                    .addExternalReference(serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_1);
+                externalReferenceOperation
+                    .addExternalReference(serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_2);
+                externalReferenceOperation
+                    .addExternalReference(serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_3);
+                externalReferenceOperation
+                    .addExternalReference(serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
 
                 //workflow references
-                externalReferenceOperation.addExternalReference(serviceVertexUuid, COMPONENT_ID, WORKFLOW_OBJECT_TYPE, REF_6);
+                externalReferenceOperation
+                    .addExternalReference(serviceVertexUuid, COMPONENT_ID, WORKFLOW_OBJECT_TYPE, REF_6);
 
                 final JanusGraphOperationStatus commit = this.janusGraphDao.commit();
                 assertThat(commit).isEqualTo(JanusGraphOperationStatus.OK);
@@ -300,432 +833,4 @@
 
 
     }
-
-    public static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-
-    /* Users */
-    private static User adminUser = new User("admin", "admin", "admin", "admin@email.com", Role.ADMIN.name(), System.currentTimeMillis());
-    private static User designerUser = new User("designer", "designer", "designer", "designer@email.com", Role.DESIGNER.name(), System
-            .currentTimeMillis());
-    private static User otherDesignerUser = new User("otherDesigner", "otherDesigner", "otherDesigner", "otherDesigner@email.com", Role.DESIGNER
-            .name(), System.currentTimeMillis());
-    private static User otherUser = new User("other", "other", "other", "other@email.com", Role.DESIGNER.name(), System.currentTimeMillis());
-
-
-    @BeforeClass
-    public static void setup() {
-
-        //Needed for User Authorization
-        //========================================================================================================================
-        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
-        when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
-        when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
-        when(servletUtils.getUserAdmin()).thenReturn(userAdmin);
-        when(servletUtils.getComponentsUtils()).thenReturn(componentUtils);
-        when(componentUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION)).thenReturn(responseFormat);
-        when(responseFormat.getStatus()).thenReturn(HttpStatus.UNAUTHORIZED.value());
-
-        ByResponseFormatComponentException ce = Mockito.mock(ByResponseFormatComponentException.class);
-        String[] params = {otherDesignerUser.getUserId()};
-        when(ce.getResponseFormat()).thenReturn(responseFormat);
-        doThrow(ce).when(accessValidationsMock)
-                .validateUserCanWorkOnComponent(any(), any(), eq(otherDesignerUser.getUserId()), any());
-        doThrow(ce).when(accessValidationsMock)
-                .validateUserCanWorkOnComponent(any(), any(), eq(otherUser.getUserId()), any());
-
-        //Needed for error configuration
-        when(notFoundResponseFormat.getStatus()).thenReturn(HttpStatus.NOT_FOUND.value());
-        when(badRequestResponseFormat.getStatus()).thenReturn(HttpStatus.BAD_REQUEST.value());
-        when(componentUtils.getResponseFormat(eq(ActionStatus.RESOURCE_NOT_FOUND), (String[]) any())).thenReturn(notFoundResponseFormat);
-        when(componentUtils.getResponseFormat(eq(ActionStatus.COMPONENT_VERSION_NOT_FOUND), (String[]) any())).thenReturn(notFoundResponseFormat);
-        when(componentUtils.getResponseFormat(eq(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND), (String[]) any())).thenReturn(notFoundResponseFormat);
-        when(componentUtils.getResponseFormat(eq(ActionStatus.EXT_REF_NOT_FOUND), (String[]) any())).thenReturn(notFoundResponseFormat);
-        when(componentUtils.getResponseFormat(eq(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID), (String[]) any())).thenReturn(badRequestResponseFormat);
-        when(userAdmin.getUser(adminUser.getUserId(), false)).thenReturn(adminUser);
-        when(userAdmin.getUser(designerUser.getUserId(), false)).thenReturn(designerUser);
-        when(userAdmin.getUser(otherUser.getUserId(), false)).thenReturn(otherUser);
-        //========================================================================================================================
-
-        String appConfigDir = "src/test/resources/config/catalog-be";
-        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
-        ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
-
-        org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
-        configuration.setJanusGraphInMemoryGraph(true);
-        org.openecomp.sdc.be.config.Configuration.HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new org.openecomp.sdc.be.config.Configuration.HeatDeploymentArtifactTimeout();
-        heatDeploymentArtifactTimeout.setDefaultMinutes(30);;
-        configuration.setHeatArtifactDeploymentTimeout(heatDeploymentArtifactTimeout);
-        configurationManager.setConfiguration(configuration);
-        ExternalConfiguration.setAppName("catalog-be");
-    }
-
-    @Before
-    public void before(){
-
-        Component resourceComponentMock = Mockito.mock(Component.class);
-        when(resourceComponentMock.getVersion()).thenReturn(VERSION);
-        when(resourceComponentMock.getUniqueId()).thenReturn(resourceVertexUuid);
-
-        Component serviceComponentMock = Mockito.mock(Component.class);
-        when(serviceComponentMock.getVersion()).thenReturn(VERSION);
-        when(serviceComponentMock.getUniqueId()).thenReturn(serviceVertexUuid);
-
-        List<Component> listComponents = new LinkedList<>();
-        listComponents.add(serviceComponentMock);
-
-        when(toscaOperationFacadeMock.getComponentListByUuid(eq(serviceVertexUuid), any())).thenReturn(Either.left(listComponents));
-        when(toscaOperationFacadeMock.getComponentByUuidAndVersion(eq(serviceVertexUuid), eq(VERSION))).thenReturn(Either.left(serviceComponentMock));
-        when(toscaOperationFacadeMock.getComponentByUuidAndVersion(eq(resourceVertexUuid), eq(VERSION))).thenReturn(Either.left(resourceComponentMock));
-        when(toscaOperationFacadeMock.getLatestComponentByUuid(eq(serviceVertexUuid), any())).thenReturn(Either.left(listComponents.get(0)));
-        when(toscaOperationFacadeMock.getLatestComponentByUuid(eq(resourceVertexUuid), any())).thenReturn(Either.left(resourceComponentMock));
-    }
-
-    @Test
-    public void testGetExternalRefsForExistingComponentInstance() {
-        String path = String.format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid, VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
-
-        Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .get();
-
-        List<String> dto = response.readEntity(new GenericType<List<String>>() {
-        });
-        assertThat(dto).containsExactly(REF_1, REF_2, REF_3, REF_5);
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
-    }
-
-    @Test
-    public void testGetExternalRefsForAsset() {
-        String path = String.format("/v1/catalog/services/%s/version/%s/externalReferences/%s", serviceVertexUuid, VERSION, MONITORING_OBJECT_TYPE);
-
-        Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .get();
-
-        Map<String, List<String>> dtoMap = response.readEntity(new GenericType<HashMap<String, List<String>>>() {
-        });
-        assertThat(dtoMap.get(COMPONENT_ID)).containsExactly(REF_1, REF_2, REF_3, REF_5);
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
-    }
-
-    @Test
-    public void testGetExternalRefsForAssetWithMissingEcompHeader() {
-        String path = String.format("/v1/catalog/services/%s/version/%s/externalReferences/%s", serviceVertexUuid, VERSION, MONITORING_OBJECT_TYPE);
-
-        //No X-Ecomp-Instance-ID header
-        Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .get();
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST.value());
-    }
-
-
-    @Test
-    public void testAddExternalRefForResource(){
-        String path = String.format("/v1/catalog/resources/%s/resourceInstances/%s/externalReferences/%s", resourceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE);
-        String getPath = String.format("/v1/catalog/resources/%s/version/%s/externalReferences/%s", resourceVertexUuid, VERSION, MONITORING_OBJECT_TYPE);
-
-        Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .post(Entity.json(new ExternalRefDTO(REF_1)));
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED.value());
-
-        //Check that GET will include the new reference
-        response = target()
-                .path(getPath)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, adminUser.getUserId())
-                .get();
-
-        Map<String, List<String>> dto = response.readEntity(new GenericType<Map<String, List<String>>>(){});
-        assertThat(dto.get(COMPONENT_ID)).containsExactlyInAnyOrder(REF_1);
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
-    }
-
-    @Test
-    public void testAddExternalRefForExistingComponentInstance() {
-        String path = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE);
-        String getPath = String.format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid, VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
-        Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .post(Entity.json(new ExternalRefDTO(REF_4)));
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED.value());
-
-        //Check that GET will include the new reference
-        response = target()
-                .path(getPath)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, adminUser.getUserId())
-                .get();
-
-        List<String> dto = response.readEntity(new GenericType<List<String>>() {
-        });
-        assertThat(dto).containsExactlyInAnyOrder(REF_1, REF_2, REF_3, REF_4, REF_5);
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
-    }
-
-    @Test
-    public void testDeleteExternalRefForExistingComponentInstance() {
-        String deletePath = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
-        String getPath = String.format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid, VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
-        Response response = target()
-                .path(deletePath)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .delete();
-
-        //Verify that the deleted reference is returned in body
-        ExternalRefDTO dto = response.readEntity(ExternalRefDTO.class);
-        assertThat(dto.getReferenceUUID()).isEqualTo(REF_5);
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
-
-        //Check that GET will NOT include the deleted reference
-        response = target()
-                .path(getPath)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .get();
-
-        List<String> getResponse = response.readEntity(new GenericType<List<String>>() {
-        });
-        assertThat(getResponse).containsExactlyInAnyOrder(REF_1, REF_2, REF_3);
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
-    }
-
-    @Test
-    public void testUpdateExternalRefForExistingComponentInstance() {
-        String updatePath = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
-        String getPath = String.format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid, VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
-        Response response = target()
-                .path(updatePath)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .put(Entity.json(new ExternalRefDTO(REF_4)));
-
-        //Verify that the updated reference is returned in body
-        ExternalRefDTO putResponseBody = response.readEntity(ExternalRefDTO.class);
-        assertThat(putResponseBody.getReferenceUUID()).isEqualTo(REF_4);
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
-
-        //Check that GET will include the updated reference
-        response = target()
-                .path(getPath)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .get();
-
-
-        List<String> dto = response.readEntity(new GenericType<List<String>>() {
-        });
-        assertThat(dto).containsExactlyInAnyOrder(REF_1, REF_2, REF_3, REF_4);
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
-    }
-
-
-    /*
-     * Rainy Scenarios
-     */
-    @Test
-    public void testAddExternalRefForNonExistingAssetId() {
-        String path = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s", "non-existing-uuid", COMPONENT_ID, MONITORING_OBJECT_TYPE);
-        Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .post(Entity.json(new ExternalRefDTO(REF_4)));
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
-    }
-
-    @Test
-    public void testAddExternalRefForNonExistingCompInstId() {
-        String path = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid, "FAKE_COM_ID", MONITORING_OBJECT_TYPE);
-        Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .post(Entity.json(new ExternalRefDTO(REF_4)));
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
-    }
-
-    @Test
-    public void testAddExistingExternalRef() {
-        String path = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE);
-        Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .post(Entity.json(new ExternalRefDTO(REF_1)));
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value()); //Ref not created but still OK is returned
-    }
-
-    @Test
-    public void testUpdateExternalRefForNonExistingAssetId() {
-        String updatePath = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", "nonExistingServiceVertexUuid", COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
-
-        Response response = target()
-                .path(updatePath)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .put(Entity.json(new ExternalRefDTO(REF_4)));
-
-        //Verify that the 404 is returned
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
-
-    }
-
-    @Test
-    public void testUpdateExternalRefForNonExistingObjectIdOrOldRef() {
-        String updatePath = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid, COMPONENT_ID, "FAKE_OBJ_TYPE", REF_5);
-
-        Response response = target()
-                .path(updatePath)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .put(Entity.json(new ExternalRefDTO(REF_4)));
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
-    }
-
-    @Test
-    public void testDeleteExternalRefForNonExistingAssetId() {
-        String deletePath = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", "non-existing-asset", COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
-        Response response = target()
-                .path(deletePath)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .delete();
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
-    }
-
-    @Test
-    public void testDeleteExternalRefForNonExistingRef() {
-        String deletePath = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, "FAKE_REF");
-        Response response = target()
-                .path(deletePath)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .delete();
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
-    }
-
-    @Test
-    public void testGetExternalRefsForNonExistingAsset() {
-        String path = String.format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", "fake-asset-id", VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
-
-        Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .get();
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
-    }
-
-    @Test
-    public void testGetExternalRefsForNonExistingVersion() {
-        String path = String.format("/v1/catalog/services/%s/version/%s/resourceInstances/%s/externalReferences/%s", serviceVertexUuid, FAKE_VERSION, COMPONENT_ID, MONITORING_OBJECT_TYPE);
-
-        Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .get();
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
-    }
-
-    @Test
-    public void testDeleteExternalRefsForExistingComponentInstanceWithUnauthorizedUser() {
-        String path = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
-
-        Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, otherUser.getUserId())
-                .delete();
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.UNAUTHORIZED.value());
-    }
-
-    @Test
-    public void testDeleteExternalRefForUserWhichIsNotCurrentUpdater() {
-        String deletePath = String.format("/v1/catalog/services/%s/resourceInstances/%s/externalReferences/%s/%s", serviceVertexUuid, COMPONENT_ID, MONITORING_OBJECT_TYPE, REF_5);
-        Response response = target()
-                .path(deletePath)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.X_ECOMP_INSTANCE_ID_HEADER, "mockXEcompInstanceId")
-                .header(Constants.USER_ID_HEADER, otherDesignerUser.getUserId())
-                .delete();
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.UNAUTHORIZED.value());
-    }
-
-    @Override
-    protected Application configure() {
-        ApplicationContext context = new AnnotationConfigApplicationContext(TestSpringConfig.class);
-        return new ResourceConfig(ExternalRefsServlet.class)
-                .register(DefaultExceptionMapper.class)
-                .register(ComponentExceptionMapper.class)
-                .register(StorageExceptionMapper.class)
-                .property("contextConfig", context);
-    }
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java
index c998318..4334b49 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ServletUtilsTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -21,45 +21,51 @@
 package org.openecomp.sdc.be.impl;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import com.google.gson.Gson;
-
-import mockit.Deencapsulation;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import com.google.gson.GsonBuilder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openecomp.sdc.be.user.UserBusinessLogic;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-@RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:application-context-test.xml"})
 public class ServletUtilsTest {
-	@Autowired
-	ServletUtils servletUtils;
 
-	@Test
-	public void testCtrServletUtils() {
-		// default test
-		assertThat(servletUtils)
-				.isNotNull()
-				.isInstanceOf(ServletUtils.class);
+    private ServletUtils servletUtils;
+    private ComponentsUtils componentsUtils;
+    private UserBusinessLogic userBusinessLogic;
+    private Gson gson;
 
-		ComponentsUtils componentsUtils = Deencapsulation.getField(servletUtils, "componentsUtils");
-		UserBusinessLogic userBusinessLogic = Deencapsulation.getField(servletUtils, "userAdmin");
-		Gson gson = Deencapsulation.getField(servletUtils, "gson");
+    @BeforeEach
+    public void setup() {
+        servletUtils = mock(ServletUtils.class);
+        userBusinessLogic = mock(UserBusinessLogic.class);
+        componentsUtils = mock(ComponentsUtils.class);
+        gson = new GsonBuilder().setPrettyPrinting().create();
+        when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
+        when(servletUtils.getGson()).thenReturn(gson);
+        when(servletUtils.getUserAdmin()).thenReturn(userBusinessLogic);
+    }
 
-		assertThat(gson)
-				.isNotNull()
-				.isInstanceOf(Gson.class)
-				.isEqualTo(servletUtils.getGson());
-		assertThat(componentsUtils)
-				.isNotNull()
-				.isInstanceOf(ComponentsUtils.class)
-				.isEqualTo(servletUtils.getComponentsUtils());
-		assertThat(userBusinessLogic)
-				.isNotNull()
-				.isInstanceOf(UserBusinessLogic.class)
-				.isEqualTo(servletUtils.getUserAdmin());
-	}
+    @Test
+    public void testCtrServletUtils() {
+        assertThat(servletUtils)
+            .isNotNull()
+            .isInstanceOf(ServletUtils.class);
+        assertThat(gson)
+            .isNotNull()
+            .isInstanceOf(Gson.class)
+            .isEqualTo(servletUtils.getGson());
+        assertThat(componentsUtils)
+            .isNotNull()
+            .isInstanceOf(ComponentsUtils.class)
+            .isEqualTo(servletUtils.getComponentsUtils());
+        assertThat(userBusinessLogic)
+            .isNotNull()
+            .isInstanceOf(UserBusinessLogic.class)
+            .isEqualTo(servletUtils.getUserAdmin());
+    }
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArchiveEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArchiveEndpointTest.java
index d879b46..4359270 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArchiveEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArchiveEndpointTest.java
@@ -22,12 +22,33 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.openecomp.sdc.be.catalog.enums.ChangeTypeEnum;
 import org.openecomp.sdc.be.components.impl.ArchiveBusinessLogic;
@@ -89,27 +110,7 @@
 import org.springframework.http.HttpStatus;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ArchiveEndpointTest extends JerseyTest {
+class ArchiveEndpointTest extends JerseyTest {
 
     private static final ServletContext servletContext = mock(ServletContext.class);
     private static final String CSAR_UUID1 = "123456789abcdefgh";
@@ -121,7 +122,7 @@
     private static final UserBusinessLogic userAdmin = mock(UserBusinessLogic.class);
     private static final ComponentsUtils componentUtils = mock(ComponentsUtils.class);
     private static final CatalogOperation catalogOperations = mock(CatalogOperation.class);
-//    private static final ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
+    //    private static final ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class);
     private static final ToscaOperationFacade toscaOperationFacade = Mockito.spy(new ToscaOperationFacade());
 
 
@@ -144,6 +145,7 @@
     @Configuration
     @PropertySource("classpath:dao.properties")
     static class TestSpringConfig {
+
         private ArchiveOperation archiveOperation;
         private GraphVertex catalogVertex;
 
@@ -171,7 +173,8 @@
 
         @Bean
         ArchiveBusinessLogic archiveBusinessLogic() {
-            return new ArchiveBusinessLogic(janusGraphDao(), accessValidations(), archiveOperation(), toscaOperationFacade(), componentUtils, catalogOperations);
+            return new ArchiveBusinessLogic(janusGraphDao(), accessValidations(), archiveOperation(),
+                toscaOperationFacade(), componentUtils, catalogOperations);
         }
 
         @Bean
@@ -249,7 +252,7 @@
         }
 
         @Bean
-        HealingPipelineDao healingPipelineDao(){
+        HealingPipelineDao healingPipelineDao() {
             return HEALING_PIPELINE_DAO;
         }
 
@@ -271,7 +274,6 @@
             //Create Service for Scenario 1 Tests (1 Service)
             serviceVertex = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion());
 
-
             Map<GraphPropertyEnum, Object> props = propsForHighestVersion();
             props.put(GraphPropertyEnum.IS_VSP_ARCHIVED, false);
             props.put(GraphPropertyEnum.CSAR_UUID, CSAR_UUID1);
@@ -287,7 +289,7 @@
             janusGraphDao.createEdge(catalogVertex, resourceVertex, EdgeLabelEnum.CATALOG_ELEMENT, null);
         }
 
-        private Map<GraphPropertyEnum, Object> propsForHighestVersion(){
+        private Map<GraphPropertyEnum, Object> propsForHighestVersion() {
             Map<GraphPropertyEnum, Object> props = new HashMap<>();
             props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
             return props;
@@ -297,22 +299,26 @@
     public static final HttpServletRequest request = mock(HttpServletRequest.class);
 
     /* Users */
-    private static final User adminUser = new User("admin", "admin", "admin", "admin@email.com", Role.ADMIN.name(), System.currentTimeMillis());
-    private static final User designerUser = new User("designer", "designer", "designer", "designer@email.com", Role.DESIGNER.name(), System
-                                                                                                                                              .currentTimeMillis());
-    private static final User otherUser = new User("other", "other", "other", "other@email.com", Role.TESTER.name(), System.currentTimeMillis());
+    private static final User adminUser = new User("admin", "admin", "admin", "admin@email.com", Role.ADMIN.name(),
+        System.currentTimeMillis());
+    private static final User designerUser = new User("designer", "designer", "designer", "designer@email.com",
+        Role.DESIGNER.name(), System.currentTimeMillis());
+    private static final User otherUser = new User("other", "other", "other", "other@email.com", Role.TESTER.name(),
+        System.currentTimeMillis());
 
-    @BeforeClass
+    @BeforeAll
     public static void setup() {
         //Needed for User Authorization
         //========================================================================================================================
-        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+            .thenReturn(webAppContextWrapper);
         when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
         when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
         when(servletUtils.getUserAdmin()).thenReturn(userAdmin);
         when(servletUtils.getComponentsUtils()).thenReturn(componentUtils);
         when(componentUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION)).thenReturn(responseFormat);
-        when(componentUtils.getResponseFormat(eq(ActionStatus.INVALID_SERVICE_STATE), any())).thenReturn(invalidServiceStateResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.INVALID_SERVICE_STATE), any()))
+            .thenReturn(invalidServiceStateResponseFormat);
         when(responseFormat.getStatus()).thenReturn(HttpStatus.UNAUTHORIZED.value());
 
         ComponentException ce = new ByResponseFormatComponentException(responseFormat);
@@ -322,24 +328,29 @@
         when(notFoundResponseFormat.getStatus()).thenReturn(HttpStatus.NOT_FOUND.value());
         when(invalidServiceStateResponseFormat.getStatus()).thenReturn(HttpStatus.CONFLICT.value());
         when(badRequestResponseFormat.getStatus()).thenReturn(HttpStatus.BAD_REQUEST.value());
-        when(componentUtils.getResponseFormat(eq(ActionStatus.RESOURCE_NOT_FOUND), (String[]) any())).thenReturn(notFoundResponseFormat);
-        when(componentUtils.getResponseFormat(eq(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID), (String[]) any())).thenReturn(badRequestResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.RESOURCE_NOT_FOUND), (String[]) any()))
+            .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID), (String[]) any()))
+            .thenReturn(badRequestResponseFormat);
 
-        when(graphLockOperation.lockComponent(anyString(), any(NodeTypeEnum.class))).thenReturn(StorageOperationStatus.OK);
+        when(graphLockOperation.lockComponent(anyString(), any(NodeTypeEnum.class)))
+            .thenReturn(StorageOperationStatus.OK);
         when(userAdmin.getUser(adminUser.getUserId(), false)).thenReturn(adminUser);
         when(userAdmin.getUser(designerUser.getUserId(), false)).thenReturn(designerUser);
         when(userAdmin.getUser(otherUser.getUserId(), false)).thenReturn(otherUser);
         //========================================================================================================================
 
         String appConfigDir = "src/test/resources/config/catalog-be";
-        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+            appConfigDir);
         ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
 
         org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
         configuration.setJanusGraphInMemoryGraph(true);
 
         org.openecomp.sdc.be.config.Configuration.HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new org.openecomp.sdc.be.config.Configuration.HeatDeploymentArtifactTimeout();
-        heatDeploymentArtifactTimeout.setDefaultMinutes(30);;
+        heatDeploymentArtifactTimeout.setDefaultMinutes(30);
+        ;
         configuration.setHeatArtifactDeploymentTimeout(heatDeploymentArtifactTimeout);
         configurationManager.setConfiguration(configuration);
 
@@ -347,13 +358,23 @@
         ExternalConfiguration.setAppName("catalog-be");
     }
 
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
+    }
+
+    @AfterEach
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
     @Test
-    public void getArchivedComponents_Empty() {
+    void getArchivedComponents_Empty() {
         assertOnGetArchivedComponents(null, 0);
     }
 
     @Test
-    public void archiveAndGetArchivedService_SingleService() {
+    void archiveAndGetArchivedService_SingleService() {
         Component serviceComponent = mock(Component.class);
         final String serviceUniqueId = serviceVertex.getUniqueId();
         when(toscaOperationFacade.getToscaElement(serviceUniqueId)).thenReturn(Either.left(serviceComponent));
@@ -364,7 +385,7 @@
     }
 
     @Test
-    public void archiveAndGetArchivedResource_SingleResource() {
+    void archiveAndGetArchivedResource_SingleResource() {
         Component component = mock(Component.class);
         final String uniqueId = resourceVertex.getUniqueId();
         when(toscaOperationFacade.getToscaElement(uniqueId)).thenReturn(Either.left(component));
@@ -375,40 +396,40 @@
     }
 
     @Test
-    public void attemptArchiveCheckedOutService() {
+    void attemptArchiveCheckedOutService() {
         checkoutComponent(serviceVertex);
         archiveService(serviceVertex.getUniqueId(), HttpStatus.CONFLICT.value());
     }
 
     @Test
-    public void testOnArchivedVsps(){
+    void testOnArchivedVsps() {
         String path = "/v1/catalog/notif/vsp/archived";
         List<String> csarIds = new LinkedList<>();
         csarIds.add("123456");
         csarIds.add(CSAR_UUID2);   //An archived CSAR ID
         Response response = target()
-                                    .path(path)
-                                    .request(MediaType.APPLICATION_JSON)
-                                    .accept(MediaType.APPLICATION_JSON)
-                                    .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                                    .post(Entity.json(csarIds));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(csarIds));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
         assertOnVertexProp(resourceVertexVspArchived.getUniqueId(), true);
     }
 
     @Test
-    public void testOnRestoredVsps(){
+    void testOnRestoredVsps() {
         String path = "/v1/catalog/notif/vsp/restored";
         List<String> csarIds = new LinkedList<>();
         csarIds.add("123456");
         csarIds.add(CSAR_UUID1);   //Non archived CSAR_ID
         Response response = target()
-                                    .path(path)
-                                    .request(MediaType.APPLICATION_JSON)
-                                    .accept(MediaType.APPLICATION_JSON)
-                                    .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                                    .post(Entity.json(csarIds));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(csarIds));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
         assertOnVertexProp(resourceVertex.getUniqueId(), false);
@@ -418,24 +439,24 @@
      *   Rainy Scenarios
      */
     @Test
-    public void archiveWithInvalidUid() {
+    void archiveWithInvalidUid() {
         archiveService("fakeUid", HttpStatus.NOT_FOUND.value());
     }
 
     @Test
-    public void restoreWithInvalidUid() {
+    void restoreWithInvalidUid() {
         restoreService("fakeUid", HttpStatus.NOT_FOUND.value());
     }
 
     @Test
-    public void archiveWithTester() {
+    void archiveWithTester() {
         String path = String.format("/v1/catalog/services/%s/%s", serviceVertex.getUniqueId(), "archive");
         Response response = target()
-                                    .path(path)
-                                    .request()
-                                    .accept(MediaType.APPLICATION_JSON)
-                                    .header(Constants.USER_ID_HEADER, otherUser.getUserId())
-                                    .post(null);
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, otherUser.getUserId())
+            .post(null);
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.UNAUTHORIZED.value());
     }
@@ -455,20 +476,30 @@
         assertThat(v.getMetadataProperty(GraphPropertyEnum.IS_VSP_ARCHIVED)).isEqualTo(expectedValue);
     }
 
-    private void archiveService(String id, int expectedStatus){ archiveOrRestoreService(id, ArchiveOperation.Action.ARCHIVE, expectedStatus); }
-    private void restoreService(String id, int expectedStatus){ archiveOrRestoreService(id, ArchiveOperation.Action.RESTORE, expectedStatus); }
+    private void archiveService(String id, int expectedStatus) {
+        archiveOrRestoreService(id, ArchiveOperation.Action.ARCHIVE, expectedStatus);
+    }
 
-    private void archiveResource(String id, int expectedStatus){ archiveOrRestoreResource(id, ArchiveOperation.Action.ARCHIVE, expectedStatus); }
-    private void restoreResource(String id, int expectedStatus){ archiveOrRestoreResource(id, ArchiveOperation.Action.RESTORE, expectedStatus); }
+    private void restoreService(String id, int expectedStatus) {
+        archiveOrRestoreService(id, ArchiveOperation.Action.RESTORE, expectedStatus);
+    }
+
+    private void archiveResource(String id, int expectedStatus) {
+        archiveOrRestoreResource(id, ArchiveOperation.Action.ARCHIVE, expectedStatus);
+    }
+
+    private void restoreResource(String id, int expectedStatus) {
+        archiveOrRestoreResource(id, ArchiveOperation.Action.RESTORE, expectedStatus);
+    }
 
     private void archiveOrRestoreService(String compUid, ArchiveOperation.Action action, int expectedStatus) {
         String path = String.format("/v1/catalog/services/%s/%s", compUid, action.name().toLowerCase());
         Response response = target()
-                                    .path(path)
-                                    .request()
-                                    .accept(MediaType.APPLICATION_JSON)
-                                    .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                                    .post(null);
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(null);
 
         assertThat(response.getStatus()).isEqualTo(expectedStatus);
     }
@@ -476,11 +507,11 @@
     private void archiveOrRestoreResource(String compUid, ArchiveOperation.Action action, int expectedStatus) {
         String path = String.format("/v1/catalog/resources/%s/%s", compUid, action.name().toLowerCase());
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                .post(null);
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(null);
 
         assertThat(response.getStatus()).isEqualTo(expectedStatus);
     }
@@ -489,13 +520,15 @@
         String path = "/v1/catalog/archive";
 
         Response response = target()
-                                    .path(path)
-                                    .request()
-                                    .accept(MediaType.APPLICATION_JSON)
-                                    .header(Constants.USER_ID_HEADER, designerUser.getUserId())
-                                    .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-        Map<String, List<CatalogComponent>> archivedComponents = response.readEntity(new GenericType<Map<String, List<CatalogComponent>>>() {  });
+        Map<String, List<CatalogComponent>> archivedComponents = response
+            .readEntity(new GenericType<Map<String, List<CatalogComponent>>>() {
+            });
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
 
         if (componentType == null) {
@@ -511,9 +544,9 @@
         ApplicationContext context = new AnnotationConfigApplicationContext(TestSpringConfig.class);
         forceSet(TestProperties.CONTAINER_PORT, "0");
         return new ResourceConfig(ArchiveEndpoint.class)
-                       .register(DefaultExceptionMapper.class)
-                       .register(ComponentExceptionMapper.class)
-                       .register(StorageExceptionMapper.class)
-                       .property("contextConfig", context);
+            .register(DefaultExceptionMapper.class)
+            .register(ComponentExceptionMapper.class)
+            .register(StorageExceptionMapper.class)
+            .property("contextConfig", context);
     }
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AutomatedUpgradeEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AutomatedUpgradeEndpointTest.java
index 91f9b5b..42ffa1a 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AutomatedUpgradeEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AutomatedUpgradeEndpointTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,15 +20,29 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import fj.data.Either;
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider;
 import org.glassfish.jersey.server.ResourceConfig;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
 import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
 import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
@@ -64,22 +78,10 @@
 import org.springframework.context.annotation.Import;
 import org.springframework.http.HttpStatus;
 
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.List;
+class AutomatedUpgradeEndpointTest extends JerseySpringBaseTest {
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class AutomatedUpgradeEndpointTest extends JerseySpringBaseTest {
-    static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
+    static ConfigurationSource configurationSource = new FSConfigurationSource(
+        ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
     static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
 
     private static final String RESOURCE_ID_PREV = "prevVF";
@@ -128,12 +130,13 @@
 
         @Bean
         UpgradeBusinessLogic upgradeBusinessLogic() {
-            return new UpgradeBusinessLogic(lifecycleBusinessLogic, componentInstanceBusinessLogic, userValidations, toscaOperationFacade, componentsUtils, upgradeOperation,
+            return new UpgradeBusinessLogic(lifecycleBusinessLogic, componentInstanceBusinessLogic, userValidations,
+                toscaOperationFacade, componentsUtils, upgradeOperation,
                 janusGraphDao);
         }
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void initClass() {
         lifecycleBusinessLogic = mock(LifecycleBusinessLogic.class);
         componentInstanceBusinessLogic = mock(ComponentInstanceBusinessLogic.class);
@@ -145,8 +148,9 @@
         user = mock(User.class);
     }
 
-    @Before
-    public void init() {
+    @BeforeEach
+    public void init() throws Exception {
+        super.setUp();
         prepareComponents();
         when(userValidations.validateUserExists(eq(USER_ID))).thenReturn(user);
         when(toscaOperationFacade.getToscaFullElement(eq(RESOURCE_ID_PREV))).thenReturn(Either.left(vfPrev));
@@ -155,20 +159,33 @@
         when(toscaOperationFacade.getToscaFullElement(eq(SERVICE_ID_NEW))).thenReturn(Either.left(serviceNew));
 
         Either<Service, ResponseFormat> fromLifeCycle = Either.left(serviceNew);
-        doReturn(fromLifeCycle).when(lifecycleBusinessLogic).changeComponentState(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID_PREV), any(User.class), eq(LifeCycleTransitionEnum.CHECKOUT), any(LifecycleChangeInfoWithAction.class), eq(false),
+        doReturn(fromLifeCycle).when(lifecycleBusinessLogic)
+            .changeComponentState(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID_PREV), any(User.class),
+                eq(LifeCycleTransitionEnum.CHECKOUT), any(LifecycleChangeInfoWithAction.class), eq(false),
                 eq(true));
 
-        when(toscaOperationFacade.getToscaElement(eq(RESOURCE_ID_PREV), any(ComponentParametersView.class))).thenReturn(Either.left(vfPrev));
-        when(componentInstanceBusinessLogic.changeInstanceVersion(any(Service.class), any(ComponentInstance.class), any(ComponentInstance.class), any(User.class), eq(ComponentTypeEnum.SERVICE))).thenReturn(istanceNew);
+        when(toscaOperationFacade.getToscaElement(eq(RESOURCE_ID_PREV), any(ComponentParametersView.class)))
+            .thenReturn(Either.left(vfPrev));
+        when(componentInstanceBusinessLogic
+            .changeInstanceVersion(any(Service.class), any(ComponentInstance.class), any(ComponentInstance.class),
+                any(User.class), eq(ComponentTypeEnum.SERVICE))).thenReturn(istanceNew);
 
-        doReturn(Either.left(serviceNewCheckIn)).when(lifecycleBusinessLogic).changeComponentState(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID_NEW), any(User.class), eq(LifeCycleTransitionEnum.CHECKIN), any(LifecycleChangeInfoWithAction.class),
+        doReturn(Either.left(serviceNewCheckIn)).when(lifecycleBusinessLogic)
+            .changeComponentState(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID_NEW), any(User.class),
+                eq(LifeCycleTransitionEnum.CHECKIN), any(LifecycleChangeInfoWithAction.class),
                 eq(false), eq(true));
 
     }
 
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
+
     @Override
     protected void configureClient(ClientConfig config) {
-        final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         config.register(jacksonJsonProvider);
     }
 
@@ -178,13 +195,14 @@
     }
 
     @Test
-    public void upgradeVfInService_success() {
+    void upgradeVfInService_success() {
         List<UpgradeRequest> inputsToUpdate = new ArrayList<>();
         UpgradeRequest request = new UpgradeRequest(SERVICE_ID_PREV);
         inputsToUpdate.add(request);
 
         Invocation.Builder builder = buildAutomatedUpgradeCall(RESOURCE_ID_NEW);
-        UpgradeStatus status = builder.post(Entity.entity(inputsToUpdate, MediaType.APPLICATION_JSON), UpgradeStatus.class);
+        UpgradeStatus status = builder
+            .post(Entity.entity(inputsToUpdate, MediaType.APPLICATION_JSON), UpgradeStatus.class);
 
         assertThat(status.getStatus()).isEqualTo(ActionStatus.OK);
         List<ServiceInfo> expected = new ArrayList<>();
@@ -198,20 +216,25 @@
     }
 
     @Test
-    public void upgradeVfInService_IdNotExist() {
+    void upgradeVfInService_IdNotExist() {
         List<UpgradeRequest> inputsToUpdate = new ArrayList<>();
         UpgradeRequest request = new UpgradeRequest(SERVICE_ID_PREV);
         inputsToUpdate.add(request);
         String wrongId = "1234";
-        when(toscaOperationFacade.getToscaFullElement(eq(wrongId))).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
-        when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.NOT_FOUND))).thenReturn(ActionStatus.RESOURCE_NOT_FOUND);
-        String[] variables = { wrongId };
-        ServiceException serviceException = new ServiceException("SVC4063", "Error: Requested '%1' resource was not found.", variables);
+        when(toscaOperationFacade.getToscaFullElement(eq(wrongId)))
+            .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+        when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.NOT_FOUND)))
+            .thenReturn(ActionStatus.RESOURCE_NOT_FOUND);
+        String[] variables = {wrongId};
+        ServiceException serviceException = new ServiceException("SVC4063",
+            "Error: Requested '%1' resource was not found.", variables);
         ResponseFormat expected = new ResponseFormat(HttpStatus.NOT_FOUND.value());
         expected.setServiceException(serviceException);
-        when(componentsUtils.getResponseFormatByResource(eq(ActionStatus.RESOURCE_NOT_FOUND), eq(wrongId))).thenReturn(expected);
+        when(componentsUtils.getResponseFormatByResource(eq(ActionStatus.RESOURCE_NOT_FOUND), eq(wrongId)))
+            .thenReturn(expected);
 
-        Response response = buildAutomatedUpgradeCall(wrongId).post(Entity.entity(inputsToUpdate, MediaType.APPLICATION_JSON), Response.class);
+        Response response = buildAutomatedUpgradeCall(wrongId)
+            .post(Entity.entity(inputsToUpdate, MediaType.APPLICATION_JSON), Response.class);
         assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
 
         ResponseFormat actual = response.readEntity(ResponseFormat.class);
@@ -221,19 +244,24 @@
     }
 
     @Test
-    public void upgradeVfInService_NotHihgestCertified() {
+    void upgradeVfInService_NotHihgestCertified() {
         List<UpgradeRequest> inputsToUpdate = new ArrayList<>();
         UpgradeRequest request = new UpgradeRequest(RESOURCE_ID_PREV);
         inputsToUpdate.add(request);
 
-        when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.NOT_FOUND))).thenReturn(ActionStatus.RESOURCE_NOT_FOUND);
-        String[] variables = { vfPrev.getName() };
-        ServiceException serviceException = new ServiceException("SVC4699", "Error: Component %1 is not highest certified", variables);
+        when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.NOT_FOUND)))
+            .thenReturn(ActionStatus.RESOURCE_NOT_FOUND);
+        String[] variables = {vfPrev.getName()};
+        ServiceException serviceException = new ServiceException("SVC4699",
+            "Error: Component %1 is not highest certified", variables);
         ResponseFormat expected = new ResponseFormat(HttpStatus.BAD_REQUEST.value());
         expected.setServiceException(serviceException);
-        when(componentsUtils.getResponseFormat(eq(ActionStatus.COMPONENT_IS_NOT_HIHGEST_CERTIFIED), eq(vfPrev.getName()))).thenReturn(expected);
+        when(componentsUtils
+            .getResponseFormat(eq(ActionStatus.COMPONENT_IS_NOT_HIHGEST_CERTIFIED), eq(vfPrev.getName())))
+            .thenReturn(expected);
 
-        Response response = buildAutomatedUpgradeCall(RESOURCE_ID_PREV).post(Entity.entity(inputsToUpdate, MediaType.APPLICATION_JSON), Response.class);
+        Response response = buildAutomatedUpgradeCall(RESOURCE_ID_PREV)
+            .post(Entity.entity(inputsToUpdate, MediaType.APPLICATION_JSON), Response.class);
         assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST.value());
 
         ResponseFormat actual = response.readEntity(ResponseFormat.class);
@@ -254,7 +282,8 @@
 //    }
 
     private Invocation.Builder buildAutomatedUpgradeCall(String id) {
-        return target("/v1/catalog/resources/{id}/automatedupgrade").resolveTemplate("id", id).request(MediaType.APPLICATION_JSON).header(Constants.USER_ID_HEADER, USER_ID);
+        return target("/v1/catalog/resources/{id}/automatedupgrade").resolveTemplate("id", id)
+            .request(MediaType.APPLICATION_JSON).header(Constants.USER_ID_HEADER, USER_ID);
     }
 
     private void prepareComponents() {
@@ -265,7 +294,7 @@
 
     private void createService() {
         servicePrev = createService("service1", SERVICE_ID_PREV, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
-        
+
         ComponentInstance ci = new ComponentInstance();
         ci.setComponentUid(RESOURCE_ID_PREV);
         ci.setName("inst 1");
@@ -277,7 +306,7 @@
         serviceNew.setComponentInstances(resourceInstances);
 
         serviceNewCheckIn = createService("service1", SERVICE_ID_NEW, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
-        
+
         serviceNewCheckIn.setComponentInstances(resourceInstances);
 
         istanceNew = new ComponentInstance();
@@ -285,14 +314,15 @@
         istanceNew.setName("inst 1");
 
         serviceProxy = createService("serviceProxy", SERVICE_ID_PROXY, LifecycleStateEnum.CERTIFIED);
-        serviceProxyContainerPrev = createService("serviceProxyContainer", SERVICE_ID_PROXY_PREV, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
-        serviceProxyContainerNew = createService("serviceProxyContainer", SERVICE_ID_PROXY_NEW, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
-       
-        
+        serviceProxyContainerPrev = createService("serviceProxyContainer", SERVICE_ID_PROXY_PREV,
+            LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+        serviceProxyContainerNew = createService("serviceProxyContainer", SERVICE_ID_PROXY_NEW,
+            LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+
 
     }
 
-    private Service createService(String name, String id, LifecycleStateEnum state){
+    private Service createService(String name, String id, LifecycleStateEnum state) {
         Service service = new Service();
         service.setName(name);
         service.setUniqueId(id);
@@ -300,6 +330,7 @@
         service.setHighestVersion(true);
         return service;
     }
+
     private void createVF() {
         vfPrev = new Resource();
         vfPrev.setName("vf1");
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java
index b49ed17..abe2544 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentInstanceServletTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -39,7 +39,6 @@
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
-import javax.ws.rs.Path;
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -48,8 +47,10 @@
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentMatchers;
 import org.mockito.Mockito;
 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
@@ -86,7 +87,7 @@
 /**
  * The test suite designed for test functionality of ComponentInstanceServlet class
  */
-public class ComponentInstanceServletTest extends JerseyTest {
+class ComponentInstanceServletTest extends JerseyTest {
 
     private final static String USER_ID = "jh0003";
     private static HttpServletRequest request;
@@ -105,7 +106,7 @@
     private static ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
     private static ConfigurationManager configurationManager;
 
-    @BeforeClass
+    @BeforeAll
     public static void setup() {
         createMocks();
         stubMethods();
@@ -118,47 +119,61 @@
         ExternalConfiguration.setAppName("catalog-be");
     }
 
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
+    }
+
+    @AfterEach
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
     @Test
-    public void testGetRelationByIdSuccess(){
+    void testGetRelationByIdSuccess() {
 
         String containerComponentType = "resources";
         String componentId = "componentId";
         String relationId = "relationId";
         String path = "/v1/catalog/" + containerComponentType + "/" + componentId + "/" + relationId + "/relationId";
-        Either<RequirementCapabilityRelDef, ResponseFormat> successResponse = Either.left(new RequirementCapabilityRelDef());
-        when(componentInstanceBusinessLogic.getRelationById(eq(componentId), eq(relationId), eq(USER_ID), eq(ComponentTypeEnum.RESOURCE))).thenReturn(successResponse);
+        Either<RequirementCapabilityRelDef, ResponseFormat> successResponse = Either
+            .left(new RequirementCapabilityRelDef());
+        when(componentInstanceBusinessLogic
+            .getRelationById(eq(componentId), eq(relationId), eq(USER_ID), eq(ComponentTypeEnum.RESOURCE)))
+            .thenReturn(successResponse);
         when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200);
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .get( Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .get(Response.class);
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
     }
 
     @Test
-    public void testGetRelationByIdFailure(){
+    void testGetRelationByIdFailure() {
 
         String containerComponentType = "unknown_type";
         String componentId = "componentId";
         String relationId = "relationId";
         String path = "/v1/catalog/" + containerComponentType + "/" + componentId + "/" + relationId + "/relationId";
         when(responseFormat.getStatus()).thenReturn(HttpStatus.BAD_REQUEST_400);
-        when(componentsUtils.getResponseFormat(eq(ActionStatus.UNSUPPORTED_ERROR), eq(containerComponentType))).thenReturn(responseFormat);
+        when(componentsUtils.getResponseFormat(eq(ActionStatus.UNSUPPORTED_ERROR), eq(containerComponentType)))
+            .thenReturn(responseFormat);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .get( Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .get(Response.class);
 
-        assertEquals(response.getStatus(), HttpStatus.BAD_REQUEST_400);
+        assertEquals(HttpStatus.BAD_REQUEST_400, response.getStatus());
     }
 
     @Test
-    public void testBatchDeleteResourceInstancesSuccess() {
+    void testBatchDeleteResourceInstancesSuccess() {
 
         String componentId = "componentId";
         String containerComponentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
@@ -179,23 +194,23 @@
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
         Either<String[], ResponseFormat> convertStatusEither = Either.left(delCompIds);
         when(componentsUtils
-                .convertJsonToObjectUsingObjectMapper(anyString(), any(User.class), ArgumentMatchers.<Class<String[]>>any(),
-                        nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class))).thenReturn(convertStatusEither);
+            .convertJsonToObjectUsingObjectMapper(anyString(), any(User.class), ArgumentMatchers.<Class<String[]>>any(),
+                nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class))).thenReturn(convertStatusEither);
         when(componentInstanceBusinessLogic
-                .batchDeleteComponentInstance(eq(containerComponentType), eq(componentId), any(List.class),
-                        eq(USER_ID))).thenReturn(Mockito.mock(Map.class));
+            .batchDeleteComponentInstance(eq(containerComponentType), eq(componentId), any(List.class),
+                eq(USER_ID))).thenReturn(Mockito.mock(Map.class));
 
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .post(Entity.json(compInsts));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .post(Entity.json(compInsts));
 
         assertEquals(HttpStatus.OK_200, response.getStatus());
     }
 
     @Test
-    public void testBatchDeleteResourceInstancesFailure() {
+    void testBatchDeleteResourceInstancesFailure() {
 
         String componentId = "componentId";
         String containerComponentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
@@ -205,16 +220,16 @@
         when(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT)).thenReturn(responseFormat);
 
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .post(Entity.json(""));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .post(Entity.json(""));
 
         assertEquals(HttpStatus.INTERNAL_SERVER_ERROR_500, response.getStatus());
     }
 
     @Test
-    public void testBatchDissociateRIFromRISuccess() {
+    void testBatchDissociateRIFromRISuccess() {
 
         String componentId = "componentId";
         String containerComponentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
@@ -227,24 +242,24 @@
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
         Either<RequirementCapabilityRelDef[], ResponseFormat> convertReqEither = Either.left(refs);
         when(componentsUtils.convertJsonToObjectUsingObjectMapper(anyString(), any(User.class),
-                ArgumentMatchers.<Class<RequirementCapabilityRelDef[]>>any(),
-                nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class))).thenReturn(convertReqEither);
+            ArgumentMatchers.<Class<RequirementCapabilityRelDef[]>>any(),
+            nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class))).thenReturn(convertReqEither);
         RequirementCapabilityRelDef actionResponseEither = ref;
         when(componentInstanceBusinessLogic
-                .dissociateRIFromRI(componentId, USER_ID, ref, ComponentTypeEnum.findByParamName(containerComponentType)))
-                .thenReturn(actionResponseEither);
+            .dissociateRIFromRI(componentId, USER_ID, ref, ComponentTypeEnum.findByParamName(containerComponentType)))
+            .thenReturn(actionResponseEither);
 
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .put(Entity.json(refs));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .put(Entity.json(refs));
 
         assertEquals(HttpStatus.OK_200, response.getStatus());
     }
 
     @Test
-    public void testBatchDissociateRIFromRIFailure() {
+    void testBatchDissociateRIFromRIFailure() {
 
         String componentId = "componentId";
         String containerComponentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
@@ -254,10 +269,10 @@
         when(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT)).thenReturn(responseFormat);
 
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .put(Entity.json(""));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .put(Entity.json(""));
 
         assertEquals(HttpStatus.INTERNAL_SERVER_ERROR_500, response.getStatus());
     }
@@ -267,21 +282,21 @@
         forceSet(TestProperties.CONTAINER_PORT, "0");
         ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
         return new ResourceConfig(ComponentInstanceServlet.class)
-                .register(new AbstractBinder() {
-                    @Override
-                    protected void configure() {
-                        bind(request).to(HttpServletRequest.class);
-                        bind(userBusinessLogic).to(UserBusinessLogic.class);
-                        bind(groupBusinessLogic).to(GroupBusinessLogic.class);
-                        bind(componentInstanceBusinessLogic).to(ComponentInstanceBusinessLogic.class);
-                        bind(componentsUtils).to(ComponentsUtils.class);
-                        bind(servletUtils).to(ServletUtils.class);
-                        bind(resourceImportManager).to(ResourceImportManager.class);
-                        bind(serviceBusinessLogic).to(ServiceBusinessLogic.class);
-                        bind(componentNodeFilterBusinessLogic).to(ComponentNodeFilterBusinessLogic.class);
-                    }
-                })
-                .property("contextConfig", context);
+            .register(new AbstractBinder() {
+                @Override
+                protected void configure() {
+                    bind(request).to(HttpServletRequest.class);
+                    bind(userBusinessLogic).to(UserBusinessLogic.class);
+                    bind(groupBusinessLogic).to(GroupBusinessLogic.class);
+                    bind(componentInstanceBusinessLogic).to(ComponentInstanceBusinessLogic.class);
+                    bind(componentsUtils).to(ComponentsUtils.class);
+                    bind(servletUtils).to(ServletUtils.class);
+                    bind(resourceImportManager).to(ResourceImportManager.class);
+                    bind(serviceBusinessLogic).to(ServiceBusinessLogic.class);
+                    bind(componentNodeFilterBusinessLogic).to(ComponentNodeFilterBusinessLogic.class);
+                }
+            })
+            .property("contextConfig", context);
     }
 
     private static void createMocks() {
@@ -304,21 +319,23 @@
     private static void stubMethods() {
         when(request.getSession()).thenReturn(session);
         when(session.getServletContext()).thenReturn(servletContext);
-        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+            .thenReturn(webAppContextWrapper);
         when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
-        when(webApplicationContext.getBean(ComponentInstanceBusinessLogic.class)).thenReturn(componentInstanceBusinessLogic);
+        when(webApplicationContext.getBean(ComponentInstanceBusinessLogic.class))
+            .thenReturn(componentInstanceBusinessLogic);
         when(request.getHeader("USER_ID")).thenReturn(USER_ID);
         when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
         when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
     }
 
     @Test
-    public void testUpdateResourceInstancePropertiesSuccess(){
+    void testUpdateResourceInstancePropertiesSuccess() {
 
         String containerComponentType = "services";
         String componentId = "componentId";
         String resourceInstanceId = "resourceInstanceId";
-        ComponentInstanceProperty [] properties = new ComponentInstanceProperty[1];
+        ComponentInstanceProperty[] properties = new ComponentInstanceProperty[1];
         ComponentInstanceProperty property = new ComponentInstanceProperty();
         property.setName("property");
         property.setValue("value");
@@ -332,22 +349,25 @@
             e.printStackTrace();
         }
         String path = "/v1/catalog/" + containerComponentType + "/" + componentId + "/resourceInstance" + "/" +
-                resourceInstanceId + "/properties";
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(propertyJson, new User(), ComponentInstanceProperty[].class,
+            resourceInstanceId + "/properties";
+        when(componentsUtils
+            .convertJsonToObjectUsingObjectMapper(propertyJson, new User(), ComponentInstanceProperty[].class,
                 null, ComponentTypeEnum.RESOURCE_INSTANCE)).thenReturn(Either.left(properties));
-        when(componentInstanceBusinessLogic.createOrUpdatePropertiesValues(eq(ComponentTypeEnum.findByParamName(SERVICE_PARAM_NAME)),
-                eq(componentId), eq(resourceInstanceId), eq(Arrays.asList(properties)), eq(USER_ID))).thenReturn(Either.left(Arrays.asList(properties)));
+        when(componentInstanceBusinessLogic
+            .createOrUpdatePropertiesValues(eq(ComponentTypeEnum.findByParamName(SERVICE_PARAM_NAME)),
+                eq(componentId), eq(resourceInstanceId), eq(Arrays.asList(properties)), eq(USER_ID)))
+            .thenReturn(Either.left(Arrays.asList(properties)));
         when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200);
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID).post(Entity.entity(properties, MediaType.APPLICATION_JSON));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID).post(Entity.entity(properties, MediaType.APPLICATION_JSON));
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
     }
 
     @Test
-    public void testUpdateResourceInstanceInputsSuccess(){
+    void testUpdateResourceInstanceInputsSuccess() {
 
         String containerComponentType = "services";
         String componentId = "componentId";
@@ -366,27 +386,29 @@
             e.printStackTrace();
         }
         String path = "/v1/catalog/" + containerComponentType + "/" + componentId + "/resourceInstance" + "/" +
-                resourceInstanceId + "/inputs";
+            resourceInstanceId + "/inputs";
         when(componentsUtils.convertJsonToObjectUsingObjectMapper(inputJson, new User(), ComponentInstanceInput[].class,
-                null, ComponentTypeEnum.RESOURCE_INSTANCE)).thenReturn(Either.left(inputs));
-        when(componentInstanceBusinessLogic.createOrUpdateInstanceInputValues(eq(ComponentTypeEnum.findByParamName(SERVICE_PARAM_NAME)),
-                eq(componentId), eq(resourceInstanceId), eq(Arrays.asList(inputs)), eq(USER_ID))).thenReturn(Either.left(Arrays.asList(inputs)));
+            null, ComponentTypeEnum.RESOURCE_INSTANCE)).thenReturn(Either.left(inputs));
+        when(componentInstanceBusinessLogic
+            .createOrUpdateInstanceInputValues(eq(ComponentTypeEnum.findByParamName(SERVICE_PARAM_NAME)),
+                eq(componentId), eq(resourceInstanceId), eq(Arrays.asList(inputs)), eq(USER_ID)))
+            .thenReturn(Either.left(Arrays.asList(inputs)));
         when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200);
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID).post(Entity.entity(inputs, MediaType.APPLICATION_JSON));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID).post(Entity.entity(inputs, MediaType.APPLICATION_JSON));
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
     }
 
     @Test
-    public void testUpdateResourceInstancePropertiesFailure(){
+    void testUpdateResourceInstancePropertiesFailure() {
 
         String containerComponentType = "services";
         String componentId = "componentId";
         String resourceInstanceId = "resourceInstanceId";
-        ComponentInstanceProperty [] properties = new ComponentInstanceProperty[1];
+        ComponentInstanceProperty[] properties = new ComponentInstanceProperty[1];
         ComponentInstanceProperty property = new ComponentInstanceProperty();
         property.setName("property");
         property.setValue("value");
@@ -400,28 +422,30 @@
             e.printStackTrace();
         }
         String path = "/v1/catalog/" + containerComponentType + "/" + componentId + "/resourceInstance" + "/" +
-                resourceInstanceId + "/properties";
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(propertyJson, new User(), ComponentInstanceProperty[].class,
+            resourceInstanceId + "/properties";
+        when(componentsUtils
+            .convertJsonToObjectUsingObjectMapper(propertyJson, new User(), ComponentInstanceProperty[].class,
                 null, ComponentTypeEnum.RESOURCE_INSTANCE)).thenReturn(Either.left(properties));
-        when(componentInstanceBusinessLogic.createOrUpdatePropertiesValues(eq(ComponentTypeEnum.findByParamName(SERVICE_PARAM_NAME)),
+        when(componentInstanceBusinessLogic
+            .createOrUpdatePropertiesValues(eq(ComponentTypeEnum.findByParamName(SERVICE_PARAM_NAME)),
                 eq(componentId), eq(resourceInstanceId), eq(Arrays.asList(properties)), eq(USER_ID)))
-                .thenReturn(Either.right(new ResponseFormat(404)));
+            .thenReturn(Either.right(new ResponseFormat(404)));
         when(responseFormat.getStatus()).thenReturn(HttpStatus.NOT_FOUND_404);
         when(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND)).thenReturn(responseFormat);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID).post(Entity.entity(properties, MediaType.APPLICATION_JSON));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID).post(Entity.entity(properties, MediaType.APPLICATION_JSON));
         assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND_404);
     }
 
     @Test
-    public void testUpdateResourceInstanceInputsFailure(){
+    void testUpdateResourceInstanceInputsFailure() {
 
         String containerComponentType = "services";
         String componentId = "componentId";
         String resourceInstanceId = "resourceInstanceId";
-        ComponentInstanceInput [] inputs = new ComponentInstanceInput[1];
+        ComponentInstanceInput[] inputs = new ComponentInstanceInput[1];
         ComponentInstanceInput input = new ComponentInstanceInput();
         input.setName("input");
         input.setValue("value");
@@ -435,23 +459,24 @@
             e.printStackTrace();
         }
         String path = "/v1/catalog/" + containerComponentType + "/" + componentId + "/resourceInstance" + "/" +
-                resourceInstanceId + "/inputs";
+            resourceInstanceId + "/inputs";
         when(componentsUtils.convertJsonToObjectUsingObjectMapper(inputJson, new User(), ComponentInstanceInput[].class,
-                null, ComponentTypeEnum.RESOURCE_INSTANCE)).thenReturn(Either.left(inputs));
-        when(componentInstanceBusinessLogic.createOrUpdateInstanceInputValues(eq(ComponentTypeEnum.findByParamName(SERVICE_PARAM_NAME)),
+            null, ComponentTypeEnum.RESOURCE_INSTANCE)).thenReturn(Either.left(inputs));
+        when(componentInstanceBusinessLogic
+            .createOrUpdateInstanceInputValues(eq(ComponentTypeEnum.findByParamName(SERVICE_PARAM_NAME)),
                 eq(componentId), eq(resourceInstanceId), eq(Arrays.asList(inputs)), eq(USER_ID)))
-                .thenReturn(Either.right(new ResponseFormat(404)));
+            .thenReturn(Either.right(new ResponseFormat(404)));
         when(responseFormat.getStatus()).thenReturn(HttpStatus.NOT_FOUND_404);
         when(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND)).thenReturn(responseFormat);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID).post(Entity.entity(inputs, MediaType.APPLICATION_JSON));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID).post(Entity.entity(inputs, MediaType.APPLICATION_JSON));
         assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND_404);
     }
-    
+
     @Test
-    public void testUpdateInstanceRequirement(){
+    void testUpdateInstanceRequirement() {
 
         String containerComponentType = "services";
         String componentId = "componentId";
@@ -467,19 +492,21 @@
             e.printStackTrace();
         }
         String path = "/v1/catalog/" + containerComponentType + "/" + componentId + "/componentInstances/" +
-                componentInstanceId + "/requirement/" + capabilityType + "/requirementName/" + requirementName;
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(eq(requirementJson), any(User.class), eq(RequirementDefinition.class),
-                eq(AuditingActionEnum.GET_TOSCA_MODEL), eq(ComponentTypeEnum.SERVICE))).thenReturn(Either.left(requirementDefinition));
+            componentInstanceId + "/requirement/" + capabilityType + "/requirementName/" + requirementName;
+        when(componentsUtils
+            .convertJsonToObjectUsingObjectMapper(eq(requirementJson), any(User.class), eq(RequirementDefinition.class),
+                eq(AuditingActionEnum.GET_TOSCA_MODEL), eq(ComponentTypeEnum.SERVICE)))
+            .thenReturn(Either.left(requirementDefinition));
         when(componentInstanceBusinessLogic.updateInstanceRequirement(ComponentTypeEnum.SERVICE,
-                componentId, componentInstanceId, capabilityType, requirementName, requirementDefinition, USER_ID))
-                .thenReturn(Either.left(requirementDefinition));
+            componentId, componentInstanceId, capabilityType, requirementName, requirementDefinition, USER_ID))
+            .thenReturn(Either.left(requirementDefinition));
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
         when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200);
 
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID).put(Entity.entity(requirementDefinition, MediaType.APPLICATION_JSON));
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID).put(Entity.entity(requirementDefinition, MediaType.APPLICATION_JSON));
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
     }
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java
index 7674ea9..fac1586 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java
@@ -25,9 +25,9 @@
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -35,12 +35,8 @@
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import fj.data.Either;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
 import java.util.Optional;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -53,18 +49,24 @@
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
+import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.ArgumentMatchers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
 import org.openecomp.sdc.be.components.impl.ComponentNodeFilterBusinessLogic;
 import org.openecomp.sdc.be.components.impl.ResourceImportManager;
 import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException;
 import org.openecomp.sdc.be.components.impl.utils.NodeFilterConstraintAction;
 import org.openecomp.sdc.be.components.validation.UserValidations;
-import org.openecomp.sdc.be.config.Configuration;
 import org.openecomp.sdc.be.config.ConfigurationManager;
 import org.openecomp.sdc.be.config.SpringConfig;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -79,12 +81,11 @@
 import org.openecomp.sdc.be.impl.ServletUtils;
 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
 import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
 import org.openecomp.sdc.be.ui.model.UIConstraint;
 import org.openecomp.sdc.be.user.Role;
 import org.openecomp.sdc.be.user.UserBusinessLogic;
-import org.openecomp.sdc.common.api.Constants;
 import org.openecomp.sdc.common.api.ConfigurationSource;
+import org.openecomp.sdc.common.api.Constants;
 import org.openecomp.sdc.common.impl.ExternalConfiguration;
 import org.openecomp.sdc.common.impl.FSConfigurationSource;
 import org.openecomp.sdc.exception.ResponseFormat;
@@ -92,7 +93,10 @@
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 
-public class ComponentNodeFilterServletTest extends JerseyTest {
+@ExtendWith(MockitoExtension.class)
+@TestInstance(Lifecycle.PER_CLASS)
+class ComponentNodeFilterServletTest extends JerseyTest {
+
     private static final String USER_ID = "jh0003";
     private static final String servicePropertyName = "resourceType";
     private static final String constraintOperator = "equal";
@@ -103,30 +107,47 @@
     private static final String componentInstance = "dac65869-dfb4-40d2-aa20-084324659ec1.resource0";
     private static final String componentType = "resources";
     private static final String capabilityName = "MyCapabilityName";
+    private static final String V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER = "/v1/catalog/%s/%s/componentInstance/%s/%s/%s/nodeFilter";
+    private static final String V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_NODE_FILTER = "/v1/catalog/%s/%s/componentInstance/%s/%s/nodeFilter";
+    private final UIConstraint uiConstraint = new UIConstraint("resourceType", "equal", "static", "static", "resourceTypeValue");
+    private final String constraint = new ConstraintConvertor().convert(uiConstraint);
+    private final String inputJson = buildConstraintDataJson(uiConstraint);
+    private final User user = new User("", "", USER_ID, "", Role.ADMIN.name(), null);
+    @Mock
+    private HttpServletRequest request;
+    @Mock
+    private HttpSession session;
+    @Mock
+    private ServletContext servletContext;
+    @Mock
+    private WebAppContextWrapper webAppContextWrapper;
+    @Mock
+    private WebApplicationContext webApplicationContext;
+    @Mock
+    private UserBusinessLogic userBusinessLogic;
+    @Mock
+    private ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
+    @Mock
+    private ComponentsUtils componentsUtils;
+    @Mock
+    private ServletUtils servletUtils;
+    @Mock
+    private ResourceImportManager resourceImportManager;
+    @Mock
+    private ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
+    @Mock
+    private ResponseFormat responseFormat;
+    @Mock
+    private UserValidations userValidations;
 
-    private static HttpServletRequest request;
-    private static HttpSession session;
-    private static ServletContext servletContext;
-    private static WebAppContextWrapper webAppContextWrapper;
-    private static WebApplicationContext webApplicationContext;
-    private static UserBusinessLogic userBusinessLogic;
-    private static ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
-    private static ComponentsUtils componentsUtils;
-    private static ServletUtils servletUtils;
-    private static ResourceImportManager resourceImportManager;
-    private static ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic;
-    private static ResponseFormat responseFormat;
-    private static UserValidations userValidations;
-    private static ConfigurationManager configurationManager;
     private CINodeFilterDataDefinition ciNodeFilterDataDefinition;
-    private UIConstraint uiConstraint;
-    private String constraint;
-    private String inputJson;
-    private User user;
+
+    public ComponentNodeFilterServletTest() throws JsonProcessingException {
+    }
 
     @BeforeAll
-    public static void initClass() {
-        createMocks();
+    public void initClass() {
+        MockitoAnnotations.initMocks(this);
         when(request.getSession()).thenReturn(session);
         when(session.getServletContext()).thenReturn(servletContext);
         when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
@@ -135,10 +156,10 @@
         when(request.getHeader("USER_ID")).thenReturn(USER_ID);
         when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
         when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
-        String appConfigDir = "src/test/resources/config/catalog-be";
-        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
-        configurationManager = new ConfigurationManager(configurationSource);
-        org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
+        final String appConfigDir = "src/test/resources/config/catalog-be";
+        final ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+        final ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+        final org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
         configuration.setJanusGraphInMemoryGraph(true);
         configurationManager.setConfiguration(configuration);
         ExternalConfiguration.setAppName("catalog-be");
@@ -147,7 +168,6 @@
     @BeforeEach
     public void resetMock() throws Exception {
         super.setUp();
-        reset(componentNodeFilterBusinessLogic);
     }
 
     @AfterEach
@@ -156,17 +176,16 @@
     }
 
     @Test
-    public void addNodeFilterPropertiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
+    void addNodeFilterPropertiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.PROPERTIES_PARAM_NAME);
 
-        when(userValidations.validateUserExists(user)).thenReturn(user);
-        when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
-        when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200);
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
-
+        doReturn(user).when(componentNodeFilterBusinessLogic).validateUser(USER_ID);
+        doReturn(HttpStatus.OK_200).when(responseFormat).getStatus();
+        doReturn(responseFormat).when(componentsUtils).getResponseFormat(ActionStatus.OK);
+        doReturn(componentsUtils).when(servletUtils).getComponentsUtils();
         assertNotNull(uiConstraint);
         assertThat(servicePropertyName).isEqualToIgnoringCase(uiConstraint.getServicePropertyName());
         assertThat(constraintOperator).isEqualToIgnoringCase(uiConstraint.getConstraintOperator());
@@ -174,18 +193,18 @@
         assertThat(sourceName).isEqualToIgnoringCase(uiConstraint.getSourceName());
         assertThat(propertyValue).isEqualToIgnoringCase(uiConstraint.getValue().toString());
 
-        when(componentsUtils.parseToConstraint(anyString(), any(User.class), ArgumentMatchers.any(ComponentTypeEnum.class)))
-            .thenReturn(Optional.of(uiConstraint));
+        doReturn(Optional.of(uiConstraint)).when(componentsUtils)
+            .parseToConstraint(anyString(), any(User.class), ArgumentMatchers.any(ComponentTypeEnum.class));
 
         assertNotNull(constraint);
         assertNotNull(ciNodeFilterDataDefinition);
         assertThat(ciNodeFilterDataDefinition.getProperties().getListToscaDataDefinition()).hasSize(1);
         assertThat("resourceType: {equal: resourceTypeValue}\n").isEqualToIgnoringCase(constraint);
-        when(componentNodeFilterBusinessLogic
+
+        doReturn(Optional.of(ciNodeFilterDataDefinition)).when(componentNodeFilterBusinessLogic)
             .addNodeFilter(componentId, componentInstance, NodeFilterConstraintAction.ADD,
                 uiConstraint.getServicePropertyName(), constraint, true, ComponentTypeEnum.RESOURCE,
-                NodeFilterConstraintType.PROPERTIES, ""))
-            .thenReturn(Optional.of(ciNodeFilterDataDefinition));
+                NodeFilterConstraintType.PROPERTIES, "");
 
         final Response response = target()
             .path(path)
@@ -199,24 +218,26 @@
                 ArgumentMatchers.any(NodeFilterConstraintType.class), anyString());
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void addNodeFilterCapabilitiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
+    void addNodeFilterCapabilitiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.CAPABILITIES_PARAM_NAME);
-
-        final UIConstraint uiConstraint1 = uiConstraint;
-        when(userValidations.validateUserExists(user)).thenReturn(user);
+        final UIConstraint uiConstraint1 = new UIConstraint(uiConstraint.getServicePropertyName(), uiConstraint.getConstraintOperator(),
+            uiConstraint.getSourceType(), uiConstraint.getSourceName(), uiConstraint.getValue());
         when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
         when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200);
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
-        when(componentsUtils.parseToConstraint(anyString(), any(User.class),ArgumentMatchers.any(ComponentTypeEnum.class)))
-            .thenReturn(Optional.of(uiConstraint));
-
+        doReturn(componentsUtils).when(servletUtils).getComponentsUtils();
         uiConstraint1.setCapabilityName(capabilityName);
+
+        when(componentsUtils.parseToConstraint(anyString(), any(User.class), ArgumentMatchers.any(ComponentTypeEnum.class)))
+            .thenReturn(Optional.of(uiConstraint1));
+
         assertThat(ciNodeFilterDataDefinition.getProperties().getListToscaDataDefinition()).hasSize(1);
         when(componentNodeFilterBusinessLogic
             .addNodeFilter(componentId, componentInstance, NodeFilterConstraintAction.ADD,
@@ -236,29 +257,17 @@
                 ArgumentMatchers.any(NodeFilterConstraintType.class), anyString());
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void addNodeFilterFailTest() throws BusinessLogicException, JsonProcessingException {
+    void addNodeFilterFailTest() throws BusinessLogicException, JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.PROPERTIES_PARAM_NAME);
 
-        when(userValidations.validateUserExists(user)).thenReturn(user);
         when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
-        when(responseFormat.getStatus()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR_500);
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
-
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(anyString(), any(User.class),
-            ArgumentMatchers.<Class<UIConstraint>>any(),
-            nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class))).thenReturn(Either.left(uiConstraint));
-
-        when(componentNodeFilterBusinessLogic
-            .addNodeFilter(componentId, componentInstance, NodeFilterConstraintAction.ADD,
-                uiConstraint.getServicePropertyName(), constraint, true, ComponentTypeEnum.RESOURCE,
-                NodeFilterConstraintType.PROPERTIES, ""))
-            .thenReturn(Optional.empty());
 
         final Response response = target()
             .path(path)
@@ -267,25 +276,17 @@
             .post(Entity.entity(inputJson, MediaType.APPLICATION_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void addNodeFilterFailConstraintParseTest() throws JsonProcessingException {
+    void addNodeFilterFailConstraintParseTest() throws JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance, NodeFilterConstraintType.PROPERTIES_PARAM_NAME);
 
-        when(userValidations.validateUserExists(user)).thenReturn(user);
         when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
 
-        when(responseFormat.getStatus()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR_500);
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
-
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(anyString(), any(User.class),
-            ArgumentMatchers.<Class<UIConstraint>>any(),
-            nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class)))
-            .thenReturn(Either.right(new ResponseFormat(HttpStatus.INTERNAL_SERVER_ERROR_500)));
-
         final Response response = target()
             .path(path)
             .request(MediaType.APPLICATION_JSON)
@@ -293,26 +294,18 @@
             .post(Entity.entity(inputJson, MediaType.APPLICATION_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void addNodeFilterFailConvertTest() throws JsonProcessingException {
+    void addNodeFilterFailConvertTest() throws JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.PROPERTIES.getType());
 
-        when(userValidations.validateUserExists(user)).thenReturn(user);
         when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
 
-        when(responseFormat.getStatus()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR_500);
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
-
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(anyString(), any(User.class),
-            ArgumentMatchers.<Class<UIConstraint>>any(),
-            nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class)))
-            .thenReturn(Either.left(null));
-
         final Response response = target()
             .path(path)
             .request(MediaType.APPLICATION_JSON)
@@ -320,26 +313,23 @@
             .post(Entity.entity(inputJson, MediaType.APPLICATION_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void updateNodeFilterPropertiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
+    void updateNodeFilterPropertiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.PROPERTIES_PARAM_NAME, 0);
 
-        when(userValidations.validateUserExists(user)).thenReturn(user);
         when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
 
         when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200);
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
-
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(anyString(), any(User.class),
-            ArgumentMatchers.<Class<List>>any(),
-            nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class)))
-            .thenReturn(Either.left(Arrays.asList(new ObjectMapper().convertValue(uiConstraint, Map.class))));
-
+        doReturn(componentsUtils).when(servletUtils).getComponentsUtils();
+        doReturn(Optional.of(uiConstraint)).when(componentsUtils)
+            .parseToConstraint(anyString(), any(User.class), eq(ComponentTypeEnum.RESOURCE));
         when(componentNodeFilterBusinessLogic
             .updateNodeFilter(componentId, componentInstance, uiConstraint, ComponentTypeEnum.RESOURCE,
                 NodeFilterConstraintType.PROPERTIES, 0)).thenReturn(Optional.of(ciNodeFilterDataDefinition));
@@ -349,49 +339,25 @@
             .header(USER_ID_HEADER, USER_ID)
             .put(Entity.entity(inputJson, MediaType.APPLICATION_JSON));
 
-        verify(componentNodeFilterBusinessLogic, times(1))
-            .updateNodeFilter(anyString(), anyString(), ArgumentMatchers.any(UIConstraint.class),
-                ArgumentMatchers.any(ComponentTypeEnum.class), ArgumentMatchers.any(NodeFilterConstraintType.class),
-                anyInt());
-
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void updateNodeFilterCapabilitiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
+    void updateNodeFilterCapabilitiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.CAPABILITIES_PARAM_NAME, 0);
 
-        when(userValidations.validateUserExists(user)).thenReturn(user);
         when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
 
         when(componentsUtils.parseToConstraint(anyString(), any(User.class), ArgumentMatchers.any(ComponentTypeEnum.class)))
             .thenReturn(Optional.of(uiConstraint));
-
+        doReturn(componentsUtils).when(servletUtils).getComponentsUtils();
         when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200);
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
 
-        when(componentsUtils.validateAndParseConstraint(ArgumentMatchers.any(ComponentTypeEnum.class), anyString(), any(User.class)))
-            .thenReturn(Collections.singletonList(uiConstraint));
-
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(anyString(), any(User.class),
-            ArgumentMatchers.<Class<List>>any(),
-            nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class)))
-            .thenReturn(Either.left(Arrays.asList(new ObjectMapper().convertValue(uiConstraint, Map.class))));
-
-        when(componentNodeFilterBusinessLogic.deleteNodeFilter(componentId, componentInstance,
-            NodeFilterConstraintAction.DELETE, null, 0, true, ComponentTypeEnum.RESOURCE,
-            NodeFilterConstraintType.PROPERTIES))
-            .thenReturn(Optional.of(ciNodeFilterDataDefinition));
-
-        when(componentNodeFilterBusinessLogic
-            .addNodeFilter(componentId, componentInstance, NodeFilterConstraintAction.ADD,
-                uiConstraint.getServicePropertyName(), constraint, true, ComponentTypeEnum.RESOURCE,
-                NodeFilterConstraintType.PROPERTIES, ""))
-            .thenReturn(Optional.of(ciNodeFilterDataDefinition));
-
         when(componentNodeFilterBusinessLogic
             .updateNodeFilter(componentId, componentInstance, uiConstraint,
                 ComponentTypeEnum.RESOURCE, NodeFilterConstraintType.CAPABILITIES, 0))
@@ -409,55 +375,18 @@
                 anyInt());
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void updateNodeFilterFailTest() throws BusinessLogicException, JsonProcessingException {
+    void updateNodeFilterFailTest() throws BusinessLogicException, JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.PROPERTIES_PARAM_NAME, 0);
 
-        when(userValidations.validateUserExists(user)).thenReturn(user);
         when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
 
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
-
-        when(componentsUtils.validateAndParseConstraint(ArgumentMatchers.any(ComponentTypeEnum.class), anyString(), any(User.class)))
-            .thenReturn(Collections.singletonList(uiConstraint));
-
-        when(componentNodeFilterBusinessLogic
-            .updateNodeFilter(componentId, componentInstance, uiConstraint,
-                ComponentTypeEnum.RESOURCE, NodeFilterConstraintType.PROPERTIES, 0))
-            .thenReturn(Optional.empty());
-        final Response response = target()
-            .path(path)
-            .request(MediaType.APPLICATION_JSON)
-            .header(USER_ID_HEADER, USER_ID)
-            .put(Entity.entity(inputJson, MediaType.APPLICATION_JSON));
-
-        verify(componentNodeFilterBusinessLogic, times(1))
-            .updateNodeFilter(anyString(), anyString(), ArgumentMatchers.any(UIConstraint.class),
-                ArgumentMatchers.any(ComponentTypeEnum.class), ArgumentMatchers.any(NodeFilterConstraintType.class),
-                anyInt());
-
-        assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
-    }
-
-    @Test
-    public void updateNodeFilterFailConstraintParseTest() throws JsonProcessingException {
-        initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/%s/nodeFilter";
-        final String path = String.format(pathFormat, componentType, componentId, componentInstance,
-            NodeFilterConstraintType.PROPERTIES_PARAM_NAME, 0);
-
-        when(userValidations.validateUserExists(user)).thenReturn(user);
-        when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
-
-        when(componentsUtils.validateAndParseConstraint(ArgumentMatchers.any(ComponentTypeEnum.class), anyString(), any(User.class)))
-            .thenReturn(Collections.emptyList());
-
         final Response response = target()
             .path(path)
             .request(MediaType.APPLICATION_JSON)
@@ -465,23 +394,17 @@
             .put(Entity.entity(inputJson, MediaType.APPLICATION_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void updateNodeFilterFailConvertTest() throws JsonProcessingException {
+    void updateNodeFilterFailConstraintParseTest() throws JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.PROPERTIES_PARAM_NAME, 0);
 
-        when(userValidations.validateUserExists(user)).thenReturn(user);
         when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
-
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(anyString(), any(User.class),
-            ArgumentMatchers.<Class<List>>any(),
-            nullable(AuditingActionEnum.class), nullable(ComponentTypeEnum.class)))
-            .thenReturn(Either.left(null));
 
         final Response response = target()
             .path(path)
@@ -490,18 +413,37 @@
             .put(Entity.entity(inputJson, MediaType.APPLICATION_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void deleteNodeFilterSuccessTest() throws BusinessLogicException, JsonProcessingException {
+    void updateNodeFilterFailConvertTest() throws JsonProcessingException {
         initComponentData();
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/%s/nodeFilter";
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.PROPERTIES_PARAM_NAME, 0);
 
-        when(userValidations.validateUserExists(user)).thenReturn(user);
         when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
 
+        final Response response = target()
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header(USER_ID_HEADER, USER_ID)
+            .put(Entity.entity(inputJson, MediaType.APPLICATION_JSON));
+
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
+    }
+
+    @Test
+    void deleteNodeFilterSuccessTest() throws BusinessLogicException, JsonProcessingException {
+        initComponentData();
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
+        final String path = String.format(pathFormat, componentType, componentId, componentInstance,
+            NodeFilterConstraintType.PROPERTIES_PARAM_NAME, 0);
+
+        when(componentNodeFilterBusinessLogic.validateUser(USER_ID)).thenReturn(user);
+        doReturn(componentsUtils).when(servletUtils).getComponentsUtils();
         when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200);
         when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
 
@@ -523,11 +465,12 @@
                 ArgumentMatchers.any(NodeFilterConstraintType.class));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
+        verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
     }
 
     @Test
-    public void deleteNodeFilterFailTest() {
-        final String pathFormat = "/v1/catalog/%s/%s/componentInstance/%s/%s/%s/nodeFilter";
+    void deleteNodeFilterFailTest() {
+        final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
         final String path = String.format(pathFormat, componentType, componentId, componentInstance,
             NodeFilterConstraintType.PROPERTIES_PARAM_NAME, 0);
         final Response response = target()
@@ -540,23 +483,6 @@
         assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500);
     }
 
-    private static void createMocks() {
-        request = mock(HttpServletRequest.class);
-        userBusinessLogic = mock(UserBusinessLogic.class);
-        componentInstanceBusinessLogic = mock(ComponentInstanceBusinessLogic.class);
-        componentsUtils = mock(ComponentsUtils.class);
-        servletUtils = mock(ServletUtils.class);
-        resourceImportManager = mock(ResourceImportManager.class);
-        componentNodeFilterBusinessLogic = mock(ComponentNodeFilterBusinessLogic.class);
-
-        session = mock(HttpSession.class);
-        servletContext = mock(ServletContext.class);
-        webAppContextWrapper = mock(WebAppContextWrapper.class);
-        webApplicationContext = mock(WebApplicationContext.class);
-        responseFormat = mock(ResponseFormat.class);
-        userValidations = mock(UserValidations.class);
-    }
-
     @Override
     protected ResourceConfig configure() {
         forceSet(TestProperties.CONTAINER_PORT, "0");
@@ -578,10 +504,6 @@
     }
 
     private void initComponentData() throws JsonProcessingException {
-        uiConstraint = new UIConstraint("resourceType", "equal", "static", "static", "resourceTypeValue");
-        constraint = new ConstraintConvertor().convert(uiConstraint);
-        inputJson = buildConstraintDataJson(uiConstraint);
-
         final RequirementNodeFilterPropertyDataDefinition requirementNodeFilterPropertyDataDefinition =
             new RequirementNodeFilterPropertyDataDefinition();
         requirementNodeFilterPropertyDataDefinition.setName(uiConstraint.getServicePropertyName());
@@ -603,9 +525,6 @@
         ciNodeFilterDataDefinition.setCapabilities(capabilityDataDefinitionList);
         ciNodeFilterDataDefinition.setID("NODE_FILTER_UID");
 
-        user = new User();
-        user.setUserId(USER_ID);
-        user.setRole(Role.ADMIN.name());
     }
 
     private String buildConstraintDataJson(final UIConstraint uiConstraint) throws JsonProcessingException {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentPropertyServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentPropertyServletTest.java
index 5b2c9cb..e455896 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentPropertyServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentPropertyServletTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,17 +20,24 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.core.Response;
 import org.glassfish.grizzly.http.util.HttpStatus;
 import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+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.MockitoAnnotations;
 import org.mockito.Spy;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
@@ -41,16 +48,9 @@
 import org.openecomp.sdc.exception.ResponseFormat;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpSession;
-import javax.ws.rs.core.Response;
+@ExtendWith(MockitoExtension.class)
+class ComponentPropertyServletTest extends JerseySpringBaseTest {
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ComponentPropertyServletTest extends JerseySpringBaseTest {
     @Mock
     private static HttpSession session;
     @Mock
@@ -73,32 +73,35 @@
     private static final String INVALID_PROPERTY_NAME = "invalid_name_$.&";
     private static final String STRING_TYPE = "string";
 
-    @Before
-    public void initClass() {
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
         when(request.getSession()).thenReturn(session);
-        when(session.getServletContext()).thenReturn(context);
-        when(context.getAttribute(eq(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))).thenReturn(wrapper);
-        when(wrapper.getWebAppContext(any())).thenReturn(webAppContext);
-        when(webAppContext.getBean(eq(ComponentsUtils.class))).thenReturn(componentsUtils);
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
     }
 
     @Test
-    public void testCreatePropertyOnService_success() {
+    void testCreatePropertyOnService_success() {
         PropertyDefinition property = new PropertyDefinition();
         property.setName(VALID_PROPERTY_NAME);
         property.setType(STRING_TYPE);
 
         EntryData<String, PropertyDefinition> propertyEntry = new EntryData<>(VALID_PROPERTY_NAME, property);
-        when(propertyBl.addPropertyToComponent(eq(SERVICE_ID), any(), any(), any())).thenReturn(Either.left(propertyEntry));
+        when(propertyBl.addPropertyToComponent(eq(SERVICE_ID), any(), any(), any()))
+            .thenReturn(Either.left(propertyEntry));
 
         Response propertyInService =
-                componentPropertyServlet.createPropertyInService(SERVICE_ID, getValidProperty(), request, USER_ID);
+            componentPropertyServlet.createPropertyInService(SERVICE_ID, getValidProperty(), request, USER_ID);
 
         Assert.assertEquals(HttpStatus.OK_200.getStatusCode(), propertyInService.getStatus());
     }
 
     @Test
-    public void testCreatePropertyInvalidName_failure() {
+    void testCreatePropertyInvalidName_failure() {
         PropertyDefinition property = new PropertyDefinition();
         property.setName(INVALID_PROPERTY_NAME);
         property.setType(STRING_TYPE);
@@ -107,38 +110,41 @@
         responseFormat.setStatus(HttpStatus.BAD_REQUEST_400.getStatusCode());
 
         when(componentsUtils.getResponseFormat(eq(ActionStatus.INVALID_PROPERTY_NAME))).thenReturn(responseFormat);
-
+        when(session.getServletContext()).thenReturn(context);
+        when(context.getAttribute(eq(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))).thenReturn(wrapper);
+        when(wrapper.getWebAppContext(any())).thenReturn(webAppContext);
+        when(webAppContext.getBean(eq(ComponentsUtils.class))).thenReturn(componentsUtils);
 
         Response propertyInService =
-                componentPropertyServlet.createPropertyInService(SERVICE_ID, getInvalidProperty(), request, USER_ID);
+            componentPropertyServlet.createPropertyInService(SERVICE_ID, getInvalidProperty(), request, USER_ID);
 
         Assert.assertEquals(HttpStatus.BAD_REQUEST_400.getStatusCode(), propertyInService.getStatus());
     }
 
     private String getValidProperty() {
         return "{\n"
-                       + "  \"valid_name_123\": {\n"
-                       + "    \"schema\": {\n"
-                       + "      \"property\": {\n"
-                       + "        \"type\": \"\"\n"
-                       + "      }\n" + "    },\n"
-                       + "    \"type\": \"string\",\n"
-                       + "    \"name\": \"valid_name_123\"\n"
-                       + "  }\n"
-                       + "}";
+            + "  \"valid_name_123\": {\n"
+            + "    \"schema\": {\n"
+            + "      \"property\": {\n"
+            + "        \"type\": \"\"\n"
+            + "      }\n" + "    },\n"
+            + "    \"type\": \"string\",\n"
+            + "    \"name\": \"valid_name_123\"\n"
+            + "  }\n"
+            + "}";
     }
 
     private String getInvalidProperty() {
         return "{\n"
-                       + "  \"invalid_name_$.&\": {\n"
-                       + "    \"schema\": {\n"
-                       + "      \"property\": {\n"
-                       + "        \"type\": \"\"\n"
-                       + "      }\n" + "    },\n"
-                       + "    \"type\": \"string\",\n"
-                       + "    \"name\": \"invalid_name_$.&\"\n"
-                       + "  }\n"
-                       + "}";
+            + "  \"invalid_name_$.&\": {\n"
+            + "    \"schema\": {\n"
+            + "      \"property\": {\n"
+            + "        \"type\": \"\"\n"
+            + "      }\n" + "    },\n"
+            + "    \"type\": \"string\",\n"
+            + "    \"name\": \"invalid_name_$.&\"\n"
+            + "  }\n"
+            + "}";
     }
 
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java
index 77b90ad..2b0ffe9 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentServletTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,13 +20,25 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
+import java.util.Collections;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.TestProperties;
 import org.json.JSONArray;
 import org.json.JSONObject;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openecomp.sdc.be.components.impl.ComponentBusinessLogicProvider;
 import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
 import org.openecomp.sdc.be.components.utils.PolicyDefinitionBuilder;
@@ -37,19 +49,7 @@
 import org.openecomp.sdc.be.user.UserBusinessLogic;
 import org.openecomp.sdc.common.api.Constants;
 
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.Collections;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ComponentServletTest extends JerseySpringBaseTest{
+class ComponentServletTest extends JerseySpringBaseTest {
 
     private static final String USER_ID = "userId";
     private static final String RESOURCE_ID = "resourceId";
@@ -57,39 +57,47 @@
     private PolicyDefinition policy1, policy2;
 
     @Override
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         super.setUp();
         policy1 = buildPolicy("p1");
         policy2 = buildPolicy("p2");
     }
 
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
+
     @Override
     protected ResourceConfig configure() {
         forceSet(TestProperties.CONTAINER_PORT, "0");
         resourceBusinessLogic = mock(ResourceBusinessLogic.class);
         UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class);
         ComponentsUtils componentsUtils = mock(ComponentsUtils.class);
-        ComponentServlet componentServlet = new ComponentServlet(userBusinessLogic, componentsUtils, new ComponentBusinessLogicProvider(resourceBusinessLogic, null, null));
+        ComponentServlet componentServlet = new ComponentServlet(userBusinessLogic, componentsUtils,
+            new ComponentBusinessLogicProvider(resourceBusinessLogic, null, null));
         return super.configure().register(componentServlet);
     }
 
     @Test
-    public void filterDataByParam_getPolicies_returnOnlyNameTargetsAndIdFields() {
+    void filterDataByParam_getPolicies_returnOnlyNameTargetsAndIdFields() {
         UiComponentDataTransfer dataTransfer = buildDataTransferWithPolicies();
-        when(resourceBusinessLogic.getComponentDataFilteredByParams(eq(RESOURCE_ID.toLowerCase()), any(User.class), eq(Collections.singletonList("policies")))).thenReturn(Either.left(dataTransfer));
+        when(resourceBusinessLogic.getComponentDataFilteredByParams(eq(RESOURCE_ID.toLowerCase()), any(User.class),
+            eq(Collections.singletonList("policies")))).thenReturn(Either.left(dataTransfer));
         UiComponentDataTransfer uiComponentDataTransfer = buildGetPolicyTypesCall().get(UiComponentDataTransfer.class);
         assertThat(uiComponentDataTransfer.getPolicies())
-                .usingElementComparatorOnFields("name", "uniqueId", "targets")
-                .containsExactlyInAnyOrder(policy1, policy2)
-                .extracting("properties")//properties is not returned in the response
-                .containsExactly(null, null);
+            .usingElementComparatorOnFields("name", "uniqueId", "targets")
+            .containsExactlyInAnyOrder(policy1, policy2)
+            .extracting("properties")//properties is not returned in the response
+            .containsExactly(null, null);
     }
 
     @Test
-    public void filterDataByParam_getPolicies_policyTypeNameFieldShouldReturnAsType() {
+    void filterDataByParam_getPolicies_policyTypeNameFieldShouldReturnAsType() {
         UiComponentDataTransfer dataTransfer = buildDataTransferWithPolicies();
-        when(resourceBusinessLogic.getComponentDataFilteredByParams(eq(RESOURCE_ID.toLowerCase()), any(User.class), eq(Collections.singletonList("policies")))).thenReturn(Either.left(dataTransfer));
+        when(resourceBusinessLogic.getComponentDataFilteredByParams(eq(RESOURCE_ID.toLowerCase()), any(User.class),
+            eq(Collections.singletonList("policies")))).thenReturn(Either.left(dataTransfer));
         Response uiComponentDataTransfer = buildGetPolicyTypesCall().get();
         verifyPolicyTypeFieldUsingJsonResponse(uiComponentDataTransfer);
     }
@@ -112,22 +120,22 @@
 
     private PolicyDefinition buildPolicy(String id) {
         return PolicyDefinitionBuilder.create()
-                .setUniqueId(id)
-                .setName("name" + id)
-                .setType("type" + id)
-                .addGroupTarget("group1")
-                .addGroupTarget("group2")
-                .addComponentInstanceTarget("inst1")
-                .addComponentInstanceTarget("inst2")
-                .addProperty("prop1")
-                .build();
+            .setUniqueId(id)
+            .setName("name" + id)
+            .setType("type" + id)
+            .addGroupTarget("group1")
+            .addGroupTarget("group2")
+            .addComponentInstanceTarget("inst1")
+            .addComponentInstanceTarget("inst2")
+            .addProperty("prop1")
+            .build();
     }
 
     private Invocation.Builder buildGetPolicyTypesCall() {
         return target("/v1/catalog/resources/{id}/filteredDataByParams")
-                .queryParam("include", "policies")
-                .resolveTemplate("id", RESOURCE_ID)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID);
+            .queryParam("include", "policies")
+            .resolveTemplate("id", RESOURCE_ID)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID);
     }
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
index af7199c..cd8c0c5 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
@@ -22,16 +22,34 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.apache.commons.text.StrSubstitutor;
 import org.apache.http.HttpStatus;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
@@ -70,1002 +88,1020 @@
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+class ElementServletTest extends JerseyTest {
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.when;
+    public static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+    public static final HttpSession session = Mockito.mock(HttpSession.class);
+    public static final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
+    public static final ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
+    public static final BeGenericServlet beGenericServlet = Mockito.mock(BeGenericServlet.class);
+    public static final Resource resource = Mockito.mock(Resource.class);
+    public static final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
+    public static final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito
+        .mock(ComponentInstanceBusinessLogic.class);
+    public static final ArtifactsBusinessLogic artifactsBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class);
 
-public class ElementServletTest extends JerseyTest {
-	public static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-	public static final HttpSession session = Mockito.mock(HttpSession.class);
-	public static final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
-	public static final ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
-	public static final BeGenericServlet beGenericServlet =  Mockito.mock(BeGenericServlet.class);
-	public static final Resource resource = Mockito.mock(Resource.class);
-	public static final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
-	public static final ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class);
-	public static final ArtifactsBusinessLogic artifactsBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class);
+    private static final ServletContext servletContext = Mockito.mock(ServletContext.class);
+    public static final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
+    private static final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
+    private static final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
+    private static final UserBusinessLogic userAdmin = Mockito.mock(UserBusinessLogic.class);
+    private static final ComponentsUtils componentUtils = Mockito.mock(ComponentsUtils.class);
+    private static final ComponentsCleanBusinessLogic componentsCleanBusinessLogic = Mockito
+        .mock(ComponentsCleanBusinessLogic.class);
+    private static final ElementBusinessLogic elementBusinessLogic = Mockito.mock(ElementBusinessLogic.class);
 
-	private static final ServletContext servletContext = Mockito.mock(ServletContext.class);
-	public static final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
-	private static final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
-	private static final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
-	private static final UserBusinessLogic userAdmin = Mockito.mock(UserBusinessLogic.class);
-	private static final ComponentsUtils componentUtils = Mockito.mock(ComponentsUtils.class);
-	private static final ComponentsCleanBusinessLogic componentsCleanBusinessLogic = Mockito.mock(ComponentsCleanBusinessLogic.class);
-	private static final ElementBusinessLogic elementBusinessLogic = Mockito.mock(ElementBusinessLogic.class);
+    private static final ResponseFormat okResponseFormat = new ResponseFormat(HttpStatus.SC_OK);
+    private static final ResponseFormat conflictResponseFormat = new ResponseFormat(HttpStatus.SC_CONFLICT);
+    private static final ResponseFormat generalErrorResponseFormat = new ResponseFormat(
+        HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    private static final ResponseFormat createdResponseFormat = new ResponseFormat(HttpStatus.SC_CREATED);
+    private static final ResponseFormat noContentResponseFormat = new ResponseFormat(HttpStatus.SC_NO_CONTENT);
+    private static final ResponseFormat unauthorizedResponseFormat = Mockito.mock(ResponseFormat.class);
+    private static final ResponseFormat notFoundResponseFormat = Mockito.mock(ResponseFormat.class);
+    private static final ResponseFormat badRequestResponseFormat = Mockito.mock(ResponseFormat.class);
+    private static final String EMPTY_JSON = "{}";
+    private static final String COMPONENT_TYPE = "componentType";
+    private static final String CATEGORY_UNIQUE_ID = "categoryUniqueId";
+    private static final String CATEGORY_ID = "categoryId";
+    private static final String SUB_CATEGORY_UNIQUE_ID = "subCategoryUniqueId";
+    private static final String SUB_CATEGORY_ID = "subCategoryId";
+    private static final String GROUPING_UNIQUE_ID = "groupingUniqueId";
 
-	private static final ResponseFormat okResponseFormat = new ResponseFormat(HttpStatus.SC_OK);
-	private static final ResponseFormat conflictResponseFormat = new ResponseFormat(HttpStatus.SC_CONFLICT);
-	private static final ResponseFormat generalErrorResponseFormat = new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	private static final ResponseFormat createdResponseFormat = new ResponseFormat(HttpStatus.SC_CREATED);
-	private static final ResponseFormat noContentResponseFormat = new ResponseFormat(HttpStatus.SC_NO_CONTENT);
-	private static final ResponseFormat unauthorizedResponseFormat = Mockito.mock(ResponseFormat.class);
-	private static final ResponseFormat notFoundResponseFormat = Mockito.mock(ResponseFormat.class);
-	private static final ResponseFormat badRequestResponseFormat = Mockito.mock(ResponseFormat.class);
-	private static final String EMPTY_JSON = "{}";
-	private static final String COMPONENT_TYPE = "componentType";
-	private static final String CATEGORY_UNIQUE_ID = "categoryUniqueId";
-	private static final String CATEGORY_ID = "categoryId";
-	private static final String SUB_CATEGORY_UNIQUE_ID = "subCategoryUniqueId";
-	private static final String SUB_CATEGORY_ID = "subCategoryId";
-	private static final String GROUPING_UNIQUE_ID = "groupingUniqueId";
+    /* Users */
+    private static User designerUser = new User("designer", "designer", "designer", "designer@email.com",
+        Role.DESIGNER.name(), System
+        .currentTimeMillis());
 
-	/* Users */
-	private static User designerUser = new User("designer", "designer", "designer", "designer@email.com", Role.DESIGNER.name(), System
-			.currentTimeMillis());
+    private static ConfigurationManager configurationManager;
 
-	private static ConfigurationManager configurationManager;
+    @BeforeAll
+    public static void setup() {
 
-	@BeforeClass
-	public static void setup() {
+        //Needed for User Authorization
+        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+            .thenReturn(webAppContextWrapper);
+        when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
+        when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
+        when(servletUtils.getUserAdmin()).thenReturn(userAdmin);
+        when(servletUtils.getComponentsUtils()).thenReturn(componentUtils);
+        when(componentUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION))
+            .thenReturn(unauthorizedResponseFormat);
+        when(unauthorizedResponseFormat.getStatus()).thenReturn(HttpStatus.SC_UNAUTHORIZED);
 
-		//Needed for User Authorization
-		when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
-		when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
-		when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
-		when(servletUtils.getUserAdmin()).thenReturn(userAdmin);
-		when(servletUtils.getComponentsUtils()).thenReturn(componentUtils);
-		when(componentUtils.getResponseFormat(ActionStatus.RESTRICTED_OPERATION)).thenReturn(unauthorizedResponseFormat);
-		when(unauthorizedResponseFormat.getStatus()).thenReturn(HttpStatus.SC_UNAUTHORIZED);
+        when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(okResponseFormat);
+        when(componentUtils.getResponseFormat(ActionStatus.CREATED)).thenReturn(createdResponseFormat);
+        when(componentUtils.getResponseFormat(ActionStatus.NO_CONTENT)).thenReturn(noContentResponseFormat);
+        when(componentUtils.getResponseFormat(ActionStatus.INVALID_CONTENT)).thenReturn(badRequestResponseFormat);
+        when(componentUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(generalErrorResponseFormat);
+        when(componentUtils.getResponseFormat(any(ComponentException.class)))
+            .thenReturn(generalErrorResponseFormat);
 
-		when(componentUtils.getResponseFormat(ActionStatus.OK)) .thenReturn(okResponseFormat);
-		when(componentUtils.getResponseFormat(ActionStatus.CREATED)).thenReturn(createdResponseFormat);
-		when(componentUtils.getResponseFormat(ActionStatus.NO_CONTENT)).thenReturn(noContentResponseFormat);
-		when(componentUtils.getResponseFormat(ActionStatus.INVALID_CONTENT)).thenReturn(badRequestResponseFormat);
-		when(componentUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)) .thenReturn(generalErrorResponseFormat);
-		when(componentUtils.getResponseFormat(any(ComponentException.class)))
-				.thenReturn(generalErrorResponseFormat);
+        ByResponseFormatComponentException ce = Mockito.mock(ByResponseFormatComponentException.class);
+        when(ce.getResponseFormat()).thenReturn(unauthorizedResponseFormat);
 
-		ByResponseFormatComponentException ce = Mockito.mock(ByResponseFormatComponentException.class);
-		when(ce.getResponseFormat()).thenReturn(unauthorizedResponseFormat);
+        //Needed for error configuration
+        when(notFoundResponseFormat.getStatus()).thenReturn(HttpStatus.SC_NOT_FOUND);
+        when(badRequestResponseFormat.getStatus()).thenReturn(HttpStatus.SC_BAD_REQUEST);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.RESOURCE_NOT_FOUND), any()))
+            .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.COMPONENT_VERSION_NOT_FOUND), any()))
+            .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND), any()))
+            .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.EXT_REF_NOT_FOUND), any()))
+            .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(eq(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID), any()))
+            .thenReturn(badRequestResponseFormat);
+        when(request.getSession()).thenReturn(session);
+        when(session.getServletContext()).thenReturn(servletContext);
+        when(beGenericServlet.getElementBL(any())).thenReturn(elementBusinessLogic);
+        when(webApplicationContext.getBean(ElementBusinessLogic.class)).thenReturn(elementBusinessLogic);
+        when(webApplicationContext.getBean(ComponentsUtils.class)).thenReturn(componentUtils);
+        when(beGenericServlet.getComponentsUtils()).thenReturn(componentUtils);
 
-		//Needed for error configuration
-		when(notFoundResponseFormat.getStatus()).thenReturn(HttpStatus.SC_NOT_FOUND);
-		when(badRequestResponseFormat.getStatus()).thenReturn(HttpStatus.SC_BAD_REQUEST);
-		when(componentUtils.getResponseFormat(eq(ActionStatus.RESOURCE_NOT_FOUND), any())).thenReturn(notFoundResponseFormat);
-		when(componentUtils.getResponseFormat(eq(ActionStatus.COMPONENT_VERSION_NOT_FOUND), any())).thenReturn(notFoundResponseFormat);
-		when(componentUtils.getResponseFormat(eq(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND), any())).thenReturn(notFoundResponseFormat);
-		when(componentUtils.getResponseFormat(eq(ActionStatus.EXT_REF_NOT_FOUND), any())).thenReturn(notFoundResponseFormat);
-		when(componentUtils.getResponseFormat(eq(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID), any())).thenReturn(badRequestResponseFormat);
-		when(request.getSession()).thenReturn(session);
-		when(session.getServletContext()).thenReturn(servletContext);
-		when(beGenericServlet.getElementBL(any())).thenReturn(elementBusinessLogic);
-		when(webApplicationContext.getBean(ElementBusinessLogic.class)).thenReturn(elementBusinessLogic);
-		when(webApplicationContext.getBean(ComponentsUtils.class)).thenReturn(componentUtils);
-		when(beGenericServlet.getComponentsUtils()).thenReturn(componentUtils);
+        Either<User, ActionStatus> designerEither = Either.left(designerUser);
 
-		Either<User, ActionStatus> designerEither = Either.left(designerUser);
+        when(userAdmin.getUser(designerUser.getUserId(), false)).thenReturn(designerUser);
 
-		when(userAdmin.getUser(designerUser.getUserId(), false)).thenReturn(designerUser);
+        String appConfigDir = "src/test/resources/config/catalog-be";
+        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+            appConfigDir);
+        configurationManager = new ConfigurationManager(configurationSource);
 
-		String appConfigDir = "src/test/resources/config/catalog-be";
-		ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
-		configurationManager = new ConfigurationManager(configurationSource);
+        org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
+        configuration.setJanusGraphInMemoryGraph(true);
+        Configuration.HeatDeploymentArtifactTimeout testHeatDeploymentArtifactTimeout = new Configuration.HeatDeploymentArtifactTimeout();
+        testHeatDeploymentArtifactTimeout.setDefaultMinutes(1);
+        configuration.setHeatArtifactDeploymentTimeout(testHeatDeploymentArtifactTimeout);
 
-		org.openecomp.sdc.be.config.Configuration configuration = new org.openecomp.sdc.be.config.Configuration();
-		configuration.setJanusGraphInMemoryGraph(true);
-		Configuration.HeatDeploymentArtifactTimeout testHeatDeploymentArtifactTimeout = new Configuration.HeatDeploymentArtifactTimeout();
-		testHeatDeploymentArtifactTimeout.setDefaultMinutes(1);
-		configuration.setHeatArtifactDeploymentTimeout(testHeatDeploymentArtifactTimeout);
+        configurationManager.setConfiguration(configuration);
+        ExternalConfiguration.setAppName("catalog-be");
 
-		configurationManager.setConfiguration(configuration);
-		ExternalConfiguration.setAppName("catalog-be");
 
+    }
 
-	}
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
+        reset(elementBusinessLogic);
+    }
 
-	@Before
-	public void resetSomeMocks() {
-		reset(elementBusinessLogic);
-	}
+    @AfterEach
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
 
-	@Test
-	public void getComponentCategoriesNoCategoryFoundTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
+    @Test
+    void getComponentCategoriesNoCategoryFoundTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
 
-		String formatEndpoint = "/v1/categories/{componentType}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String formatEndpoint = "/v1/categories/{componentType}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		ResponseFormat notFoundResponseFormat = new ResponseFormat(HttpStatus.SC_NOT_FOUND);
-		Either<List<CategoryDefinition>, ResponseFormat> getAllCategoriesEither = Either.right(notFoundResponseFormat);
+        ResponseFormat notFoundResponseFormat = new ResponseFormat(HttpStatus.SC_NOT_FOUND);
+        Either<List<CategoryDefinition>, ResponseFormat> getAllCategoriesEither = Either.right(notFoundResponseFormat);
 
-		when(elementBusinessLogic.getAllCategories(componentType, designerUser.getUserId()))
-				.thenReturn(getAllCategoriesEither);
+        when(elementBusinessLogic.getAllCategories(componentType, designerUser.getUserId()))
+            .thenReturn(getAllCategoriesEither);
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
-	}
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
+    }
 
-	@Test
-	public void getComponentCategoriesExceptionDuringProcessingTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
+    @Test
+    void getComponentCategoriesExceptionDuringProcessingTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
 
-		String formatEndpoint = "/v1/categories/{componentType}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String formatEndpoint = "/v1/categories/{componentType}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		when(elementBusinessLogic.getAllCategories(componentType, designerUser.getUserId()))
-				.thenThrow(new RuntimeException("Test exception: getComponentCategories"));
+        when(elementBusinessLogic.getAllCategories(componentType, designerUser.getUserId()))
+            .thenThrow(new RuntimeException("Test exception: getComponentCategories"));
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-	@Test
-	public void getComponentCategoriesTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
+    @Test
+    void getComponentCategoriesTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
 
-		String formatEndpoint = "/v1/categories/{componentType}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String formatEndpoint = "/v1/categories/{componentType}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		Either<List<CategoryDefinition>, ResponseFormat> getAllCategoriesEither = Either.left(new ArrayList<>());
+        Either<List<CategoryDefinition>, ResponseFormat> getAllCategoriesEither = Either.left(new ArrayList<>());
 
-		when(elementBusinessLogic.getAllCategories(componentType, designerUser.getUserId()))
-				.thenReturn(getAllCategoriesEither);
+        when(elementBusinessLogic.getAllCategories(componentType, designerUser.getUserId()))
+            .thenReturn(getAllCategoriesEither);
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
-	}
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
+    }
 
-	@Test
-	public void getAllCategoriesNoCategoryFoundTest() {
-		String path = "/v1/categories";
+    @Test
+    void getAllCategoriesNoCategoryFoundTest() {
+        String path = "/v1/categories";
 
-		ResponseFormat notFoundResponseFormat = new ResponseFormat(HttpStatus.SC_NOT_FOUND);
-		Either<UiCategories, ResponseFormat> getAllCategoriesEither = Either.right(notFoundResponseFormat);
+        ResponseFormat notFoundResponseFormat = new ResponseFormat(HttpStatus.SC_NOT_FOUND);
+        Either<UiCategories, ResponseFormat> getAllCategoriesEither = Either.right(notFoundResponseFormat);
 
-		when(elementBusinessLogic.getAllCategories(designerUser.getUserId()))
-				.thenReturn(getAllCategoriesEither);
+        when(elementBusinessLogic.getAllCategories(designerUser.getUserId()))
+            .thenReturn(getAllCategoriesEither);
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
-	}
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
+    }
 
-	@Test
-	public void getAllCategoriesExceptionDuringProcessingTest() {
-		String path = "/v1/setup/ui";
-		when(elementBusinessLogic.getAllCategories(designerUser.getUserId()))
-				.thenThrow(new RuntimeException("Test exception: getAllCategories"));
+    @Test
+    void getAllCategoriesExceptionDuringProcessingTest() {
+        String path = "/v1/setup/ui";
+        when(elementBusinessLogic.getAllCategories(designerUser.getUserId()))
+            .thenThrow(new RuntimeException("Test exception: getAllCategories"));
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-	@Test
-	public void getAllCategoriesTest() {
-		String path = "/v1/setup/ui";
-		Either<UiCategories, ResponseFormat> getAllCategoriesEither = Either.left(new UiCategories());
-		Either<List<ArtifactType>, ActionStatus> otherEither = Either.left(new ArrayList<>());
-		when(elementBusinessLogic.getDefaultHeatTimeout()).thenReturn(Either.left(configurationManager.getConfiguration().getHeatArtifactDeploymentTimeout()));
-		when(elementBusinessLogic.getResourceTypesMap()).thenReturn(Either.left(new HashMap<String, String>()));
-		when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
-				.thenReturn(otherEither);
+    @Test
+    void getAllCategoriesTest() {
+        String path = "/v1/setup/ui";
+        Either<UiCategories, ResponseFormat> getAllCategoriesEither = Either.left(new UiCategories());
+        Either<List<ArtifactType>, ActionStatus> otherEither = Either.left(new ArrayList<>());
+        when(elementBusinessLogic.getDefaultHeatTimeout())
+            .thenReturn(Either.left(configurationManager.getConfiguration().getHeatArtifactDeploymentTimeout()));
+        when(elementBusinessLogic.getResourceTypesMap()).thenReturn(Either.left(new HashMap<String, String>()));
+        when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
+            .thenReturn(otherEither);
 
+        when(elementBusinessLogic.getAllCategories(designerUser.getUserId()))
+            .thenReturn(getAllCategoriesEither);
 
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		when(elementBusinessLogic.getAllCategories(designerUser.getUserId()))
-				.thenReturn(getAllCategoriesEither);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+    @Test
+    void createComponentCategoryCreationFailedTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
-	}
+        String formatEndpoint = "/v1/category/{componentType}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void createComponentCategoryCreationFailedTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
+        Either<CategoryDefinition, ResponseFormat> createComponentCategoryEither = Either.right(conflictResponseFormat);
 
-		String formatEndpoint = "/v1/category/{componentType}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        when(elementBusinessLogic.createCategory(any(), eq(componentType), eq(designerUser.getUserId())))
+            .thenReturn(createComponentCategoryEither);
 
-		Either<CategoryDefinition, ResponseFormat> createComponentCategoryEither = Either.right(conflictResponseFormat);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(EMPTY_JSON));
 
-		when(elementBusinessLogic.createCategory(any(), eq(componentType), eq(designerUser.getUserId())))
-				.thenReturn(createComponentCategoryEither);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.post(Entity.json(EMPTY_JSON));
+    @Test
+    void createComponentCategoryExceptionDuringCreationTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
-	}
+        String formatEndpoint = "/v1/category/{componentType}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void createComponentCategoryExceptionDuringCreationTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
+        when(elementBusinessLogic.createCategory(any(), eq(componentType), eq(designerUser.getUserId())))
+            .thenThrow(new RuntimeException("Test exception: createComponentCategory"));
 
-		String formatEndpoint = "/v1/category/{componentType}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(EMPTY_JSON));
 
-		when(elementBusinessLogic.createCategory(any(), eq(componentType), eq(designerUser.getUserId())))
-				.thenThrow(new RuntimeException("Test exception: createComponentCategory"));
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.post(Entity.json(EMPTY_JSON));
+    @Test
+    void createComponentCategoryTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+        String formatEndpoint = "/v1/category/{componentType}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void createComponentCategoryTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
+        Either<CategoryDefinition, ResponseFormat> createComponentCategoryEither = Either
+            .left(new CategoryDefinition());
 
-		String formatEndpoint = "/v1/category/{componentType}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        when(elementBusinessLogic.createCategory(any(), eq(componentType), eq(designerUser.getUserId())))
+            .thenReturn(createComponentCategoryEither);
 
-		Either<CategoryDefinition, ResponseFormat> createComponentCategoryEither = Either.left(new CategoryDefinition());
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(EMPTY_JSON));
 
-		when(elementBusinessLogic.createCategory(any(), eq(componentType), eq(designerUser.getUserId())))
-				.thenReturn(createComponentCategoryEither);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CREATED);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.post(Entity.json(EMPTY_JSON));
+    @Test
+    void deleteComponentCategoryNoCategoryFoundTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryUniqueId = "categoryUniqueId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CREATED);
-	}
+        String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void deleteComponentCategoryNoCategoryFoundTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryUniqueId = "categoryUniqueId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
+        ResponseFormat notFoundResponseFormat = new ResponseFormat(HttpStatus.SC_NOT_FOUND);
+        Either<CategoryDefinition, ResponseFormat> deleteComponentCategoryEither = Either.right(notFoundResponseFormat);
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        when(elementBusinessLogic.deleteCategory(categoryUniqueId, componentType, designerUser.getUserId()))
+            .thenReturn(deleteComponentCategoryEither);
 
-		ResponseFormat notFoundResponseFormat = new ResponseFormat(HttpStatus.SC_NOT_FOUND);
-		Either<CategoryDefinition, ResponseFormat> deleteComponentCategoryEither = Either.right(notFoundResponseFormat);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
 
-		when(elementBusinessLogic.deleteCategory(categoryUniqueId, componentType, designerUser.getUserId()))
-				.thenReturn(deleteComponentCategoryEither);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.delete();
+    @Test
+    void deleteComponentCategoryExceptionDuringProcessingTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryUniqueId = "categoryUniqueId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
-	}
+        String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void deleteComponentCategoryExceptionDuringProcessingTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryUniqueId = "categoryUniqueId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
+        when(elementBusinessLogic.deleteCategory(categoryUniqueId, componentType, designerUser.getUserId()))
+            .thenThrow(new RuntimeException("Test exception: deleteComponentCategory"));
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
 
-		when(elementBusinessLogic.deleteCategory(categoryUniqueId, componentType, designerUser.getUserId()))
-				.thenThrow(new RuntimeException("Test exception: deleteComponentCategory"));
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.delete();
+    @Test
+    void deleteComponentCategoryTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryUniqueId = "categoryUniqueId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+        String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void deleteComponentCategoryTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryUniqueId = "categoryUniqueId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
+        Either<CategoryDefinition, ResponseFormat> deleteComponentCategoryEither = Either
+            .left(new CategoryDefinition());
+        when(elementBusinessLogic.deleteCategory(categoryUniqueId, componentType, designerUser.getUserId()))
+            .thenReturn(deleteComponentCategoryEither);
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
 
-		Either<CategoryDefinition, ResponseFormat> deleteComponentCategoryEither = Either.left(new CategoryDefinition());
-		when(elementBusinessLogic.deleteCategory(categoryUniqueId, componentType, designerUser.getUserId()))
-				.thenReturn(deleteComponentCategoryEither);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.delete();
+    @Test
+    void createComponentSubCategoryCreationFailedTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryId = "categoryId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_ID, categoryId);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
-	}
+        String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void createComponentSubCategoryCreationFailedTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryId = "categoryId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_ID, categoryId);
+        Either<SubCategoryDefinition, ResponseFormat> createComponentSubCategoryEither = Either
+            .right(conflictResponseFormat);
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        when(elementBusinessLogic
+            .createSubCategory(any(), eq(componentType), eq(categoryId), eq(designerUser.getUserId())))
+            .thenReturn(createComponentSubCategoryEither);
 
-		Either<SubCategoryDefinition, ResponseFormat> createComponentSubCategoryEither = Either.right(conflictResponseFormat);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(EMPTY_JSON));
 
-		when(elementBusinessLogic.createSubCategory(any(), eq(componentType), eq(categoryId), eq(designerUser.getUserId())))
-				.thenReturn(createComponentSubCategoryEither);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.post(Entity.json(EMPTY_JSON));
+    @Test
+    void createComponentSubCategoryExceptionDuringCreationTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryId = "categoryId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_ID, categoryId);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
-	}
+        String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void createComponentSubCategoryExceptionDuringCreationTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryId = "categoryId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_ID, categoryId);
+        when(elementBusinessLogic
+            .createSubCategory(any(), eq(componentType), eq(categoryId), eq(designerUser.getUserId())))
+            .thenThrow(new RuntimeException("Test exception: createComponentSubCategory"));
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(EMPTY_JSON));
 
-		when(elementBusinessLogic.createSubCategory(any(), eq(componentType), eq(categoryId), eq(designerUser.getUserId())))
-				.thenThrow(new RuntimeException("Test exception: createComponentSubCategory"));
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.post(Entity.json(EMPTY_JSON));
+    @Test
+    void createComponentSubCategoryTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryId = "categoryId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_ID, categoryId);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+        String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void createComponentSubCategoryTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryId = "categoryId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_ID, categoryId);
+        Either<SubCategoryDefinition, ResponseFormat> createComponentSubCategoryEither = Either
+            .left(new SubCategoryDefinition());
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        when(elementBusinessLogic
+            .createSubCategory(any(), eq(componentType), eq(categoryId), eq(designerUser.getUserId())))
+            .thenReturn(createComponentSubCategoryEither);
 
-		Either<SubCategoryDefinition, ResponseFormat> createComponentSubCategoryEither = Either.left(new SubCategoryDefinition());
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(EMPTY_JSON));
 
-		when(elementBusinessLogic.createSubCategory(any(), eq(componentType), eq(categoryId), eq(designerUser.getUserId())))
-				.thenReturn(createComponentSubCategoryEither);
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CREATED);
+    }
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.post(Entity.json(EMPTY_JSON));
+    @Test
+    void deleteComponentSubCategoryCreationFailedTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryUniqueId = "categoryUniqueId";
+        String subCategoryUniqueId = "subCategoryUniqueId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
+        parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CREATED);
-	}
+        String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-	@Test
-	public void deleteComponentSubCategoryCreationFailedTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryUniqueId = "categoryUniqueId";
-		String subCategoryUniqueId = "subCategoryUniqueId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
-		parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
+        Either<SubCategoryDefinition, ResponseFormat> deleteComponentSubCategoryEither = Either
+            .right(conflictResponseFormat);
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        when(elementBusinessLogic
+            .deleteSubCategory(eq(subCategoryUniqueId), eq(componentType), eq(designerUser.getUserId())))
+            .thenReturn(deleteComponentSubCategoryEither);
 
-		Either<SubCategoryDefinition, ResponseFormat> deleteComponentSubCategoryEither = Either.right(conflictResponseFormat);
-
-		when(elementBusinessLogic.deleteSubCategory(eq(subCategoryUniqueId), eq(componentType), eq(designerUser.getUserId())))
-				.thenReturn(deleteComponentSubCategoryEither);
-
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.delete();
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
-	}
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
+    }
 
-	@Test
-	public void deleteComponentSubCategoryExceptionDuringCreationTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryUniqueId = "categoryUniqueId";
-		String subCategoryUniqueId = "subCategoryUniqueId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
-		parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
+    @Test
+    void deleteComponentSubCategoryExceptionDuringCreationTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryUniqueId = "categoryUniqueId";
+        String subCategoryUniqueId = "subCategoryUniqueId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
+        parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		when(elementBusinessLogic.deleteSubCategory(eq(subCategoryUniqueId), eq(componentType), eq(designerUser.getUserId())))
-				.thenThrow(new RuntimeException("Test exception: deleteComponentSubCategory"));
+        when(elementBusinessLogic
+            .deleteSubCategory(eq(subCategoryUniqueId), eq(componentType), eq(designerUser.getUserId())))
+            .thenThrow(new RuntimeException("Test exception: deleteComponentSubCategory"));
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.delete();
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-	@Test
-	public void deleteComponentSubCategoryTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryUniqueId = "categoryUniqueId";
-		String subCategoryUniqueId = "subCategoryUniqueId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
-		parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
+    @Test
+    void deleteComponentSubCategoryTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryUniqueId = "categoryUniqueId";
+        String subCategoryUniqueId = "subCategoryUniqueId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
+        parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		Either<SubCategoryDefinition, ResponseFormat> deleteComponentSubCategoryEither = Either.left(new SubCategoryDefinition());
+        Either<SubCategoryDefinition, ResponseFormat> deleteComponentSubCategoryEither = Either
+            .left(new SubCategoryDefinition());
 
-		when(elementBusinessLogic.deleteSubCategory(eq(subCategoryUniqueId), eq(componentType), eq(designerUser.getUserId())))
-				.thenReturn(deleteComponentSubCategoryEither);
+        when(elementBusinessLogic
+            .deleteSubCategory(eq(subCategoryUniqueId), eq(componentType), eq(designerUser.getUserId())))
+            .thenReturn(deleteComponentSubCategoryEither);
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.delete();
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
-	}
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
+    }
 
-	@Test
-	public void createComponentGroupingCreationFailedTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryId = "categoryUniqueId";
-		String subCategoryId = "subCategoryId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_ID, categoryId);
-		parametersMap.put(SUB_CATEGORY_ID, subCategoryId);
+    @Test
+    void createComponentGroupingCreationFailedTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryId = "categoryUniqueId";
+        String subCategoryId = "subCategoryId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_ID, categoryId);
+        parametersMap.put(SUB_CATEGORY_ID, subCategoryId);
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory/{subCategoryId}/grouping";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory/{subCategoryId}/grouping";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		Either<GroupingDefinition, ResponseFormat> createComponentGroupingEither = Either.right(conflictResponseFormat);
+        Either<GroupingDefinition, ResponseFormat> createComponentGroupingEither = Either.right(conflictResponseFormat);
 
-		when(elementBusinessLogic.createGrouping(any(), eq(componentType), eq(categoryId), eq(subCategoryId), eq(designerUser.getUserId())))
-				.thenReturn(createComponentGroupingEither);
+        when(elementBusinessLogic
+            .createGrouping(any(), eq(componentType), eq(categoryId), eq(subCategoryId), eq(designerUser.getUserId())))
+            .thenReturn(createComponentGroupingEither);
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.post(Entity.json(EMPTY_JSON));
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(EMPTY_JSON));
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
-	}
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
+    }
 
-	@Test
-	public void createComponentGroupingExceptionDuringCreationTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryId = "categoryUniqueId";
-		String subCategoryId = "subCategoryId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_ID, categoryId);
-		parametersMap.put(SUB_CATEGORY_ID, subCategoryId);
+    @Test
+    void createComponentGroupingExceptionDuringCreationTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryId = "categoryUniqueId";
+        String subCategoryId = "subCategoryId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_ID, categoryId);
+        parametersMap.put(SUB_CATEGORY_ID, subCategoryId);
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory/{subCategoryId}/grouping";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory/{subCategoryId}/grouping";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
+        when(elementBusinessLogic
+            .createGrouping(any(), eq(componentType), eq(categoryId), eq(subCategoryId), eq(designerUser.getUserId())))
+            .thenThrow(new RuntimeException("Test exception: createComponentGrouping"));
 
-		when(elementBusinessLogic.createGrouping(any(), eq(componentType), eq(categoryId), eq(subCategoryId), eq(designerUser.getUserId())))
-				.thenThrow(new RuntimeException("Test exception: createComponentGrouping"));
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(EMPTY_JSON));
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.post(Entity.json(EMPTY_JSON));
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+    @Test
+    void createComponentGroupingTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryId = "categoryUniqueId";
+        String subCategoryId = "subCategoryId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_ID, categoryId);
+        parametersMap.put(SUB_CATEGORY_ID, subCategoryId);
 
-	@Test
-	public void createComponentGroupingTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryId = "categoryUniqueId";
-		String subCategoryId = "subCategoryId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_ID, categoryId);
-		parametersMap.put(SUB_CATEGORY_ID, subCategoryId);
+        String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory/{subCategoryId}/grouping";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryId}/subCategory/{subCategoryId}/grouping";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        Either<GroupingDefinition, ResponseFormat> createComponentGroupingEither = Either
+            .left(new GroupingDefinition());
 
-		Either<GroupingDefinition, ResponseFormat> createComponentGroupingEither = Either.left(new GroupingDefinition());
+        when(elementBusinessLogic
+            .createGrouping(any(), eq(componentType), eq(categoryId), eq(subCategoryId), eq(designerUser.getUserId())))
+            .thenReturn(createComponentGroupingEither);
 
-		when(elementBusinessLogic.createGrouping(any(), eq(componentType), eq(categoryId), eq(subCategoryId), eq(designerUser.getUserId())))
-				.thenReturn(createComponentGroupingEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .post(Entity.json(EMPTY_JSON));
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.post(Entity.json(EMPTY_JSON));
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CREATED);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CREATED);
-	}
+    @Test
+    void deleteComponentGroupingCreationFailedTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryUniqueId = "categoryUniqueId";
+        String subCategoryUniqueId = "subCategoryUniqueId";
+        String groupingUniqueId = "groupingUniqueId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
+        parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
+        parametersMap.put(GROUPING_UNIQUE_ID, groupingUniqueId);
 
-	@Test
-	public void deleteComponentGroupingCreationFailedTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryUniqueId = "categoryUniqueId";
-		String subCategoryUniqueId = "subCategoryUniqueId";
-		String groupingUniqueId = "groupingUniqueId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
-		parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
-		parametersMap.put(GROUPING_UNIQUE_ID, groupingUniqueId);
+        String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}/grouping/{groupingUniqueId}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}/grouping/{groupingUniqueId}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        Either<GroupingDefinition, ResponseFormat> deleteComponentGroupingEither = Either.right(conflictResponseFormat);
 
-		Either<GroupingDefinition, ResponseFormat> deleteComponentGroupingEither = Either.right(conflictResponseFormat);
+        when(elementBusinessLogic.deleteGrouping(eq(groupingUniqueId), eq(componentType), eq(designerUser.getUserId())))
+            .thenReturn(deleteComponentGroupingEither);
 
-		when(elementBusinessLogic.deleteGrouping(eq(groupingUniqueId), eq(componentType), eq(designerUser.getUserId())))
-				.thenReturn(deleteComponentGroupingEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.delete();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CONFLICT);
-	}
+    @Test
+    void deleteComponentGroupingExceptionDuringCreationTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryUniqueId = "categoryUniqueId";
+        String subCategoryUniqueId = "subCategoryUniqueId";
+        String groupingUniqueId = "groupingUniqueId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
+        parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
+        parametersMap.put(GROUPING_UNIQUE_ID, groupingUniqueId);
 
-	@Test
-	public void deleteComponentGroupingExceptionDuringCreationTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryUniqueId = "categoryUniqueId";
-		String subCategoryUniqueId = "subCategoryUniqueId";
-		String groupingUniqueId = "groupingUniqueId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
-		parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
-		parametersMap.put(GROUPING_UNIQUE_ID, groupingUniqueId);
+        String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}/grouping/{groupingUniqueId}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}/grouping/{groupingUniqueId}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        when(elementBusinessLogic.deleteGrouping(eq(groupingUniqueId), eq(componentType), eq(designerUser.getUserId())))
+            .thenThrow(new RuntimeException("Test exception: deleteComponentGrouping"));
 
-		when(elementBusinessLogic.deleteGrouping(eq(groupingUniqueId), eq(componentType), eq(designerUser.getUserId())))
-				.thenThrow(new RuntimeException("Test exception: deleteComponentGrouping"));
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.delete();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+    @Test
+    void deleteComponentGroupingTest() {
+        String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
+        String categoryUniqueId = "categoryUniqueId";
+        String subCategoryUniqueId = "subCategoryUniqueId";
+        String groupingUniqueId = "groupingUniqueId";
+        Map<String, String> parametersMap = new HashMap<>();
+        parametersMap.put(COMPONENT_TYPE, componentType);
+        parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
+        parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
+        parametersMap.put(GROUPING_UNIQUE_ID, groupingUniqueId);
 
-	@Test
-	public void deleteComponentGroupingTest() {
-		String componentType = ComponentTypeEnum.SERVICE_PARAM_NAME;
-		String categoryUniqueId = "categoryUniqueId";
-		String subCategoryUniqueId = "subCategoryUniqueId";
-		String groupingUniqueId = "groupingUniqueId";
-		Map<String,String> parametersMap = new HashMap<>();
-		parametersMap.put(COMPONENT_TYPE, componentType);
-		parametersMap.put(CATEGORY_UNIQUE_ID, categoryUniqueId);
-		parametersMap.put(SUB_CATEGORY_UNIQUE_ID, subCategoryUniqueId);
-		parametersMap.put(GROUPING_UNIQUE_ID, groupingUniqueId);
+        String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}/grouping/{groupingUniqueId}";
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
-		String formatEndpoint = "/v1/category/{componentType}/{categoryUniqueId}/subCategory/{subCategoryUniqueId}/grouping/{groupingUniqueId}";
-		String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        Either<GroupingDefinition, ResponseFormat> deleteComponentGroupingEither = Either
+            .left(new GroupingDefinition());
 
-		Either<GroupingDefinition, ResponseFormat> deleteComponentGroupingEither = Either.left(new GroupingDefinition());
+        when(elementBusinessLogic.deleteGrouping(eq(groupingUniqueId), eq(componentType), eq(designerUser.getUserId())))
+            .thenReturn(deleteComponentGroupingEither);
 
-		when(elementBusinessLogic.deleteGrouping(eq(groupingUniqueId), eq(componentType), eq(designerUser.getUserId())))
-				.thenReturn(deleteComponentGroupingEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .delete();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.delete();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
-	}
+    @Test
+    void tagsNoTagsFoundTest() {
+        String path = "/v1/tags";
+        Either<List<Tag>, ActionStatus> tagsEither = Either.right(ActionStatus.NO_CONTENT);
 
-	@Test
-	public void tagsNoTagsFoundTest() {
-		String path = "/v1/tags";
-		Either<List<Tag>, ActionStatus> tagsEither = Either.right(ActionStatus.NO_CONTENT);
+        when(elementBusinessLogic.getAllTags(designerUser.getUserId()))
+            .thenReturn(tagsEither);
 
-		when(elementBusinessLogic.getAllTags(designerUser.getUserId()))
-				.thenReturn(tagsEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
-	}
+    @Test
+    void tagsExceptionDuringProcessingTest() {
+        String path = "/v1/tags";
+        when(elementBusinessLogic.getAllTags(designerUser.getUserId()))
+            .thenThrow(new RuntimeException("Test exception: tags"));
 
-	@Test
-	public void tagsExceptionDuringProcessingTest() {
-		String path = "/v1/tags";
-		when(elementBusinessLogic.getAllTags(designerUser.getUserId()))
-				.thenThrow(new RuntimeException("Test exception: tags"));
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+    @Test
+    void tagsTest() {
+        String path = "/v1/tags";
+        Either<List<Tag>, ActionStatus> tagsEither = Either.left(new ArrayList<>());
+        when(elementBusinessLogic.getAllTags(designerUser.getUserId()))
+            .thenReturn(tagsEither);
 
-	@Test
-	public void tagsTest() {
-		String path = "/v1/tags";
-		Either<List<Tag>, ActionStatus> tagsEither = Either.left(new ArrayList<>());
-		when(elementBusinessLogic.getAllTags(designerUser.getUserId()))
-				.thenReturn(tagsEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
-	}
+    @Test
+    void propertyScopesNoPropertyScopesFoundTest() {
+        String path = "/v1/propertyScopes";
+        Either<List<PropertyScope>, ActionStatus> propertyScopesEither = Either.right(ActionStatus.NO_CONTENT);
 
-	@Test
-	public void propertyScopesNoPropertyScopesFoundTest() {
-		String path = "/v1/propertyScopes";
-		Either<List<PropertyScope>, ActionStatus> propertyScopesEither = Either.right(ActionStatus.NO_CONTENT);
+        when(elementBusinessLogic.getAllPropertyScopes(designerUser.getUserId()))
+            .thenReturn(propertyScopesEither);
 
-		when(elementBusinessLogic.getAllPropertyScopes(designerUser.getUserId()))
-				.thenReturn(propertyScopesEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
-	}
+    @Test
+    void propertyScopesExceptionDuringProcessingTest() {
+        String path = "/v1/propertyScopes";
+        when(elementBusinessLogic.getAllPropertyScopes(designerUser.getUserId()))
+            .thenThrow(new RuntimeException("Test exception: propertyScopes"));
 
-	@Test
-	public void propertyScopesExceptionDuringProcessingTest() {
-		String path = "/v1/propertyScopes";
-		when(elementBusinessLogic.getAllPropertyScopes(designerUser.getUserId()))
-				.thenThrow(new RuntimeException("Test exception: propertyScopes"));
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+    @Test
+    void propertyScopesTest() {
+        String path = "/v1/propertyScopes";
+        Either<List<PropertyScope>, ActionStatus> propertyScopesEither = Either.left(new ArrayList<>());
+        when(elementBusinessLogic.getAllPropertyScopes(designerUser.getUserId()))
+            .thenReturn(propertyScopesEither);
 
-	@Test
-	public void propertyScopesTest() {
-		String path = "/v1/propertyScopes";
-		Either<List<PropertyScope>, ActionStatus> propertyScopesEither = Either.left(new ArrayList<>());
-		when(elementBusinessLogic.getAllPropertyScopes(designerUser.getUserId()))
-				.thenReturn(propertyScopesEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
-	}
+    @Test
+    void artifactTypesNoartifactTypesFoundTest() {
+        String path = "/v1/artifactTypes";
+        Either<List<ArtifactType>, ActionStatus> artifactTypesEither = Either.right(ActionStatus.NO_CONTENT);
 
-	@Test
-	public void artifactTypesNoartifactTypesFoundTest() {
-		String path = "/v1/artifactTypes";
-		Either<List<ArtifactType>, ActionStatus> artifactTypesEither = Either.right(ActionStatus.NO_CONTENT);
+        when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
+            .thenReturn(artifactTypesEither);
 
-		when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
-				.thenReturn(artifactTypesEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
-	}
+    @Test
+    void artifactTypesExceptionDuringProcessingTest() {
+        String path = "/v1/artifactTypes";
+        when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
+            .thenThrow(new RuntimeException("Test exception: artifactTypes"));
 
-	@Test
-	public void artifactTypesExceptionDuringProcessingTest() {
-		String path = "/v1/artifactTypes";
-		when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
-				.thenThrow(new RuntimeException("Test exception: artifactTypes"));
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+    @Test
+    void artifactTypesTest() {
+        String path = "/v1/artifactTypes";
+        Either<List<ArtifactType>, ActionStatus> artifactTypesEither = Either.left(new ArrayList<>());
+        when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
+            .thenReturn(artifactTypesEither);
 
-	@Test
-	public void artifactTypesTest() {
-		String path = "/v1/artifactTypes";
-		Either<List<ArtifactType>, ActionStatus> artifactTypesEither = Either.left(new ArrayList<>());
-		when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
-				.thenReturn(artifactTypesEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
-	}
+    @Test
+    void configurationNoConfigurationFoundTest() {
+        String path = "/v1/setup/ui";
 
-	@Test
-	public void configurationNoConfigurationFoundTest() {
-		String path = "/v1/setup/ui";
+        Either<List<ArtifactType>, ActionStatus> otherEither = Either.left(new ArrayList<>());
+        Configuration.HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new Configuration.HeatDeploymentArtifactTimeout();
+        heatDeploymentArtifactTimeout.setDefaultMinutes(1);
+        Either<Configuration.HeatDeploymentArtifactTimeout, ActionStatus> defaultHeatTimeoutEither = Either
+            .left(heatDeploymentArtifactTimeout);
+        Either<Map<String, String>, ActionStatus> resourceTypesMapEither = Either.left(new HashMap<>());
 
-		Either<List<ArtifactType>, ActionStatus> otherEither = Either.left(new ArrayList<>());
-		Configuration.HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new Configuration.HeatDeploymentArtifactTimeout();
-		heatDeploymentArtifactTimeout.setDefaultMinutes(1);
-		Either<Configuration.HeatDeploymentArtifactTimeout, ActionStatus> defaultHeatTimeoutEither = Either.left(heatDeploymentArtifactTimeout);
-		Either<Map<String, String>, ActionStatus> resourceTypesMapEither = Either.left(new HashMap<>());
+        when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
+            .thenReturn(otherEither);
+        when(elementBusinessLogic.getDefaultHeatTimeout())
+            .thenReturn(defaultHeatTimeoutEither);
+        when(elementBusinessLogic.getResourceTypesMap())
+            .thenReturn(resourceTypesMapEither);
 
-		when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
-				.thenReturn(otherEither);
-		when(elementBusinessLogic.getDefaultHeatTimeout())
-				.thenReturn(defaultHeatTimeoutEither);
-		when(elementBusinessLogic.getResourceTypesMap())
-				.thenReturn(resourceTypesMapEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+    @Test
+    void configurationExceptionDuringProcessingTest() {
+        String path = "/v1/setup/ui";
+        when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
+            .thenThrow(new RuntimeException("Test exception: artifactTypes"));
 
-	@Test
-	public void configurationExceptionDuringProcessingTest() {
-		String path = "/v1/setup/ui";
-		when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId()))
-				.thenThrow(new RuntimeException("Test exception: artifactTypes"));
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+    @Test
+    void screenNoCatalogComponentsFoundTest() {
+        String path = "/v1/screen";
 
-	@Test
-	public void screenNoCatalogComponentsFoundTest() {
-		String path = "/v1/screen";
+        Either<Map<String, List<CatalogComponent>>, ResponseFormat> screenEither = Either
+            .right(badRequestResponseFormat);
+        when(elementBusinessLogic.getCatalogComponents(eq(designerUser.getUserId()), any()))
+            .thenReturn(screenEither);
 
-		Either<Map<String, List<CatalogComponent>>, ResponseFormat> screenEither = Either.right(badRequestResponseFormat);
-		when(elementBusinessLogic.getCatalogComponents(eq(designerUser.getUserId()), any()))
-				.thenReturn(screenEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
-	}
+    @Test
+    void screenExceptionDuringProcessingTest() {
+        String path = "/v1/screen";
 
-	@Test
-	public void screenExceptionDuringProcessingTest() {
-		String path = "/v1/screen";
+        when(elementBusinessLogic.getCatalogComponents(eq(designerUser.getUserId()), any()))
+            .thenThrow(new RuntimeException("Test exception: screen"));
 
-		when(elementBusinessLogic.getCatalogComponents(eq(designerUser.getUserId()), any()))
-				.thenThrow(new RuntimeException("Test exception: screen"));
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-	}
+    @Test
+    void screenTest() {
+        String path = "/v1/screen";
 
-	@Test
-	public void screenTest() {
-		String path = "/v1/screen";
+        Either<Map<String, List<CatalogComponent>>, ResponseFormat> screenEither = Either.left(new HashMap<>());
+        when(elementBusinessLogic.getCatalogComponents(eq(designerUser.getUserId()), any()))
+            .thenReturn(screenEither);
 
-		Either<Map<String, List<CatalogComponent>>, ResponseFormat> screenEither = Either.left(new HashMap<>());
-		when(elementBusinessLogic.getCatalogComponents(eq(designerUser.getUserId()), any()))
-				.thenReturn(screenEither);
+        Response response = target()
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+            .get();
 
-		Response response = target()
-				.path(path)
-				.request()
-				.accept(MediaType.APPLICATION_JSON)
-				.header(Constants.USER_ID_HEADER, designerUser.getUserId())
-				.get();
+        assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
+    }
 
-		assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
-	}
-	
-	@Override
-	protected Application configure() {
-		ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
+    @Override
+    protected Application configure() {
+        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
 		forceSet(TestProperties.CONTAINER_PORT, "0");
-		return new ResourceConfig(ElementServlet.class)
-				.register(new AbstractBinder() {
+        return new ResourceConfig(ElementServlet.class)
+            .register(new AbstractBinder() {
 
-					@Override
-					protected void configure() {
-						bind(request).to(HttpServletRequest.class);
-						bind(userBusinessLogic).to(UserBusinessLogic.class);
-						bind(componentUtils).to(ComponentsUtils.class);
-						bind(componentsCleanBusinessLogic).to(ComponentsCleanBusinessLogic.class);
-						bind(elementBusinessLogic).to(ElementBusinessLogic.class);
-						bind(artifactsBusinessLogic).to(ArtifactsBusinessLogic.class);
-					}
-				})
-				.property("contextConfig", context);
-	}
+                @Override
+                protected void configure() {
+                    bind(request).to(HttpServletRequest.class);
+                    bind(userBusinessLogic).to(UserBusinessLogic.class);
+                    bind(componentUtils).to(ComponentsUtils.class);
+                    bind(componentsCleanBusinessLogic).to(ComponentsCleanBusinessLogic.class);
+                    bind(elementBusinessLogic).to(ElementBusinessLogic.class);
+                    bind(artifactsBusinessLogic).to(ArtifactsBusinessLogic.class);
+                }
+            })
+            .property("contextConfig", context);
+    }
 }
\ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ExceptionHandlerEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ExceptionHandlerEndpointTest.java
index 34ff686..cdd5965 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ExceptionHandlerEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ExceptionHandlerEndpointTest.java
@@ -20,27 +20,28 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import com.fasterxml.jackson.databind.DeserializationFeature;
+import javax.ws.rs.core.Response;
 import org.apache.http.HttpStatus;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
 import org.openecomp.sdc.exception.ResponseFormat;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Import;
 
-import javax.ws.rs.core.Response;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ExceptionHandlerEndpointTest extends JerseySpringBaseTest {
+class ExceptionHandlerEndpointTest extends JerseySpringBaseTest {
 
     private static ComponentsUtils componentUtils;
 
@@ -54,10 +55,20 @@
         }
     }
 
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
+
     @Override
     protected void configureClient(ClientConfig config) {
         final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
-                .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         config.register(jacksonJsonProvider);
     }
 
@@ -67,12 +78,13 @@
         componentUtils = mock(ComponentsUtils.class);
 
         return super.configure(ExceptionHandlerConfig.class)
-                .register(ExceptionHandlerEndpoint.class);
+            .register(ExceptionHandlerEndpoint.class);
     }
 
     @Test
-    public void getHandleException() {
-        when(componentUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR));
+    void getHandleException() {
+        when(componentUtils.getResponseFormat(ActionStatus.GENERAL_ERROR))
+            .thenReturn(new ResponseFormat(HttpStatus.SC_INTERNAL_SERVER_ERROR));
         Response response = target().path("/v1/catalog/handleException").request().get(Response.class);
         assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
     }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupEndpointTest.java
index 957fba2..c7886e3 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupEndpointTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,8 +20,28 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.anyList;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.be.model.operations.api.StorageOperationStatus.NOT_FOUND;
+
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.assertj.core.api.AssertionsForClassTypes;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
@@ -29,9 +49,10 @@
 import org.glassfish.jersey.logging.LoggingFeature;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.openecomp.sdc.be.components.impl.GroupBusinessLogicNew;
@@ -60,28 +81,7 @@
 import org.springframework.context.annotation.Import;
 import org.springframework.http.HttpStatus;
 
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.Mockito.anyList;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.openecomp.sdc.be.model.operations.api.StorageOperationStatus.NOT_FOUND;
-
-public class GroupEndpointTest extends JerseySpringBaseTest {
+class GroupEndpointTest extends JerseySpringBaseTest {
 
     private static final String VALID_USER = "ab001";
     private static final String INVALID_USER = "ab002";
@@ -119,11 +119,12 @@
         }
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void initClass() {
         ExternalConfiguration.setAppName("catalog-be");
         String appConfigDir = "src/test/resources/config/catalog-be";
-        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+            appConfigDir);
         ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
         //ComponentsUtils needs configuration singleton to be set
         componentValidations = mock(ComponentValidations.class);
@@ -136,7 +137,7 @@
     @Override
     protected void configureClient(ClientConfig config) {
         final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
-                .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         config.register(jacksonJsonProvider);
     }
 
@@ -144,12 +145,13 @@
     protected ResourceConfig configure() {
         forceSet(TestProperties.CONTAINER_PORT, "0");
         return super.configure(GroupEndpointTestConfig.class)
-                .register(GroupEndpoint.class)
-                .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, "WARNING");
+            .register(GroupEndpoint.class)
+            .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, "WARNING");
     }
 
-    @Before
-    public void init() {
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
         cr = new Resource();
         cr.setSystemName("CR1");
         g1 = new GroupDefinition();
@@ -167,20 +169,33 @@
         unhappyScenarioSetup();
     }
 
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
+
     private void unhappyScenarioSetup() {
-        when(accessValidations.validateUserCanWorkOnComponent(eq(INVALID_COMPONENT_ID), eq(ComponentTypeEnum.RESOURCE), eq(VALID_USER), anyString())).thenThrow(new StorageException(NOT_FOUND, INVALID_COMPONENT_ID));
+        when(accessValidations
+            .validateUserCanWorkOnComponent(eq(INVALID_COMPONENT_ID), eq(ComponentTypeEnum.RESOURCE), eq(VALID_USER),
+                anyString())).thenThrow(new StorageException(NOT_FOUND, INVALID_COMPONENT_ID));
         when(componentValidations.getComponentInstance(cr, A)).thenReturn(Optional.of(ci));
     }
 
-
     private void happyScenarioSetup() {
-        when(accessValidations.validateUserCanWorkOnComponent(eq(VALID_COMPONENT_ID), any(ComponentTypeEnum.class), eq(VALID_USER), anyString())).thenReturn(cr);
-        when(accessValidations.validateUserCanRetrieveComponentData(eq(VALID_COMPONENT_ID), eq("resources"), eq(VALID_USER), anyString()))
-                .thenReturn(cr);
+        when(accessValidations
+            .validateUserCanWorkOnComponent(eq(VALID_COMPONENT_ID), any(ComponentTypeEnum.class), eq(VALID_USER),
+                anyString())).thenReturn(cr);
+        when(accessValidations
+            .validateUserCanRetrieveComponentData(eq(VALID_COMPONENT_ID), eq("resources"), eq(VALID_USER), anyString()))
+            .thenReturn(cr);
         when(componentValidations.getComponentInstance(cr, A)).thenReturn(Optional.of(ci));
-        doNothing().when(groupsOperation).updateGroupOnComponent(eq(VALID_COMPONENT_ID), isA(GroupDefinition.class), any(PromoteVersionEnum.class));
-        when(groupOperation.validateAndUpdatePropertyValue(isA(GroupProperty.class))).thenReturn(StorageOperationStatus.OK);
-        when(groupsOperation.updateGroupPropertiesOnComponent(eq(VALID_COMPONENT_ID), isA(GroupDefinition.class), anyList(), any(PromoteVersionEnum.class))).thenAnswer(new Answer<Either>() {
+        doNothing().when(groupsOperation)
+            .updateGroupOnComponent(eq(VALID_COMPONENT_ID), isA(GroupDefinition.class), any(PromoteVersionEnum.class));
+        when(groupOperation.validateAndUpdatePropertyValue(isA(GroupProperty.class)))
+            .thenReturn(StorageOperationStatus.OK);
+        when(groupsOperation
+            .updateGroupPropertiesOnComponent(eq(VALID_COMPONENT_ID), isA(GroupDefinition.class), anyList(),
+                any(PromoteVersionEnum.class))).thenAnswer(new Answer<Either>() {
             @Override
             public Either answer(InvocationOnMock invocationOnMock) throws Throwable {
                 Object[] args = invocationOnMock.getArguments();
@@ -190,44 +205,44 @@
     }
 
     @Test
-    public void updateGroupMembers_success() {
+    void updateGroupMembers_success() {
         List<String> ids = Arrays.asList(A);
         List<String> updatedIds = buildUpdateGroupMembersCall(VALID_COMPONENT_ID, VALID_GROUP_ID, VALID_USER)
-                .post(Entity.entity(ids, MediaType.APPLICATION_JSON), new GenericType<List<String>>() {
-                });
+            .post(Entity.entity(ids, MediaType.APPLICATION_JSON), new GenericType<List<String>>() {
+            });
         assertThat(updatedIds.size()).isEqualTo(ids.size());
         assertThat(updatedIds).containsExactlyInAnyOrder(ids.toArray(new String[ids.size()]));
     }
 
     @Test
-    public void updateGroupMembersWith2IdenticalMembers_success() {
+    void updateGroupMembersWith2IdenticalMembers_success() {
         List<String> ids = Arrays.asList(A, A);
         List<String> updatedIds = buildUpdateGroupMembersCall(VALID_COMPONENT_ID, VALID_GROUP_ID, VALID_USER)
-                .post(Entity.entity(ids, MediaType.APPLICATION_JSON), new GenericType<List<String>>() {
-                });
+            .post(Entity.entity(ids, MediaType.APPLICATION_JSON), new GenericType<List<String>>() {
+            });
         assertThat(updatedIds.size()).isEqualTo(1);
         assertThat(updatedIds).containsExactlyInAnyOrder(String.valueOf(A));
     }
 
     @Test
-    public void updateGroupMembersWithEmptyList_success() {
+    void updateGroupMembersWithEmptyList_success() {
         List<String> ids = new ArrayList<>();
         List<String> updatedIds = buildUpdateGroupMembersCall(VALID_COMPONENT_ID, VALID_GROUP_ID, VALID_USER)
-                .post(Entity.entity(ids, MediaType.APPLICATION_JSON), new GenericType<List<String>>() {
-                });
-        assertThat(updatedIds.size()).isEqualTo(0);
+            .post(Entity.entity(ids, MediaType.APPLICATION_JSON), new GenericType<List<String>>() {
+            });
+        assertThat(updatedIds.size()).isZero();
     }
 
     @Test
-    public void updateGroupMember_InvalidComponentId_failure() {
+    void updateGroupMember_InvalidComponentId_failure() {
         List<String> ids = new ArrayList<>();
         Response response = buildUpdateGroupMembersCall(INVALID_COMPONENT_ID, VALID_GROUP_ID, VALID_USER)
-                .post(Entity.entity(ids, MediaType.APPLICATION_JSON), Response.class);
+            .post(Entity.entity(ids, MediaType.APPLICATION_JSON), Response.class);
         AssertionsForClassTypes.assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
     }
 
     @Test
-    public void updateGroupProperty_success() {
+    void updateGroupProperty_success() {
         GroupProperty property = new GroupProperty();
         property.setValue("value1");
         property.setName("prop");
@@ -239,31 +254,33 @@
 //                });
 //        assertThat(updatedProperties.size()).isEqualTo(1);
         Response response = buildUpdateGroupPropertiesCall(VALID_COMPONENT_ID, VALID_GROUP_ID, VALID_USER)
-                .put(Entity.entity(propertyStr, MediaType.APPLICATION_JSON));
+            .put(Entity.entity(propertyStr, MediaType.APPLICATION_JSON));
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
     }
 
     @Test
-    public void getGroupProperties_success() {
-        List<PropertyDataDefinition> properties = buildUpdateGroupPropertiesCall(VALID_COMPONENT_ID, VALID_GROUP_ID, VALID_USER)
-                .get(new GenericType<List<PropertyDataDefinition>>(){});
+    void getGroupProperties_success() {
+        List<PropertyDataDefinition> properties = buildUpdateGroupPropertiesCall(VALID_COMPONENT_ID, VALID_GROUP_ID,
+            VALID_USER)
+            .get(new GenericType<List<PropertyDataDefinition>>() {
+            });
         assertThat(properties.size()).isEqualTo(1);
         assertThat(properties.get(0).getValue()).isEqualTo(OLD_VALUE);
     }
 
     private Invocation.Builder buildUpdateGroupMembersCall(String componentId, String groupId, String userId) {
         return target("/v1/catalog/resources/" + componentId + "/groups/" + groupId + "/members")
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, userId);
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, userId);
     }
 
     private Invocation.Builder buildUpdateGroupPropertiesCall(String componentId, String groupId, String userId) {
         return target("/v1/catalog/resources/" + componentId + "/groups/" + groupId + "/properties")
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, userId);
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, userId);
     }
-	
+
 
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java
index 00e7768..1e4e56c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,18 +20,34 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
 import fj.data.Either;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Stream;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openecomp.sdc.be.components.impl.GroupTypeBusinessLogic;
 import org.openecomp.sdc.be.components.utils.GroupTypeBuilder;
 import org.openecomp.sdc.be.components.validation.UserValidations;
@@ -58,23 +74,7 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Import;
 
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Stream;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class GroupTypesEndpointTest extends JerseySpringBaseTest {
+class GroupTypesEndpointTest extends JerseySpringBaseTest {
 
     private static final String USER_ID = "a001";
     private static final GroupTypeDefinition EMPTY_GROUP_TYPE = new GroupTypeDefinition();
@@ -92,7 +92,8 @@
     private static OperationUtils operationUtils;
     private static User user;
 
-    static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
+    static ConfigurationSource configurationSource = new FSConfigurationSource(
+        ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
     static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
 
     @org.springframework.context.annotation.Configuration
@@ -113,11 +114,12 @@
 
         @Bean
         GroupTypeOperation groupTypeOperation() {
-            return new GroupTypeOperation(janusGraphGenericDao, propertyOperation, capabilityTypeOperation, capabilityOperation, derivedFromOperation, operationUtils);
+            return new GroupTypeOperation(janusGraphGenericDao, propertyOperation, capabilityTypeOperation,
+                capabilityOperation, derivedFromOperation, operationUtils);
         }
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void initClass() {
         componentsUtils = mock(ComponentsUtils.class);
         propertyOperation = mock(PropertyOperation.class);
@@ -129,15 +131,24 @@
         user = mock(User.class);
     }
 
-    @Before
-    public void init() {
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
         when(userValidations.validateUserExists(eq(USER_ID))).thenReturn(user);
-        when(janusGraphGenericDao.getByCriteriaWithPredicate(eq(NodeTypeEnum.GroupType), any(), eq(GroupTypeData.class))).thenReturn(Either.left(buildGroupTypeDataList()));
+        when(
+            janusGraphGenericDao.getByCriteriaWithPredicate(eq(NodeTypeEnum.GroupType), any(), eq(GroupTypeData.class)))
+            .thenReturn(Either.left(buildGroupTypeDataList()));
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
     }
 
     @Override
     protected void configureClient(ClientConfig config) {
-        final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         config.register(jacksonJsonProvider);
     }
 
@@ -145,81 +156,88 @@
     protected ResourceConfig configure() {
         forceSet(TestProperties.CONTAINER_PORT, "0");
         return super.configure(GroupTypesTestConfig.class)
-                .register(GroupTypesEndpoint.class);
+            .register(GroupTypesEndpoint.class);
     }
 
     @Test
-    public void verifyExclusionMapIsCaseInsensitive() {
-        Map<String, Set<String>> excludedGroupTypesMapping = configurationManager.getConfiguration().getExcludedGroupTypesMapping();
-        assertThat(excludedGroupTypesMapping.get(COMPONENT_TYPE)).hasSameElementsAs(excludedGroupTypesMapping.get(COMPONENT_TYPE.toLowerCase()));
+    void verifyExclusionMapIsCaseInsensitive() {
+        Map<String, Set<String>> excludedGroupTypesMapping = configurationManager.getConfiguration()
+            .getExcludedGroupTypesMapping();
+        assertThat(excludedGroupTypesMapping.get(COMPONENT_TYPE))
+            .hasSameElementsAs(excludedGroupTypesMapping.get(COMPONENT_TYPE.toLowerCase()));
     }
 
     @Test
-    public void getGroupTypes_validUser_Success() {
+    void getGroupTypes_validUser_Success() {
         List<GroupTypeDefinition> testConfigGroupTypes = buildGroupTypesList();
-        List<GroupTypeDefinition> fetchedGroupTypes = buildGetGroupTypesCall(USER_ID, COMPONENT_TYPE).get(new GenericType<List<GroupTypeDefinition>>(){});
+        List<GroupTypeDefinition> fetchedGroupTypes = buildGetGroupTypesCall(USER_ID, COMPONENT_TYPE)
+            .get(new GenericType<List<GroupTypeDefinition>>() {
+            });
         verifyGroupTypesList(testConfigGroupTypes, fetchedGroupTypes);
     }
 
     @Test
-    public void getGroupTypes_whenNoInteranlComponentType_passEmptyAsExcludedTypes() {
+    void getGroupTypes_whenNoInteranlComponentType_passEmptyAsExcludedTypes() {
         List<GroupTypeDefinition> testConfigGroupTypes = buildGroupTypesList();
-        List<GroupTypeDefinition> fetchedGroupTypes = buildGetGroupTypesCallNoInternalComponent(USER_ID).get(new GenericType<List<GroupTypeDefinition>>(){});
+        List<GroupTypeDefinition> fetchedGroupTypes = buildGetGroupTypesCallNoInternalComponent(USER_ID)
+            .get(new GenericType<List<GroupTypeDefinition>>() {
+            });
         verifyGroupTypesList(testConfigGroupTypes, fetchedGroupTypes);
     }
 
-    private void verifyGroupTypesList(List<GroupTypeDefinition> groupTypes, List<GroupTypeDefinition> fetchedGroupTypes) {
+    private void verifyGroupTypesList(List<GroupTypeDefinition> groupTypes,
+                                      List<GroupTypeDefinition> fetchedGroupTypes) {
         String[] expectedReturnFields = {"version", "type", "uniqueId", "name", "icon"};
         assertThat(fetchedGroupTypes)
-                .usingElementComparatorOnFields(expectedReturnFields)
-                .isEqualTo(groupTypes);
+            .usingElementComparatorOnFields(expectedReturnFields)
+            .isEqualTo(groupTypes);
         verifyOnlySpecificFieldsInResponse(fetchedGroupTypes, expectedReturnFields);
     }
 
-    private void verifyOnlySpecificFieldsInResponse(List<GroupTypeDefinition> fetchedGroupTypes, String ... fields) {
+    private void verifyOnlySpecificFieldsInResponse(List<GroupTypeDefinition> fetchedGroupTypes, String... fields) {
         assertThat(fetchedGroupTypes)
-                .usingElementComparatorIgnoringFields(fields)
-                .containsOnly(EMPTY_GROUP_TYPE);
+            .usingElementComparatorIgnoringFields(fields)
+            .containsOnly(EMPTY_GROUP_TYPE);
     }
 
     private Invocation.Builder buildGetGroupTypesCall(String userId, String componentType) {
         return target("/v1/catalog/groupTypes")
-                .queryParam("internalComponentType", componentType)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, userId);
+            .queryParam("internalComponentType", componentType)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, userId);
     }
 
     private Invocation.Builder buildGetGroupTypesCallNoInternalComponent(String userId) {
         return target("/v1/catalog/groupTypes")
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, userId);
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, userId);
     }
 
     private Map<String, Set<String>> buildExcludeGroupTypesMap() {
         return new ImmutableMap.Builder<String, Set<String>>()
-                .put("CR", Sets.newHashSet("VFModule", "Root", "Heat"))
-                .put(COMPONENT_TYPE, EXCLUDED_TYPES)
-                .build();
+            .put("CR", Sets.newHashSet("VFModule", "Root", "Heat"))
+            .put(COMPONENT_TYPE, EXCLUDED_TYPES)
+            .build();
     }
 
 
     private List<GroupTypeDefinition> buildGroupTypesList() {
         GroupTypeDefinition type1 = GroupTypeBuilder.create()
-                                                    .setDerivedFrom("root")
-                                                    .setType("org.openecomp.groups.VfModule")
-                                                    .setUniqueId("id1")
-                                                    .setVersion("1.0")
-                                                    .setName("vf module")
-                                                    .setIcon("vf module icon")
-                                                    .build();
+            .setDerivedFrom("root")
+            .setType("org.openecomp.groups.VfModule")
+            .setUniqueId("id1")
+            .setVersion("1.0")
+            .setName("vf module")
+            .setIcon("vf module icon")
+            .build();
         GroupTypeDefinition type2 = GroupTypeBuilder.create()
-                                                    .setDerivedFrom("root")
-                                                    .setType("org.openecomp.groups.NetworkCollection")
-                                                    .setUniqueId("id2")
-                                                    .setVersion("1.0")
-                                                    .setName("network collection")
-                                                    .setIcon("network collection icon")
-                                                    .build();
+            .setDerivedFrom("root")
+            .setType("org.openecomp.groups.NetworkCollection")
+            .setUniqueId("id2")
+            .setVersion("1.0")
+            .setName("network collection")
+            .setIcon("network collection icon")
+            .build();
         return asList(type1, type2);
     }
 
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java
index 9b8b984..bd20471 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/InputsServletTest.java
@@ -20,15 +20,39 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.glassfish.grizzly.http.util.HttpStatus;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
@@ -66,31 +90,7 @@
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class InputsServletTest extends JerseyTest {
+class InputsServletTest extends JerseyTest {
 
     /* Constants */
     private static final String RESOURCE_ID = "serviceId";
@@ -120,10 +120,11 @@
     private static HttpServletRequest request;
 
     String appConfigDir = "src/test/resources/config/catalog-be";
-    ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+    ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+        appConfigDir);
     ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
 
-    @BeforeClass
+    @BeforeAll
     public static void configureMocks() {
         request = mock(HttpServletRequest.class);
         userBusinessLogic = mock(UserBusinessLogic.class);
@@ -141,8 +142,9 @@
 
     }
 
-    @Before
-    public void resetMocks() {
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
         Mockito.reset(resourceImportManager);
         Mockito.reset(servletUtils);
         Mockito.reset(componentsUtils);
@@ -160,10 +162,16 @@
         when(httpSession.getServletContext()).thenReturn(servletContext);
         when(servletContext.getAttribute(
             Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(new WebAppContextWrapper());
-        when(servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)).thenReturn(webApplicationContext);
+        when(servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE))
+            .thenReturn(webApplicationContext);
         when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
     }
 
+    @AfterEach
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+
     @Override
     protected Application configure() {
         InputsServlet inputsServlet = new InputsServlet(userBusinessLogic, inputsBusinessLogic,
@@ -185,18 +193,15 @@
         return resourceConfig;
     }
 
-
-
-
     private InputDefinition setUpListInput() {
         InputDefinition listInput = new InputDefinition();
         listInput.setName(LISTINPUT_NAME);
         listInput.setType("list");
         SchemaDefinition listInputSchema = new SchemaDefinition();
         listInputSchema.setProperty(new PropertyDataDefinitionBuilder()
-                .setType(LISTINPUT_SCHEMA_TYPE)
-                .setIsRequired(false)
-                .build()
+            .setType(LISTINPUT_SCHEMA_TYPE)
+            .setIsRequired(false)
+            .build()
         );
         listInput.setSchema(listInputSchema);
         return listInput;
@@ -233,15 +238,17 @@
     }
 
     @Test
-    public void test_createListInput_success() throws Exception {
+    void test_createListInput_success() throws Exception {
         ComponentInstListInput requestBodyObj = setUpCreateListInputParams();
         Entity<ComponentInstListInput> entity = Entity.entity(requestBodyObj, MediaType.APPLICATION_JSON);
 
-        doReturn(Either.left(requestBodyObj)).when(componentsUtils).convertJsonToObjectUsingObjectMapper(any(), any(), eq(ComponentInstListInput.class),
-            eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.SERVICE));
+        doReturn(Either.left(requestBodyObj)).when(componentsUtils)
+            .convertJsonToObjectUsingObjectMapper(any(), any(), eq(ComponentInstListInput.class),
+                eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.SERVICE));
 
-        doReturn(Either.left(Collections.emptyList())).when(inputsBusinessLogic).createListInput(eq(USER_ID), eq(RESOURCE_ID), eq(ComponentTypeEnum.SERVICE),
-            any(), eq(true), eq(false));
+        doReturn(Either.left(Collections.emptyList())).when(inputsBusinessLogic)
+            .createListInput(eq(USER_ID), eq(RESOURCE_ID), eq(ComponentTypeEnum.SERVICE),
+                any(), eq(true), eq(false));
 
         ResponseFormat responseFormat = new ResponseFormat(HttpStatus.OK_200.getStatusCode());
         doReturn(responseFormat).when(componentsUtils).getResponseFormat(ActionStatus.OK);
@@ -249,72 +256,76 @@
         Response response = buildCreateListInputCall().post(entity);
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200.getStatusCode());
         verify(inputsBusinessLogic, times(1)).createListInput(USER_ID, RESOURCE_ID,
-                ComponentTypeEnum.SERVICE, requestBodyObj, true, false);
+            ComponentTypeEnum.SERVICE, requestBodyObj, true, false);
     }
 
     @Test
-    public void test_createListInput_fail_parse() throws Exception {
+    void test_createListInput_fail_parse() throws Exception {
         ComponentInstListInput requestBodyObj = setUpCreateListInputParams();
         Entity<ComponentInstListInput> entity = Entity.entity(requestBodyObj, MediaType.APPLICATION_JSON);
 
         // for parseToComponentInstListInput
         ArgumentCaptor<User> userCaptor = ArgumentCaptor.forClass(User.class);
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(any(), userCaptor.capture(), eq(ComponentInstListInput.class),
+        when(componentsUtils
+            .convertJsonToObjectUsingObjectMapper(any(), userCaptor.capture(), eq(ComponentInstListInput.class),
                 eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.SERVICE)))
-                .thenReturn(Either.right(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode())));
+            .thenReturn(Either.right(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode())));
 
         when(inputsBusinessLogic.createListInput(eq(USER_ID), eq(RESOURCE_ID), eq(ComponentTypeEnum.SERVICE),
-                any(), eq(true), eq(false)))
-                .thenReturn(Either.left(Collections.emptyList()));
+            any(), eq(true), eq(false)))
+            .thenReturn(Either.left(Collections.emptyList()));
 
         Response response = buildCreateListInputCall().post(entity);
         assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
         verify(componentsUtils, times(1))
-                .convertJsonToObjectUsingObjectMapper(any(), any(), eq(ComponentInstListInput.class),
+            .convertJsonToObjectUsingObjectMapper(any(), any(), eq(ComponentInstListInput.class),
                 eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.SERVICE));
         assertThat(userCaptor.getValue().getUserId()).isEqualTo(USER_ID);
         verify(inputsBusinessLogic, never()).createListInput(USER_ID, RESOURCE_ID,
-                ComponentTypeEnum.SERVICE, requestBodyObj, true, false);
+            ComponentTypeEnum.SERVICE, requestBodyObj, true, false);
     }
 
 
     @Test
-    public void test_createListInput_fail_createInput() throws Exception {
+    void test_createListInput_fail_createInput() throws Exception {
         ComponentInstListInput requestBodyObj = setUpCreateListInputParams();
         Entity<ComponentInstListInput> entity = Entity.entity(requestBodyObj, MediaType.APPLICATION_JSON);
 
         // for parseToComponentInstListInput
         ArgumentCaptor<User> userCaptor = ArgumentCaptor.forClass(User.class);
-        when(componentsUtils.convertJsonToObjectUsingObjectMapper(any(), userCaptor.capture(), eq(ComponentInstListInput.class),
+        when(componentsUtils
+            .convertJsonToObjectUsingObjectMapper(any(), userCaptor.capture(), eq(ComponentInstListInput.class),
                 eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.SERVICE)))
-                .thenReturn(Either.left(requestBodyObj));
+            .thenReturn(Either.left(requestBodyObj));
 
         when(inputsBusinessLogic.createListInput(eq(USER_ID), eq(RESOURCE_ID), eq(ComponentTypeEnum.SERVICE),
-                any(), eq(true), eq(false)))
-                .thenReturn(Either.right(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode())));
+            any(), eq(true), eq(false)))
+            .thenReturn(Either.right(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode())));
 
         Response response = buildCreateListInputCall().post(entity);
         assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
         verify(inputsBusinessLogic, times(1))
-                .createListInput(eq(USER_ID), eq(RESOURCE_ID), eq(ComponentTypeEnum.SERVICE),
-                        any(), eq(true), eq(false));
+            .createListInput(eq(USER_ID), eq(RESOURCE_ID), eq(ComponentTypeEnum.SERVICE),
+                any(), eq(true), eq(false));
     }
 
 
     @Test
-    public void test_createListInput_fail_exception() throws Exception {
+    void test_createListInput_fail_exception() throws Exception {
         ComponentInstListInput requestBodyObj = setUpCreateListInputParams();
         Entity<ComponentInstListInput> entity = Entity.entity(requestBodyObj, MediaType.APPLICATION_JSON);
 
-        when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode()));
+        when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR))
+            .thenReturn(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode()));
 
         Response response = buildCreateListInputCall().post(entity);
         assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
     }
 
     @Test
-    public void test_getDataType_success() throws Exception {
-        when(dataTypeBusinessLogic.getPrivateDataType(eq(RESOURCE_ID),eq(LISTINPUT_SCHEMA_TYPE))).thenReturn(Either.left(new DataTypeDefinition()));
+    void test_getDataType_success() throws Exception {
+        when(dataTypeBusinessLogic.getPrivateDataType(eq(RESOURCE_ID), eq(LISTINPUT_SCHEMA_TYPE)))
+            .thenReturn(Either.left(new DataTypeDefinition()));
 
         ResponseFormat responseFormat = new ResponseFormat();
         responseFormat.setStatus(HttpStatus.OK_200.getStatusCode());
@@ -325,12 +336,14 @@
     }
 
     @Test
-    public void test_getDataType_fail() throws Exception {
-        when(dataTypeBusinessLogic.getPrivateDataType(eq(RESOURCE_ID),eq(LISTINPUT_SCHEMA_TYPE))).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+    void test_getDataType_fail() throws Exception {
+        when(dataTypeBusinessLogic.getPrivateDataType(eq(RESOURCE_ID), eq(LISTINPUT_SCHEMA_TYPE)))
+            .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
         ResponseFormat responseFormat = new ResponseFormat();
         responseFormat.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500.getStatusCode());
-        when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.BAD_REQUEST))).thenReturn(ActionStatus.GENERAL_ERROR);
+        when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.BAD_REQUEST)))
+            .thenReturn(ActionStatus.GENERAL_ERROR);
         when(componentsUtils.getResponseFormat(eq(ActionStatus.GENERAL_ERROR))).thenReturn(responseFormat);
 
         Response response = buildGetDataTypeCall().get();
@@ -338,17 +351,20 @@
     }
 
     @Test
-    public void test_getDataType_fail_exception() throws Exception {
-        when(dataTypeBusinessLogic.getPrivateDataType(eq(RESOURCE_ID),eq(LISTINPUT_SCHEMA_TYPE))).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
-        when(componentsUtils.getResponseFormat(eq(ActionStatus.GENERAL_ERROR))).thenReturn(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode()));
+    void test_getDataType_fail_exception() throws Exception {
+        when(dataTypeBusinessLogic.getPrivateDataType(eq(RESOURCE_ID), eq(LISTINPUT_SCHEMA_TYPE)))
+            .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+        when(componentsUtils.getResponseFormat(eq(ActionStatus.GENERAL_ERROR)))
+            .thenReturn(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode()));
 
         Response response = buildGetDataTypeCall().get();
         assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
     }
 
     @Test
-    public void test_getDataTypes_success() throws Exception {
-        when(dataTypeBusinessLogic.getPrivateDataTypes(eq(RESOURCE_ID))).thenReturn(Either.left(Collections.emptyList()));
+    void test_getDataTypes_success() throws Exception {
+        when(dataTypeBusinessLogic.getPrivateDataTypes(eq(RESOURCE_ID)))
+            .thenReturn(Either.left(Collections.emptyList()));
 
         ResponseFormat responseFormat = new ResponseFormat();
         responseFormat.setStatus(HttpStatus.OK_200.getStatusCode());
@@ -359,12 +375,14 @@
     }
 
     @Test
-    public void test_getDataTypes_fail() throws Exception {
-        when(dataTypeBusinessLogic.getPrivateDataTypes(eq(RESOURCE_ID))).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+    void test_getDataTypes_fail() throws Exception {
+        when(dataTypeBusinessLogic.getPrivateDataTypes(eq(RESOURCE_ID)))
+            .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
         ResponseFormat responseFormat = new ResponseFormat();
         responseFormat.setStatus(HttpStatus.INTERNAL_SERVER_ERROR_500.getStatusCode());
-        when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.BAD_REQUEST))).thenReturn(ActionStatus.GENERAL_ERROR);
+        when(componentsUtils.convertFromStorageResponse(eq(StorageOperationStatus.BAD_REQUEST)))
+            .thenReturn(ActionStatus.GENERAL_ERROR);
         when(componentsUtils.getResponseFormat(eq(ActionStatus.GENERAL_ERROR))).thenReturn(responseFormat);
 
         Response response = buildGetDataTypesCall().get();
@@ -372,101 +390,109 @@
     }
 
     @Test
-    public void test_getDataTypes_fail_exception() throws Exception {
-        when(dataTypeBusinessLogic.getPrivateDataType(eq(RESOURCE_ID),eq(LISTINPUT_SCHEMA_TYPE))).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
-        when(componentsUtils.getResponseFormat(eq(ActionStatus.GENERAL_ERROR))).thenReturn(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode()));
+    void test_getDataTypes_fail_exception() throws Exception {
+        when(dataTypeBusinessLogic.getPrivateDataType(eq(RESOURCE_ID), eq(LISTINPUT_SCHEMA_TYPE)))
+            .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+        when(componentsUtils.getResponseFormat(eq(ActionStatus.GENERAL_ERROR)))
+            .thenReturn(new ResponseFormat(HttpStatus.BAD_REQUEST_400.getStatusCode()));
 
         Response response = buildGetDataTypesCall().get();
         assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
     }
 
-
     @Test
-    public void test_deleteDataType_success() throws Exception {
-        when(dataTypeBusinessLogic.deletePrivateDataType(RESOURCE_ID, LISTINPUT_SCHEMA_TYPE)).thenReturn(Either.left(new DataTypeDefinition()));
+    void test_deleteDataType_success() throws Exception {
+        when(dataTypeBusinessLogic.deletePrivateDataType(RESOURCE_ID, LISTINPUT_SCHEMA_TYPE))
+            .thenReturn(Either.left(new DataTypeDefinition()));
 
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
+        when(componentsUtils.getResponseFormat(ActionStatus.OK))
+            .thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
 
         Response response = buildGetDataTypeCall().delete();
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200.getStatusCode());
     }
 
     @Test
-    public void test_deleteDataType_failure_exception() throws Exception {
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
-        when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(new ResponseFormat(HttpStatus.INTERNAL_SERVER_ERROR_500.getStatusCode()));
+    void test_deleteDataType_failure_exception() throws Exception {
+        when(componentsUtils.getResponseFormat(ActionStatus.OK))
+            .thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
+        when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR))
+            .thenReturn(new ResponseFormat(HttpStatus.INTERNAL_SERVER_ERROR_500.getStatusCode()));
         Response response = buildGetDataTypeCall().delete();
         assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR_500.getStatusCode());
         verify(componentsUtils, never()).getResponseFormat(ActionStatus.OK);
     }
 
     @Test
-    public void test_deleteDataType_failure_notFound() throws Exception {
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
-        when(dataTypeBusinessLogic.deletePrivateDataType(RESOURCE_ID, LISTINPUT_SCHEMA_TYPE)).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
-        when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND)).thenReturn(ActionStatus.ARTIFACT_NOT_FOUND);
-        when(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND)).thenReturn(new ResponseFormat(HttpStatus.NOT_FOUND_404.getStatusCode()));
+    void test_deleteDataType_failure_notFound() throws Exception {
+        when(componentsUtils.getResponseFormat(ActionStatus.OK))
+            .thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
+        when(dataTypeBusinessLogic.deletePrivateDataType(RESOURCE_ID, LISTINPUT_SCHEMA_TYPE))
+            .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+        when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND))
+            .thenReturn(ActionStatus.ARTIFACT_NOT_FOUND);
+        when(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND))
+            .thenReturn(new ResponseFormat(HttpStatus.NOT_FOUND_404.getStatusCode()));
         Response response = buildGetDataTypeCall().delete();
         assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND_404.getStatusCode());
         verify(componentsUtils, never()).getResponseFormat(ActionStatus.OK);
     }
 
     @Test
-    public void test_deleteInput_success() throws Exception {
+    void test_deleteInput_success() throws Exception {
         when(inputsBusinessLogic.deleteInput(RESOURCE_ID, USER_ID, LISTINPUT_NAME))
-                .thenReturn(new InputDefinition());
-        when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
+            .thenReturn(new InputDefinition());
+        when(componentsUtils.getResponseFormat(ActionStatus.OK))
+            .thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
 
         // invoke delete call
         Response response = target("/v1/catalog/services/{id}/delete/{inputId}/input")
-                .resolveTemplate("id", RESOURCE_ID)
-                .resolveTemplate("inputId", LISTINPUT_NAME)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID)
-                .delete();
+            .resolveTemplate("id", RESOURCE_ID)
+            .resolveTemplate("inputId", LISTINPUT_NAME)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID)
+            .delete();
         assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200.getStatusCode());
         verify(inputsBusinessLogic, times(1)).deleteInput(RESOURCE_ID, USER_ID, LISTINPUT_NAME);
     }
 
-
     @Test
-    public void test_deleteInput_failure_deleteInput() throws Exception {
+    void test_deleteInput_failure_deleteInput() throws Exception {
         ComponentException componentException = new ByActionStatusComponentException(ActionStatus.INVALID_CONTENT);
         when(inputsBusinessLogic.deleteInput(RESOURCE_ID, USER_ID, LISTINPUT_NAME))
-                .thenThrow(componentException);
+            .thenThrow(componentException);
 
         // invoke delete call
         Response response = target("/v1/catalog/services/{id}/delete/{inputId}/input")
-                .resolveTemplate("id", RESOURCE_ID)
-                .resolveTemplate("inputId", LISTINPUT_NAME)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID)
-                .delete();
+            .resolveTemplate("id", RESOURCE_ID)
+            .resolveTemplate("inputId", LISTINPUT_NAME)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID)
+            .delete();
         assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400.getStatusCode());
         verify(componentsUtils, never()).getResponseFormat(ActionStatus.OK);
     }
 
-
     private Invocation.Builder buildCreateListInputCall() {
         return target("/v1/catalog/services/{id}/create/listInput")
-                .resolveTemplate("id", RESOURCE_ID)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID);
+            .resolveTemplate("id", RESOURCE_ID)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID);
     }
 
     private Invocation.Builder buildGetDataTypeCall() {
         return target("/v1/catalog/services/{id}/dataType/{dataTypeName}")
-                .resolveTemplate("id", RESOURCE_ID)
-                .resolveTemplate("dataTypeName", LISTINPUT_SCHEMA_TYPE)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID);
+            .resolveTemplate("id", RESOURCE_ID)
+            .resolveTemplate("dataTypeName", LISTINPUT_SCHEMA_TYPE)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID);
     }
 
     private Invocation.Builder buildGetDataTypesCall() {
         return target("/v1/catalog/services/{id}/dataTypes")
-                .resolveTemplate("id", RESOURCE_ID)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID);
+            .resolveTemplate("id", RESOURCE_ID)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID);
     }
 
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/JerseySpringBaseTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/JerseySpringBaseTest.java
index 38eef3c..e755de1 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/JerseySpringBaseTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/JerseySpringBaseTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,7 +20,13 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.mockito.Mockito.mock;
+
 import com.fasterxml.jackson.databind.DeserializationFeature;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Feature;
 import org.glassfish.grizzly.servlet.HttpSessionImpl;
 import org.glassfish.grizzly.servlet.WebappContext;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
@@ -33,7 +39,7 @@
 import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature;
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.BeforeAll;
 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
 import org.openecomp.sdc.be.servlets.exception.ComponentExceptionMapper;
 import org.openecomp.sdc.be.servlets.exception.DefaultExceptionMapper;
@@ -42,13 +48,6 @@
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Feature;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static org.mockito.Mockito.mock;
-
 public abstract class JerseySpringBaseTest extends JerseyTest {
 
     private static final Logger log = Logger.getLogger(JerseySpringBaseTest.class.getName());
@@ -57,10 +56,12 @@
     protected static WebappContext context;
     protected static WebAppContextWrapper contextWrapper;
     protected static WebApplicationContext applicationContext;
-    private final static JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-    private final static Feature loggingFeature = new LoggingFeature(log, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, null);
+    private final static JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
+        .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+    private final static Feature loggingFeature = new LoggingFeature(log, Level.INFO,
+        LoggingFeature.Verbosity.PAYLOAD_ANY, null);
 
-    @BeforeClass
+    @BeforeAll
     public static void initBaseClass() {
         request = mock(HttpServletRequest.class);
         session = mock(HttpSessionImpl.class);
@@ -72,8 +73,8 @@
     @Override
     protected void configureClient(ClientConfig config) {
         config.register(MultiPartFeature.class)
-              .register(loggingFeature)
-              .register(jacksonJsonProvider);
+            .register(loggingFeature)
+            .register(jacksonJsonProvider);
     }
 
     protected ResourceConfig configure() {
@@ -85,21 +86,21 @@
         ApplicationContext context = new AnnotationConfigApplicationContext(springConfig);
         forceSet(TestProperties.CONTAINER_PORT, "0");
         return new ResourceConfig()
-                .register(new AbstractBinder() {
-                    @Override
-                    protected void configure() {
-                        bind(request).to(HttpServletRequest.class);
-                    }
-                })
-                .register(RolesAllowedDynamicFeature.class)
-                .register(DefaultExceptionMapper.class)
-                .register(ComponentExceptionMapper.class)
-                .register(StorageExceptionMapper.class)
-                .register(MultiPartFeature.class)
-                .register(jacksonJsonProvider)
-                .register(loggingFeature)
-                .property("jersey.config.server.provider.classnames", "org.openecomp.sdc.be.view.MixinModelWriter")
-                .property("contextConfig", context);
+            .register(new AbstractBinder() {
+                @Override
+                protected void configure() {
+                    bind(request).to(HttpServletRequest.class);
+                }
+            })
+            .register(RolesAllowedDynamicFeature.class)
+            .register(DefaultExceptionMapper.class)
+            .register(ComponentExceptionMapper.class)
+            .register(StorageExceptionMapper.class)
+            .register(MultiPartFeature.class)
+            .register(jacksonJsonProvider)
+            .register(loggingFeature)
+            .property("jersey.config.server.provider.classnames", "org.openecomp.sdc.be.view.MixinModelWriter")
+            .property("contextConfig", context);
     }
 
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java
index 4d1b611..469a73d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,8 +20,28 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.common.api.Constants.GET_POLICY;
+
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import fj.data.Either;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Objects;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.glassfish.grizzly.http.util.HttpStatus;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
@@ -29,15 +49,14 @@
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.TestProperties;
 import org.json.simple.JSONObject;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mockito;
 import org.mockito.Spy;
-import org.mockito.junit.MockitoJUnitRunner;
 import org.openecomp.sdc.be.components.impl.BaseBusinessLogic;
 import org.openecomp.sdc.be.components.impl.PolicyBusinessLogic;
 import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
@@ -77,31 +96,7 @@
 import org.openecomp.sdc.common.util.ThreadLocalsHolder;
 import org.openecomp.sdc.exception.ResponseFormat;
 
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Objects;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-import static org.openecomp.sdc.common.api.Constants.GET_POLICY;
-
-
-
-@RunWith(MockitoJUnitRunner.class)
-public class PolicyServletTest extends JerseySpringBaseTest{
+class PolicyServletTest extends JerseySpringBaseTest {
 
     private final static String USER_ID = "jh0003";
     private static final String COMPONENT_ID = "componentId";
@@ -131,201 +126,224 @@
 
     private static final String UPDATE_TARGETS_URL = "/v1/catalog/{componentType}/{componentId}/policies/{policyId}/targets";
     static ConfigurationSource configurationSource = new FSConfigurationSource(
-            ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
+        ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
     static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
 
-    @BeforeClass
+    @BeforeAll
     public static void initClass() {
         ResponseFormatManager.getInstance();
         createMocks();
         when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
     }
 
-    @Before
-    public void beforeMethod() {
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
         Mockito.reset(businessLogic);
-        final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         setClient(ClientBuilder.newClient(new ClientConfig(jacksonJsonProvider)));
         ThreadLocalsHolder.setApiType(FilterDecisionEnum.EXTERNAL);
         when(request.isUserInRole(anyString())).thenReturn(true);
 
     }
 
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
 
     @Test
-    public void testGetPolicySuccess(){
+    void testGetPolicySuccess() {
         String path = "/v1/catalog/" + validComponentType + "/" + componentId + "/policies/" + POLICY_ID;
         PolicyDefinition successResponse = new PolicyDefinition();
-        when(businessLogic.getPolicy(eq(ComponentTypeEnum.RESOURCE), eq(componentId), eq(POLICY_ID), eq(USER_ID))).thenReturn(successResponse);
+        when(businessLogic.getPolicy(eq(ComponentTypeEnum.RESOURCE), eq(componentId), eq(POLICY_ID), eq(USER_ID)))
+            .thenReturn(successResponse);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .get(Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .get(Response.class);
 
         assertEquals(response.getStatus(), HttpStatus.OK_200.getStatusCode());
     }
 
     @Test
-    public void testGetPolicyFailure(){
+    void testGetPolicyFailure() {
         String path = "/v1/catalog/" + unsupportedComponentType + "/" + componentId + "/policies/" + POLICY_ID;
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .get(Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .get(Response.class);
 
         assertEquals(response.getStatus(), HttpStatus.BAD_REQUEST_400.getStatusCode());
     }
-    
+
     @Test
-    public void testPostPolicySuccess(){
+    void testPostPolicySuccess() {
         String path = "/v1/catalog/" + validComponentType + "/" + componentId + "/policies/" + policyTypeName;
         PolicyDefinition policy = new PolicyDefinition();
         PolicyDefinition successResponse = policy;
-        when(businessLogic.createPolicy(eq(ComponentTypeEnum.RESOURCE), eq(componentId), eq(policyTypeName), eq(USER_ID), eq(true))).thenReturn(successResponse);
+        when(businessLogic
+            .createPolicy(eq(ComponentTypeEnum.RESOURCE), eq(componentId), eq(policyTypeName), eq(USER_ID), eq(true)))
+            .thenReturn(successResponse);
         when(responseFormat.getStatus()).thenReturn(HttpStatus.CREATED_201.getStatusCode());
         when(componentsUtils.getResponseFormat(ActionStatus.CREATED)).thenReturn(responseFormat);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .post(Entity.entity(policy, MediaType.APPLICATION_JSON),Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .post(Entity.entity(policy, MediaType.APPLICATION_JSON), Response.class);
 
         assertEquals(response.getStatus(), HttpStatus.CREATED_201.getStatusCode());
     }
-    
+
     @Test
-    public void testPostPolicyFailure(){
+    void testPostPolicyFailure() {
         String path = "/v1/catalog/" + unsupportedComponentType + "/" + componentId + "/policies/" + policyTypeName;
         PolicyDefinition policy = new PolicyDefinition();
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .post(Entity.entity(policy, MediaType.APPLICATION_JSON),Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .post(Entity.entity(policy, MediaType.APPLICATION_JSON), Response.class);
 
         assertEquals(response.getStatus(), HttpStatus.BAD_REQUEST_400.getStatusCode());
     }
-    
+
     @Test
-    public void testPutPolicySuccess(){
+    void testPutPolicySuccess() {
         String path = "/v1/catalog/" + validComponentType + "/" + componentId + "/policies/" + POLICY_ID;
         PolicyDefinition policy = new PolicyDefinition();
         policy.setUniqueId(POLICY_ID);
         PolicyDefinition successResponse = policy;
-        when(businessLogic.updatePolicy(eq(ComponentTypeEnum.RESOURCE), eq(componentId), any(PolicyDefinition.class), eq(USER_ID), eq(true))).thenReturn(successResponse);
+        when(businessLogic
+            .updatePolicy(eq(ComponentTypeEnum.RESOURCE), eq(componentId), any(PolicyDefinition.class), eq(USER_ID),
+                eq(true))).thenReturn(successResponse);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .put(Entity.entity(policy, MediaType.APPLICATION_JSON),Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .put(Entity.entity(policy, MediaType.APPLICATION_JSON), Response.class);
 
         assertEquals(response.getStatus(), HttpStatus.OK_200.getStatusCode());
     }
-    
+
     @Test
-    public void testPutPolicyFailure(){
+    void testPutPolicyFailure() {
         String path = "/v1/catalog/" + unsupportedComponentType + "/" + componentId + "/policies/" + POLICY_ID;
         PolicyDefinition policy = new PolicyDefinition();
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .put(Entity.entity(policy, MediaType.APPLICATION_JSON),Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .put(Entity.entity(policy, MediaType.APPLICATION_JSON), Response.class);
 
         assertEquals(response.getStatus(), HttpStatus.BAD_REQUEST_400.getStatusCode());
     }
-    
+
     @Test
-    public void testDeletePolicySuccess(){
+    void testDeletePolicySuccess() {
         String path = "/v1/catalog/" + validComponentType + "/" + componentId + "/policies/" + POLICY_ID;
         PolicyDefinition successResponse = new PolicyDefinition();
-        when(businessLogic.deletePolicy(eq(ComponentTypeEnum.RESOURCE), eq(componentId), eq(POLICY_ID), eq(USER_ID), eq(true))).thenReturn(successResponse);
+        when(businessLogic
+            .deletePolicy(eq(ComponentTypeEnum.RESOURCE), eq(componentId), eq(POLICY_ID), eq(USER_ID), eq(true)))
+            .thenReturn(successResponse);
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .delete(Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .delete(Response.class);
 
         assertEquals(response.getStatus(), HttpStatus.OK_200.getStatusCode());
     }
 
     @Test
-    public void testDeletePolicyFailure(){
+    void testDeletePolicyFailure() {
         String path = "/v1/catalog/" + unsupportedComponentType + "/" + componentId + "/policies/" + POLICY_ID;
         Response response = target()
-                .path(path)
-                .request(MediaType.APPLICATION_JSON)
-                .header("USER_ID", USER_ID)
-                .delete(Response.class);
+            .path(path)
+            .request(MediaType.APPLICATION_JSON)
+            .header("USER_ID", USER_ID)
+            .delete(Response.class);
 
         assertEquals(response.getStatus(), HttpStatus.BAD_REQUEST_400.getStatusCode());
     }
 
     @Test
-    public void getPolicyProperties_operationForbidden() {
-       // doThrow(new ComponentException(ActionStatus.GENERAL_ERROR)).when(businessLogic).getPolicyProperties(ComponentTypeEnum.SERVICE, SERVICE_ID, POLICY_ID, USER_ID);
+    void getPolicyProperties_operationForbidden() {
+        // doThrow(new ComponentException(ActionStatus.GENERAL_ERROR)).when(businessLogic).getPolicyProperties(ComponentTypeEnum.SERVICE, SERVICE_ID, POLICY_ID, USER_ID);
         when(businessLogic.getPolicyProperties(ComponentTypeEnum.SERVICE, SERVICE_ID, POLICY_ID, USER_ID))
-                .thenThrow(new ByActionStatusComponentException(ActionStatus.AUTH_FAILED, USER_ID));
+            .thenThrow(new ByActionStatusComponentException(ActionStatus.AUTH_FAILED, USER_ID));
         Response response = buildGetPropertiesRequest().get();
         assertThat(response.getStatus()).isEqualTo(Response.Status.FORBIDDEN.getStatusCode());
     }
 
     @Test//(expected = ComponentException.class)
-    public void getPolicyProperties_unHandledError_returnGeneralError() {
-        when(businessLogic.getPolicyProperties(ComponentTypeEnum.SERVICE, SERVICE_ID, POLICY_ID, USER_ID)).thenThrow(new RuntimeException());
+    void getPolicyProperties_unHandledError_returnGeneralError() {
+        when(businessLogic.getPolicyProperties(ComponentTypeEnum.SERVICE, SERVICE_ID, POLICY_ID, USER_ID))
+            .thenThrow(new RuntimeException());
         Response response = buildGetPropertiesRequest().get();
         assertThat(response.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
     }
 
     @Test
-    public void getPolicyProperties_wrongComponentType() {
+    void getPolicyProperties_wrongComponentType() {
         Response response = buildGetPropertiesRequest("unknownType").get();
         assertThat(response.getStatus()).isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
         //verifyZeroInteractions(businessLogic);
     }
 
     @Test
-    public void getPolicyProperties() {
+    void getPolicyProperties() {
         List<PropertyDataDefinition> properties = getPropertiesList();
-        when(businessLogic.getPolicyProperties(ComponentTypeEnum.SERVICE, SERVICE_ID, POLICY_ID, USER_ID)).thenReturn(properties);
-        List<PropertyDataDefinition> policyProps = buildGetPropertiesRequest().get(new GenericType<List<PropertyDataDefinition>>() {});
+        when(businessLogic.getPolicyProperties(ComponentTypeEnum.SERVICE, SERVICE_ID, POLICY_ID, USER_ID))
+            .thenReturn(properties);
+        List<PropertyDataDefinition> policyProps = buildGetPropertiesRequest()
+            .get(new GenericType<List<PropertyDataDefinition>>() {
+            });
         assertThat(policyProps)
-                .usingElementComparatorOnFields("uniqueId")
-                .containsExactlyInAnyOrder(properties.get(0), properties.get(1));
-    }
-    
-    @Test
-    public void updatePolicyPropertiesSuccess() {
-        List<PropertyDataDefinition> properties = getPropertiesList();
-        when(businessLogic.updatePolicyProperties(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID), eq(POLICY_ID),
-                any(PropertyDataDefinition[].class), eq(USER_ID), eq(true))).thenReturn(properties);
-        List<PropertyDataDefinition> policyProps = buildUpdatePropertiesRequest(ComponentTypeEnum.SERVICE_PARAM_NAME, properties).invoke(new GenericType<List<PropertyDataDefinition>>() {});
-        assertThat(policyProps)
-                .usingElementComparatorOnFields("uniqueId")
-                .containsExactlyInAnyOrder(properties.get(0), properties.get(1));
+            .usingElementComparatorOnFields("uniqueId")
+            .containsExactlyInAnyOrder(properties.get(0), properties.get(1));
     }
 
     @Test
-    public void updatePolicyTargetsSuccess() {
+    void updatePolicyPropertiesSuccess() {
+        List<PropertyDataDefinition> properties = getPropertiesList();
+        when(businessLogic.updatePolicyProperties(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID), eq(POLICY_ID),
+            any(PropertyDataDefinition[].class), eq(USER_ID), eq(true))).thenReturn(properties);
+        List<PropertyDataDefinition> policyProps = buildUpdatePropertiesRequest(ComponentTypeEnum.SERVICE_PARAM_NAME,
+            properties).invoke(new GenericType<List<PropertyDataDefinition>>() {
+        });
+        assertThat(policyProps)
+            .usingElementComparatorOnFields("uniqueId")
+            .containsExactlyInAnyOrder(properties.get(0), properties.get(1));
+    }
+
+    @Test
+    void updatePolicyTargetsSuccess() {
         List<PolicyTargetDTO> targets = getTargetDTOList();
-        when(businessLogic.updatePolicyTargets(eq(ComponentTypeEnum.RESOURCE), eq(COMPONENT_ID), eq(POLICY_ID), anyMap(), eq(USER_ID))).thenReturn(new PolicyDefinition());
+        when(businessLogic
+            .updatePolicyTargets(eq(ComponentTypeEnum.RESOURCE), eq(COMPONENT_ID), eq(POLICY_ID), anyMap(),
+                eq(USER_ID))).thenReturn(new PolicyDefinition());
         Response policyTargets = buildUpdateTargetsRequest(ComponentTypeEnum.RESOURCE_PARAM_NAME, targets).invoke();
         assertThat(policyTargets.getStatus()).isEqualTo(200);
     }
 
     @Test
-    public void updatePolicyPropertiesFailure() {
+    void updatePolicyPropertiesFailure() {
         List<PropertyDataDefinition> properties = getPropertiesList();
         ResponseFormat notFoundResponse = new ResponseFormat(HttpStatus.NOT_FOUND_404.getStatusCode());
-        when(businessLogic.updatePolicyProperties(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID), eq(POLICY_ID), any(PropertyDataDefinition[].class), eq(USER_ID), eq(true))).thenThrow(new ByResponseFormatComponentException(notFoundResponse));
+        when(businessLogic.updatePolicyProperties(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID), eq(POLICY_ID),
+            any(PropertyDataDefinition[].class), eq(USER_ID), eq(true)))
+            .thenThrow(new ByResponseFormatComponentException(notFoundResponse));
         Response policyProps = buildUpdatePropertiesRequest(ComponentTypeEnum.SERVICE_PARAM_NAME, properties).invoke();
         assertEquals(HttpStatus.NOT_FOUND_404.getStatusCode(), policyProps.getStatus());
     }
 
     @Test
-    public void testDeclarePropertyToPolicySuccess() {
+    void testDeclarePropertyToPolicySuccess() {
         Service service = new Service();
         service.setUniqueId(SERVICE_ID);
         service.addProperty(new PropertyDataDefinitionBuilder().setUniqueId(PROP_1).build());
@@ -335,14 +353,15 @@
 
         setMocksForPropertyDeclaration(policyDefinition);
 
-        when(componentsUtils.getResponseFormat(eq(ActionStatus.OK))).thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
+        when(componentsUtils.getResponseFormat(eq(ActionStatus.OK)))
+            .thenReturn(new ResponseFormat(HttpStatus.OK_200.getStatusCode()));
 
         Response declareResponse = buildDeclarePropertiesRequest(PROP_1).invoke();
         assertEquals(HttpStatus.OK_200.getStatusCode(), declareResponse.getStatus());
     }
 
     @Test
-    public void testUndeclarePolicySuccess() {
+    void testUndeclarePolicySuccess() {
         Service service = new Service();
         service.setUniqueId(SERVICE_ID);
         PropertyDefinition origProperty = new PropertyDataDefinitionBuilder().setUniqueId(PROP_1).build();
@@ -355,7 +374,9 @@
 
         addGetPolicyValueToProperty(origProperty, policyDefinition);
 
-        when(businessLogic.deletePolicy(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID), eq(policyDefinition.getUniqueId()), eq(USER_ID), eq(true))).thenReturn(policyDefinition);
+        when(businessLogic
+            .deletePolicy(eq(ComponentTypeEnum.SERVICE), eq(SERVICE_ID), eq(policyDefinition.getUniqueId()),
+                eq(USER_ID), eq(true))).thenReturn(policyDefinition);
 
         Response deleteResponse = buildDeletePolicyRequest(policyDefinition).invoke();
         assertEquals(HttpStatus.OK_200.getStatusCode(), deleteResponse.getStatus());
@@ -364,7 +385,8 @@
     private void addGetPolicyValueToProperty(PropertyDefinition propertyDefinition,
                                              PolicyDefinition policyDefinition) {
         JSONObject jobject = new JSONObject();
-        String origValue = Objects.isNull(propertyDefinition.getValue()) ? propertyDefinition.getDefaultValue() : propertyDefinition.getValue();
+        String origValue = Objects.isNull(propertyDefinition.getValue()) ? propertyDefinition.getDefaultValue()
+            : propertyDefinition.getValue();
         jobject.put(GET_POLICY, null);
         propertyDefinition.setValue(jobject.toJSONString());
 
@@ -384,21 +406,21 @@
         when(contextWrapper.getWebAppContext(any())).thenReturn(applicationContext);
         when(applicationContext.getBean(eq(PolicyBusinessLogic.class))).thenReturn(businessLogic);
         when(businessLogic.declareProperties(eq(USER_ID), eq(SERVICE_ID), any(), any())).thenReturn(
-                Either.left(Collections.singletonList(policyDefinition)));
+            Either.left(Collections.singletonList(policyDefinition)));
         when(componentsUtils
-                     .convertJsonToObjectUsingObjectMapper(any(), any(), eq(ComponentInstInputsMap.class), eq(
-                             AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.SERVICE)))
-                        .thenReturn(Either.left(getDeclarationBodyForProperty(PROP_1)));
+            .convertJsonToObjectUsingObjectMapper(any(), any(), eq(ComponentInstInputsMap.class), eq(
+                AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.SERVICE)))
+            .thenReturn(Either.left(getDeclarationBodyForProperty(PROP_1)));
     }
 
     private List<PropertyDataDefinition> getPropertiesList() {
         PropertyDefinition prop1 = new PropertyDataDefinitionBuilder()
-                .setUniqueId("prop1")
-                .build();
+            .setUniqueId("prop1")
+            .build();
 
         PropertyDefinition prop2 = new PropertyDataDefinitionBuilder()
-                .setUniqueId("prop2")
-                .build();
+            .setUniqueId("prop2")
+            .build();
         return Arrays.asList(prop1, prop2);
     }
 
@@ -416,60 +438,60 @@
 
     private Invocation.Builder buildGetPropertiesRequest(String componentType) {
         return target(PROPS_URL)
-                .resolveTemplate("componentType", componentType)
-                .resolveTemplate("serviceId", SERVICE_ID)
-                .resolveTemplate("policyId", POLICY_ID)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID);
+            .resolveTemplate("componentType", componentType)
+            .resolveTemplate("serviceId", SERVICE_ID)
+            .resolveTemplate("policyId", POLICY_ID)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID);
 
     }
-    
+
     private Invocation buildUpdatePropertiesRequest(String componentType, List<PropertyDataDefinition> properties) {
         return target(PROPS_URL)
-                .resolveTemplate("componentType", componentType)
-                .resolveTemplate("serviceId", SERVICE_ID)
-                .resolveTemplate("policyId", POLICY_ID)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID)
-                .buildPut(Entity.entity(properties, MediaType.APPLICATION_JSON));
+            .resolveTemplate("componentType", componentType)
+            .resolveTemplate("serviceId", SERVICE_ID)
+            .resolveTemplate("policyId", POLICY_ID)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID)
+            .buildPut(Entity.entity(properties, MediaType.APPLICATION_JSON));
     }
 
     private Invocation buildUpdateTargetsRequest(String componentType, List<PolicyTargetDTO> targets) {
         return target(UPDATE_TARGETS_URL)
-                .resolveTemplate("componentType", componentType)
-                .resolveTemplate("componentId", COMPONENT_ID)
-                .resolveTemplate("policyId", POLICY_ID)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID)
-                .buildPost(Entity.entity(targets, MediaType.APPLICATION_JSON));
+            .resolveTemplate("componentType", componentType)
+            .resolveTemplate("componentId", COMPONENT_ID)
+            .resolveTemplate("policyId", POLICY_ID)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID)
+            .buildPost(Entity.entity(targets, MediaType.APPLICATION_JSON));
     }
 
     private Invocation.Builder buildGetPropertiesRequest() {
         return target(PROPS_URL)
-                .resolveTemplate("componentType", "services")
-                .resolveTemplate("serviceId", SERVICE_ID)
-                .resolveTemplate("policyId", POLICY_ID)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID);
+            .resolveTemplate("componentType", "services")
+            .resolveTemplate("serviceId", SERVICE_ID)
+            .resolveTemplate("policyId", POLICY_ID)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID);
     }
 
     private Invocation buildDeletePolicyRequest(PolicyDefinition policyDefinition) {
         return target(DELETE_URL)
-                       .resolveTemplate("containerComponentType", "services")
-                       .resolveTemplate("componentId", SERVICE_ID)
-                       .resolveTemplate("policyId", policyDefinition.getUniqueId())
-                       .request(MediaType.APPLICATION_JSON)
-                       .header(Constants.USER_ID_HEADER, USER_ID)
-                        .buildDelete();
+            .resolveTemplate("containerComponentType", "services")
+            .resolveTemplate("componentId", SERVICE_ID)
+            .resolveTemplate("policyId", policyDefinition.getUniqueId())
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID)
+            .buildDelete();
     }
 
     private Invocation buildDeclarePropertiesRequest(String propertyId) {
         return target(DECLARE_URL)
-                       .resolveTemplate("componentType", "services")
-                       .resolveTemplate("serviceId", SERVICE_ID)
-                       .request(MediaType.APPLICATION_JSON)
-                       .header(Constants.USER_ID_HEADER, USER_ID)
-                       .buildPost(Entity.entity(getDeclarationBodyForProperty(propertyId), MediaType.APPLICATION_JSON));
+            .resolveTemplate("componentType", "services")
+            .resolveTemplate("serviceId", SERVICE_ID)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID)
+            .buildPost(Entity.entity(getDeclarationBodyForProperty(propertyId), MediaType.APPLICATION_JSON));
     }
 
     private ComponentInstInputsMap getDeclarationBodyForProperty(String propertyId) {
@@ -483,7 +505,8 @@
         propInput.setPropertiesName(propertyId);
 
         componentInstInputsMap.setComponentInstancePropertiesToPolicies(new HashMap<>());
-        componentInstInputsMap.getComponentInstancePropertiesToPolicies().put("componentInstancePropertiesToPolicies", Collections.singletonList(propInput));
+        componentInstInputsMap.getComponentInstancePropertiesToPolicies()
+            .put("componentInstancePropertiesToPolicies", Collections.singletonList(propInput));
 
         return componentInstInputsMap;
     }
@@ -492,8 +515,8 @@
     protected ResourceConfig configure() {
         forceSet(TestProperties.CONTAINER_PORT, "0");
         return super.configure()
-                .register(new PolicyServlet(null, null, componentsUtils,
-                    servletUtils, null, businessLogic));
+            .register(new PolicyServlet(null, null, componentsUtils,
+                servletUtils, null, businessLogic));
     }
 
     private static void createMocks() {
@@ -519,15 +542,15 @@
     private static class BaseBusinessLogicTest extends BaseBusinessLogic {
 
         BaseBusinessLogicTest(IElementOperation elementDao,
-            IGroupOperation groupOperation,
-            IGroupInstanceOperation groupInstanceOperation,
-            IGroupTypeOperation groupTypeOperation,
-            InterfaceOperation interfaceOperation,
-            InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
-            ArtifactsOperations artifactToscaOperation) {
+                              IGroupOperation groupOperation,
+                              IGroupInstanceOperation groupInstanceOperation,
+                              IGroupTypeOperation groupTypeOperation,
+                              InterfaceOperation interfaceOperation,
+                              InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
+                              ArtifactsOperations artifactToscaOperation) {
             super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, interfaceOperation,
                 interfaceLifecycleTypeOperation, artifactToscaOperation);
         }
     }
-    
+
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java
index d84ac90..34377b0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyTypesEndpointTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,10 +20,21 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.List;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
 import org.apache.http.HttpStatus;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openecomp.sdc.be.components.impl.PolicyTypeBusinessLogic;
 import org.openecomp.sdc.be.components.utils.PolicyTypeBuilder;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -33,23 +44,23 @@
 import org.openecomp.sdc.common.api.Constants;
 import org.openecomp.sdc.exception.ResponseFormat;
 
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import java.util.List;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class PolicyTypesEndpointTest extends JerseySpringBaseTest {
+class PolicyTypesEndpointTest extends JerseySpringBaseTest {
 
     public static final String USER_ID = "userId";
     public static final String COMPONENT_TYPE = "VF";
     private PolicyTypeBusinessLogic policyTypeBusinessLogic;
     private ComponentsUtils componentUtils;
 
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
+
     @Override
     protected ResourceConfig configure() {
         forceSet(TestProperties.CONTAINER_PORT, "0");
@@ -58,77 +69,82 @@
         UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class);
         ComponentsUtils componentsUtils = mock(ComponentsUtils.class);
         return super.configure()
-                .register(new PolicyTypesEndpoint(userBusinessLogic, componentsUtils, policyTypeBusinessLogic));
+            .register(new PolicyTypesEndpoint(userBusinessLogic, componentsUtils, policyTypeBusinessLogic));
     }
 
     @Test
-    public void getPolicyTypes() {
+    void getPolicyTypes() {
         List<PolicyTypeDefinition> policyTypes = buildPolicyTypesList();
         when(policyTypeBusinessLogic.getAllPolicyTypes(USER_ID, COMPONENT_TYPE)).thenReturn(policyTypes);
         when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(new ResponseFormat(HttpStatus.SC_OK));
-        List<PolicyTypeDefinition> fetchedPolicyTypes = buildGetPolicyTypesCall().get(new GenericType<List<PolicyTypeDefinition>>(){});
+        List<PolicyTypeDefinition> fetchedPolicyTypes = buildGetPolicyTypesCall()
+            .get(new GenericType<List<PolicyTypeDefinition>>() {
+            });
         verifyPolicyTypesList(policyTypes, fetchedPolicyTypes);
     }
 
     @Test
-    public void getPolicyTypes_whenNoInternalComponent_passNullAsComponentType() {
+    void getPolicyTypes_whenNoInternalComponent_passNullAsComponentType() {
         List<PolicyTypeDefinition> policyTypes = buildPolicyTypesList();
         when(policyTypeBusinessLogic.getAllPolicyTypes(USER_ID, null)).thenReturn(policyTypes);
         when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(new ResponseFormat(HttpStatus.SC_OK));
-        List<PolicyTypeDefinition> fetchedPolicyTypes = buildGetPolicyTypesCallNoInternalComponent().get(new GenericType<List<PolicyTypeDefinition>>(){});
+        List<PolicyTypeDefinition> fetchedPolicyTypes = buildGetPolicyTypesCallNoInternalComponent()
+            .get(new GenericType<List<PolicyTypeDefinition>>() {
+            });
         verifyPolicyTypesList(policyTypes, fetchedPolicyTypes);
     }
 
 
-    private void verifyPolicyTypesList(List<PolicyTypeDefinition> policyTypes, List<PolicyTypeDefinition> fetchedPolicyTypes) {
+    private void verifyPolicyTypesList(List<PolicyTypeDefinition> policyTypes,
+                                       List<PolicyTypeDefinition> fetchedPolicyTypes) {
         assertThat(fetchedPolicyTypes)
-                .usingElementComparatorOnFields("version", "type", "uniqueId", "name", "icon")
-                .isEqualTo(policyTypes);
-        assertThat(fetchedPolicyTypes).extracting("derivedFrom")//derivedFrom is not on the PolicyTypeMixin and should not return in response
-                .containsOnly((String)null);
+            .usingElementComparatorOnFields("version", "type", "uniqueId", "name", "icon")
+            .isEqualTo(policyTypes);
+        assertThat(fetchedPolicyTypes)
+            .extracting("derivedFrom")//derivedFrom is not on the PolicyTypeMixin and should not return in response
+            .containsOnly((String) null);
     }
 
     private Invocation.Builder buildGetPolicyTypesCall() {
         return target("/v1/catalog/policyTypes")
-                .queryParam("internalComponentType", COMPONENT_TYPE)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID);
+            .queryParam("internalComponentType", COMPONENT_TYPE)
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID);
     }
 
     private Invocation.Builder buildGetPolicyTypesCallNoInternalComponent() {
         return target("/v1/catalog/policyTypes")
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID);
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID);
     }
 
     private List<PolicyTypeDefinition> buildPolicyTypesList() {
         PolicyTypeDefinition type1 = new PolicyTypeBuilder()
-                .setDerivedFrom("root")
-                .setType("type1")
-                .setUniqueId("id1")
-                .setVersion("1.0")
-                .setName("type1name")
-                .setIcon("type1Icon")
-                .build();
+            .setDerivedFrom("root")
+            .setType("type1")
+            .setUniqueId("id1")
+            .setVersion("1.0")
+            .setName("type1name")
+            .setIcon("type1Icon")
+            .build();
         PolicyTypeDefinition type2 = new PolicyTypeBuilder()
-                .setDerivedFrom("type1")
-                .setType("type2")
-                .setUniqueId("id2")
-                .setVersion("1.0")
-                .setName("type2name")
-                .setIcon("type2con")
-                .build();
+            .setDerivedFrom("type1")
+            .setType("type2")
+            .setUniqueId("id2")
+            .setVersion("1.0")
+            .setName("type2name")
+            .setIcon("type2con")
+            .build();
         PolicyTypeDefinition type3 = new PolicyTypeBuilder()
-                .setDerivedFrom("root")
-                .setType("type3")
-                .setUniqueId("id3")
-                .setVersion("1.0")
-                .setName("type3name")
-                .setIcon("type3con")
-                .build();
+            .setDerivedFrom("root")
+            .setType("type3")
+            .setUniqueId("id3")
+            .setVersion("1.0")
+            .setName("type3name")
+            .setIcon("type3con")
+            .build();
         return asList(type1, type2, type3);
     }
 
 
-
 }
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java
index 6c1c447..36612eb 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -22,9 +22,29 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.when;
+
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import fj.data.Either;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.text.StrSubstitutor;
@@ -35,9 +55,10 @@
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
 import org.json.JSONException;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
 import org.openecomp.sdc.be.components.impl.GroupBusinessLogic;
@@ -68,41 +89,21 @@
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+class ResourceServletTest extends JerseyTest {
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.when;
-
-public class ResourceServletTest extends JerseyTest {
-    public static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
-    public static final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
-    private static final HttpSession session = Mockito.mock(HttpSession.class);
-    private static final ServletContext servletContext = Mockito.mock(ServletContext.class);
-    private static final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
-    private static final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
-    public static final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
-    public static final ComponentsUtils componentUtils = Mockito.mock(ComponentsUtils.class);
-    private static final UserBusinessLogic userAdmin = Mockito.mock(UserBusinessLogic.class);
-    private static final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
-    private static final GroupBusinessLogic groupBL = Mockito.mock(GroupBusinessLogic.class);
-    private static final ComponentInstanceBusinessLogic componentInstanceBL = Mockito.mock(ComponentInstanceBusinessLogic.class);
-    private static final ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
+    private final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+    private final ResourceImportManager resourceImportManager = Mockito.mock(ResourceImportManager.class);
+    private final HttpSession session = Mockito.mock(HttpSession.class);
+    private final ServletContext servletContext = Mockito.mock(ServletContext.class);
+    private final WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
+    private final WebApplicationContext webApplicationContext = Mockito.mock(WebApplicationContext.class);
+    private final ServletUtils servletUtils = Mockito.mock(ServletUtils.class);
+    private final ComponentsUtils componentUtils = Mockito.mock(ComponentsUtils.class);
+    private final UserBusinessLogic userAdmin = Mockito.mock(UserBusinessLogic.class);
+    private final UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class);
+    private final GroupBusinessLogic groupBL = Mockito.mock(GroupBusinessLogic.class);
+    private final ComponentInstanceBusinessLogic componentInstanceBL = Mockito.mock(ComponentInstanceBusinessLogic.class);
+    private final ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
     private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
     private static final ResponseFormat okResponseFormat = new ResponseFormat(HttpStatus.SC_OK);
     private static final ResponseFormat conflictResponseFormat = new ResponseFormat(HttpStatus.SC_CONFLICT);
@@ -111,8 +112,8 @@
     private static final ResponseFormat noContentResponseFormat = new ResponseFormat(HttpStatus.SC_NO_CONTENT);
     private static final ResponseFormat notFoundResponseFormat = new ResponseFormat(HttpStatus.SC_NOT_FOUND);
     private static final ResponseFormat badRequestResponseFormat = new ResponseFormat(HttpStatus.SC_BAD_REQUEST);
-    private static final ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration
-        .getChangeListener(), "src/test/resources/config/catalog-be");
+    private static final ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+        "src/test/resources/config/catalog-be");
     private static final ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
     private static final String RESOURCE_NAME = "resourceName";
     private static final String VERSION = "version";
@@ -122,17 +123,30 @@
     private static final String CSAR_UUID = "csaruuid";
     private static final String EMPTY_JSON = "{}";
     private static final String NON_UI_IMPORT_JSON = "{\n" +
-            "  \"node1\": \"value1\",\n" +
-            "  \"node2\": {\n" +
-            "    \"level21\": \"value21\",\n" +
-            "    \"level22\": \"value22\"\n" +
-            "  }\n" +
-            "}";
+        "  \"node1\": \"value1\",\n" +
+        "  \"node2\": {\n" +
+        "    \"level21\": \"value21\",\n" +
+        "    \"level22\": \"value22\"\n" +
+        "  }\n" +
+        "}";
     private static User user;
 
-    @BeforeClass
+    @BeforeAll
     public static void setup() {
         ExternalConfiguration.setAppName("catalog-be");
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
+
+    @BeforeEach
+    public void beforeTest() throws Exception {
+        super.setUp();
+        Mockito.reset(componentUtils);
+        Mockito.reset(resourceBusinessLogic);
+
         when(request.getSession()).thenReturn(session);
         when(session.getServletContext()).thenReturn(servletContext);
         when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
@@ -147,28 +161,22 @@
         user.setRole(Role.ADMIN.name());
         when(userAdmin.getUser(userId)).thenReturn(user);
         when(request.getHeader(Constants.USER_ID_HEADER)).thenReturn(userId);
-
         ImmutablePair<Resource, ActionStatus> pair = new ImmutablePair<>(new Resource(), ActionStatus.OK);
-        when(resourceImportManager.importUserDefinedResource(Mockito.anyString(), Mockito.any(UploadResourceInfo.class), Mockito.any(User.class), Mockito.anyBoolean())).thenReturn(pair);
+        when(resourceImportManager
+            .importUserDefinedResource(Mockito.anyString(), Mockito.any(UploadResourceInfo.class), Mockito.any(User.class), Mockito.anyBoolean()))
+            .thenReturn(pair);
         when(webApplicationContext.getBean(ResourceBusinessLogic.class)).thenReturn(resourceBusinessLogic);
 
-    }
-
-    @Before
-    public void beforeTest() {
-        Mockito.reset(componentUtils);
-        Mockito.reset(resourceBusinessLogic);
-
-        when(componentUtils.getResponseFormat(ActionStatus.OK)) .thenReturn(okResponseFormat);
+        when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(okResponseFormat);
         when(componentUtils.getResponseFormat(ActionStatus.CREATED)).thenReturn(createdResponseFormat);
         when(componentUtils.getResponseFormat(ActionStatus.NO_CONTENT)).thenReturn(noContentResponseFormat);
         when(componentUtils.getResponseFormat(ActionStatus.INVALID_CONTENT)).thenReturn(badRequestResponseFormat);
-        when(componentUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)) .thenReturn(generalErrorResponseFormat);
-        when(componentUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND)) .thenReturn(notFoundResponseFormat);
+        when(componentUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)).thenReturn(generalErrorResponseFormat);
+        when(componentUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND)).thenReturn(notFoundResponseFormat);
     }
 
     @Test
-    public void testHappyScenarioTest() {
+    void testHappyScenarioTest() {
         when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(createdResponseFormat);
 
         UploadResourceInfo validJson = buildValidJson();
@@ -182,20 +190,21 @@
     }
 
     @Test
-    public void testNonValidMd5Fail() {
+    void testNonValidMd5Fail() {
         UploadResourceInfo validJson = buildValidJson();
 
         setMD5OnRequest(false, validJson);
 
-        Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON).post(Entity.json(gson.toJson(validJson)), Response.class);
+        Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON)
+            .post(Entity.json(gson.toJson(validJson)), Response.class);
         Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(Mockito.any(ActionStatus.class));
         Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(ActionStatus.INVALID_RESOURCE_CHECKSUM);
-        assertEquals(response.getStatus(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
 
     }
 
     @Test
-    public void testNonValidPayloadNameFail() {
+    void testNonValidPayloadNameFail() {
         UploadResourceInfo mdJson = buildValidJson();
         mdJson.setPayloadName("myCompute.xml");
 
@@ -204,7 +213,7 @@
     }
 
     @Test
-    public void testNullPayloadFail() {
+    void testNullPayloadFail() {
         UploadResourceInfo mdJson = buildValidJson();
         mdJson.setPayloadData(null);
         runAndVerifyActionStatusError(mdJson, ActionStatus.INVALID_RESOURCE_PAYLOAD);
@@ -212,7 +221,7 @@
     }
 
     @Test
-    public void testNonYmlPayloadFail() {
+    void testNonYmlPayloadFail() {
         UploadResourceInfo mdJson = buildValidJson();
         String payload = "{ json : { isNot : yaml } ";
         encodeAndSetPayload(mdJson, payload);
@@ -221,20 +230,23 @@
     }
 
     @Test
-    public void testNonToscaPayloadFail() {
+    void testNonToscaPayloadFail() {
         UploadResourceInfo mdJson = buildValidJson();
 
-        String payload = "node_types: \r\n" + "  org.openecomp.resource.importResource4test:\r\n" + "    derived_from: tosca.nodes.Root\r\n" + "    description: update update";
+        String payload = "node_types: \r\n" + "  org.openecomp.resource.importResource4test:\r\n" + "    derived_from: tosca.nodes.Root\r\n"
+            + "    description: update update";
         encodeAndSetPayload(mdJson, payload);
         runAndVerifyActionStatusError(mdJson, ActionStatus.INVALID_TOSCA_TEMPLATE);
 
     }
 
     @Test
-    public void testServiceToscaPayloadFail() {
+    void testServiceToscaPayloadFail() {
         UploadResourceInfo mdJson = buildValidJson();
 
-        String payload = "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n" + "  org.openecomp.resource.importResource4test:\r\n" + "    derived_from: tosca.nodes.Root\r\n" + "    topology_template: thisIsService\r\n"
+        String payload =
+            "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n" + "  org.openecomp.resource.importResource4test:\r\n"
+                + "    derived_from: tosca.nodes.Root\r\n" + "    topology_template: thisIsService\r\n"
                 + "    description: update update";
 
         encodeAndSetPayload(mdJson, payload);
@@ -243,10 +255,12 @@
     }
 
     @Test
-    public void testMultipleResourcesInPayloadFail() {
+    void testMultipleResourcesInPayloadFail() {
         UploadResourceInfo mdJson = buildValidJson();
 
-        String payload = "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n" + "  org.openecomp.resource.importResource4test2:\r\n" + "    derived_from: tosca.nodes.Root\r\n" + "  org.openecomp.resource.importResource4test:\r\n"
+        String payload =
+            "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n" + "  org.openecomp.resource.importResource4test2:\r\n"
+                + "    derived_from: tosca.nodes.Root\r\n" + "  org.openecomp.resource.importResource4test:\r\n"
                 + "    derived_from: tosca.nodes.Root\r\n" + "    description: update update";
 
         encodeAndSetPayload(mdJson, payload);
@@ -255,7 +269,7 @@
     }
 
     @Test
-    public void testNonValidNameSpaceInPayloadFail() {
+    void testNonValidNameSpaceInPayloadFail() {
         UploadResourceInfo mdJson = buildValidJson();
 
         String payload = "tosca_definitions_version: tosca_simple_yaml_1_0_0\r\n" + "node_types: \r\n"
@@ -267,716 +281,732 @@
     }
 
     @Test
-    public void deleteResourceTryDeleteNonExistingResourceTest() {
+    void deleteResourceTryDeleteNonExistingResourceTest() {
         String resourceId = "resourceId";
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put("resourceId", resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         when(resourceBusinessLogic.deleteResource(any(), any(User.class)))
-                .thenReturn(notFoundResponseFormat);
+            .thenReturn(notFoundResponseFormat);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .delete();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .delete();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
     }
 
     @Test
-    public void deleteResourceExceptionDuringDeletingTest() {
+    void deleteResourceExceptionDuringDeletingTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         when(resourceBusinessLogic.deleteResource(any(), any(User.class)))
-                .thenThrow(new JSONException("Test exception: deleteResource"));
+            .thenThrow(new JSONException("Test exception: deleteResource"));
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .delete();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .delete();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void deleteResourceCategoryTest() {
+    void deleteResourceCategoryTest() {
         String resourceId = "resourceId";
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put("resourceId", resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         when(resourceBusinessLogic.deleteResource(eq(resourceId.toLowerCase()), any(User.class)))
-                .thenReturn(noContentResponseFormat);
+            .thenReturn(noContentResponseFormat);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .delete();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .delete();
 
         assertThat(response.getStatus()).isEqualTo(org.apache.http.HttpStatus.SC_NO_CONTENT);
     }
 
     @Test
-    public void deleteResourceByNameAndVersionTryDeleteNonExistingResourceTest() {
+    void deleteResourceByNameAndVersionTryDeleteNonExistingResourceTest() {
         String resourceName = RESOURCE_NAME;
         String version = VERSION;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_NAME, resourceName);
         parametersMap.put(VERSION, version);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceName}/{version}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         when(resourceBusinessLogic.deleteResourceByNameAndVersion(eq(resourceName), eq(version), any(User.class)))
-                .thenReturn(notFoundResponseFormat);
+            .thenReturn(notFoundResponseFormat);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .delete();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .delete();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
     }
 
     @Test
-    public void deleteResourceByNameAndVersionExceptionDuringDeletingTest() {
+    void deleteResourceByNameAndVersionExceptionDuringDeletingTest() {
         String resourceName = RESOURCE_NAME;
         String version = VERSION;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_NAME, resourceName);
         parametersMap.put(VERSION, version);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceName}/{version}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         when(resourceBusinessLogic.deleteResourceByNameAndVersion(eq(resourceName), eq(version), any(User.class)))
-                .thenThrow(new JSONException("Test exception: deleteResourceByNameAndVersion"));
+            .thenThrow(new JSONException("Test exception: deleteResourceByNameAndVersion"));
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .delete();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .delete();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void deleteResourceByNameAndVersionCategoryTest() {
+    void deleteResourceByNameAndVersionCategoryTest() {
         String resourceName = RESOURCE_NAME;
         String version = VERSION;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_NAME, resourceName);
         parametersMap.put(VERSION, version);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceName}/{version}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         when(resourceBusinessLogic.deleteResourceByNameAndVersion(eq(resourceName), eq(version), any(User.class)))
-                .thenReturn(noContentResponseFormat);
+            .thenReturn(noContentResponseFormat);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .delete();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .delete();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NO_CONTENT);
     }
 
     @Test
-    public void getResourceByIdTryGetNonExistingResourceTest() {
+    void getResourceByIdTryGetNonExistingResourceTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Resource, ResponseFormat> getResourceByIdEither = Either.right(notFoundResponseFormat);
         when(resourceBusinessLogic.getResource(eq(resourceId.toLowerCase()), any(User.class)))
-                .thenReturn(getResourceByIdEither);
+            .thenReturn(getResourceByIdEither);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
     }
 
     @Test
-    public void getResourceByIdExceptionDuringSearchingTest() {
+    void getResourceByIdExceptionDuringSearchingTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         given(resourceBusinessLogic.getResource(eq(resourceId.toLowerCase()), any(User.class)))
-                .willAnswer( invocation -> { throw new IOException("Test exception: getResourceById"); });
+            .willAnswer(invocation -> {
+                throw new IOException("Test exception: getResourceById");
+            });
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void getResourceByIdTest() {
+    void getResourceByIdTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Resource, ResponseFormat> getResourceByIdEither = Either.left(new Resource());
         when(resourceBusinessLogic.getResource(eq(resourceId.toLowerCase()), any(User.class)))
-                .thenReturn(getResourceByIdEither);
+            .thenReturn(getResourceByIdEither);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
     }
 
     @Test
-    public void getResourceByNameAndVersionTryGetNonExistingResourceTest() {
+    void getResourceByNameAndVersionTryGetNonExistingResourceTest() {
         String resourceName = RESOURCE_NAME;
         String resourceVersion = RESOURCE_VERSION;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_NAME, resourceName);
         parametersMap.put(RESOURCE_VERSION, resourceVersion);
 
         String formatEndpoint = "/v1/catalog/resources/resourceName/{resourceName}/resourceVersion/{resourceVersion}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Resource, ResponseFormat> getResourceByNameAndVersionEither = Either.right(notFoundResponseFormat);
         when(resourceBusinessLogic.getResourceByNameAndVersion(eq(resourceName), eq(resourceVersion), eq(user.getUserId())))
-                .thenReturn(getResourceByNameAndVersionEither);
+            .thenReturn(getResourceByNameAndVersionEither);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
     }
 
     @Test
-    public void getResourceByNameAndVersionExceptionDuringSearchingTest() {
+    void getResourceByNameAndVersionExceptionDuringSearchingTest() {
         String resourceName = RESOURCE_NAME;
         String resourceVersion = RESOURCE_VERSION;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_NAME, resourceName);
         parametersMap.put(RESOURCE_VERSION, resourceVersion);
 
         String formatEndpoint = "/v1/catalog/resources/resourceName/{resourceName}/resourceVersion/{resourceVersion}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         given(resourceBusinessLogic.getResourceByNameAndVersion(eq(resourceName), eq(resourceVersion), eq(user.getUserId())))
-                .willAnswer( invocation -> { throw new IOException("Test exception: getResourceByNameAndVersion"); });
+            .willAnswer(invocation -> {
+                throw new IOException("Test exception: getResourceByNameAndVersion");
+            });
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void getResourceByNameAndVersionTest() {
+    void getResourceByNameAndVersionTest() {
         String resourceName = RESOURCE_NAME;
         String resourceVersion = RESOURCE_VERSION;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_NAME, resourceName);
         parametersMap.put(RESOURCE_VERSION, resourceVersion);
 
         String formatEndpoint = "/v1/catalog/resources/resourceName/{resourceName}/resourceVersion/{resourceVersion}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Resource, ResponseFormat> getResourceByNameAndVersionEither = Either.left(new Resource());
         when(resourceBusinessLogic.getResourceByNameAndVersion(eq(resourceName), eq(resourceVersion), eq(user.getUserId())))
-                .thenReturn(getResourceByNameAndVersionEither);
+            .thenReturn(getResourceByNameAndVersionEither);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
     }
 
     @Test
-    public void validateResourceNameTryValidateNonExistingResourceTest() {
+    void validateResourceNameTryValidateNonExistingResourceTest() {
         String resourceName = RESOURCE_NAME;
         String resourceType = "VFC";
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_NAME, resourceName);
 
         String formatEndpoint = "/v1/catalog/resources/validate-name/{resourceName}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Map<String, Boolean>, ResponseFormat> validateResourceNameEither =
-                Either.right(notFoundResponseFormat);
+            Either.right(notFoundResponseFormat);
         ResourceTypeEnum resourceTypeEnum = ResourceTypeEnum.valueOf(resourceType);
         when(resourceBusinessLogic.validateResourceNameExists(eq(resourceName), eq(resourceTypeEnum), eq(user.getUserId())))
-                .thenReturn(validateResourceNameEither);
+            .thenReturn(validateResourceNameEither);
 
         Response response = target()
-                .path(path)
-                .queryParam(SUBTYPE, resourceType)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .queryParam(SUBTYPE, resourceType)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_NOT_FOUND);
     }
 
     @Test
-    public void validateResourceNameInvalidContentTest() {
+    void validateResourceNameInvalidContentTest() {
         String resourceName = RESOURCE_NAME;
         String resourceType = "ThisIsInvalid";
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_NAME, resourceName);
 
         String formatEndpoint = "/v1/catalog/resources/validate-name/{resourceName}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Response response = target()
-                .path(path)
-                .queryParam(SUBTYPE, resourceType)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .queryParam(SUBTYPE, resourceType)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
     }
 
     @Test
-    public void validateResourceNameTest() {
+    void validateResourceNameTest() {
         String resourceName = RESOURCE_NAME;
         String resourceType = "VFC";
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_NAME, resourceName);
 
         String formatEndpoint = "/v1/catalog/resources/validate-name/{resourceName}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Map<String, Boolean>, ResponseFormat> validateResourceNameEither =
-                Either.left(new HashMap<>());
+            Either.left(new HashMap<>());
         ResourceTypeEnum resourceTypeEnum = ResourceTypeEnum.valueOf(resourceType);
         when(resourceBusinessLogic.validateResourceNameExists(eq(resourceName), eq(resourceTypeEnum), eq(user.getUserId())))
-                .thenReturn(validateResourceNameEither);
+            .thenReturn(validateResourceNameEither);
 
         Response response = target()
-                .path(path)
-                .queryParam(SUBTYPE, resourceType)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .queryParam(SUBTYPE, resourceType)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
     }
 
     @Test
-    public void getCertifiedAbstractResourcesExceptionDuringSearchingTest() {
+    void getCertifiedAbstractResourcesExceptionDuringSearchingTest() {
         String path = "/v1/catalog/resources/certified/abstract";
         given(resourceBusinessLogic.getAllCertifiedResources(eq(true), eq(HighestFilterEnum.HIGHEST_ONLY),
-                eq(user.getUserId())))
-                .willAnswer( invocation -> { throw new IOException("Test exception: getCertifiedAbstractResources"); });
+            eq(user.getUserId())))
+            .willAnswer(invocation -> {
+                throw new IOException("Test exception: getCertifiedAbstractResources");
+            });
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void getCertifiedAbstractResourcesTest() {
+    void getCertifiedAbstractResourcesTest() {
         String path = "/v1/catalog/resources/certified/abstract";
 
         List<Resource> resources = Arrays.asList(new Resource(), new Resource());
         when(resourceBusinessLogic.getAllCertifiedResources(eq(true), eq(HighestFilterEnum.HIGHEST_ONLY),
-                eq(user.getUserId())))
-                .thenReturn(resources);
+            eq(user.getUserId())))
+            .thenReturn(resources);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
     }
 
     @Test
-    public void getCertifiedNotAbstractResourcesExceptionDuringSearchingTest() {
+    void getCertifiedNotAbstractResourcesExceptionDuringSearchingTest() {
         String path = "/v1/catalog/resources/certified/notabstract";
         given(resourceBusinessLogic.getAllCertifiedResources(eq(false), eq(HighestFilterEnum.ALL),
-                eq(user.getUserId())))
-                .willAnswer( invocation -> { throw new IOException("Test exception: getCertifiedNotAbstractResources"); });
+            eq(user.getUserId())))
+            .willAnswer(invocation -> {
+                throw new IOException("Test exception: getCertifiedNotAbstractResources");
+            });
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void getCertifiedNotAbstractResourcesTest() {
+    void getCertifiedNotAbstractResourcesTest() {
         String path = "/v1/catalog/resources/certified/notabstract";
 
         List<Resource> resources = Arrays.asList(new Resource(), new Resource());
         when(resourceBusinessLogic.getAllCertifiedResources(eq(true), eq(HighestFilterEnum.ALL),
-                eq(user.getUserId())))
-                .thenReturn(resources);
+            eq(user.getUserId())))
+            .thenReturn(resources);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
     }
 
     @Test
-    public void updateResourceMetadataTryUpdateNonExistingResourceTest() {
+    void updateResourceMetadataTryUpdateNonExistingResourceTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}/metadata";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Resource, ResponseFormat> updateResourceMetadataEither = Either.right(badRequestResponseFormat);
 
         when(componentUtils.convertJsonToObjectUsingObjectMapper(any(), any(), eq(Resource.class),
-                eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
-                .thenReturn(updateResourceMetadataEither);
+            eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
+            .thenReturn(updateResourceMetadataEither);
 
         when(resourceBusinessLogic.updateResourceMetadata(eq(resourceId.toLowerCase()), any(), any(), any(User.class),
-                eq(false)))
-                .thenReturn(new Resource());
+            eq(false)))
+            .thenReturn(new Resource());
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .put(Entity.json(EMPTY_JSON));
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .put(Entity.json(EMPTY_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
     }
 
     @Test
-    public void updateResourceMetadataExceptionDuringUpdateTest() {
+    void updateResourceMetadataExceptionDuringUpdateTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}/metadata";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         given(componentUtils.convertJsonToObjectUsingObjectMapper(any(), any(), eq(Resource.class),
-                eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
-                .willAnswer( invocation -> { throw new IOException("Test exception: updateResourceMetadata"); });
+            eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
+            .willAnswer(invocation -> {
+                throw new IOException("Test exception: updateResourceMetadata");
+            });
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .put(Entity.json(EMPTY_JSON));
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .put(Entity.json(EMPTY_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void updateResourceMetadataCategoryTest() {
+    void updateResourceMetadataCategoryTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}/metadata";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Resource initialResource = new Resource();
         Either<Resource, ResponseFormat> updateResourceMetadataEither = Either.left(initialResource);
 
         when(componentUtils.convertJsonToObjectUsingObjectMapper(any(), any(), eq(Resource.class),
-                eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
-                .thenReturn(updateResourceMetadataEither);
+            eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
+            .thenReturn(updateResourceMetadataEither);
 
         when(resourceBusinessLogic.updateResourceMetadata(eq(resourceId.toLowerCase()), eq(initialResource), any(),
-                any(User.class), eq(false)))
-                .thenReturn(new Resource());
+            any(User.class), eq(false)))
+            .thenReturn(new Resource());
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .put(Entity.json(EMPTY_JSON));
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .put(Entity.json(EMPTY_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
     }
 
     @Test
-    public void updateResourceParsingUncussessfulTest() {
+    void updateResourceParsingUncussessfulTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Resource, ResponseFormat> updateResourceEither = Either.right(badRequestResponseFormat);
 
         when(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
-                eq(Resource.class), eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
-                .thenReturn(updateResourceEither);
+            eq(Resource.class), eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
+            .thenReturn(updateResourceEither);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .put(Entity.json(NON_UI_IMPORT_JSON));
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .put(Entity.json(NON_UI_IMPORT_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
     }
 
     @Test
-    public void updateResourceExceptionDuringUpdateTest() {
+    void updateResourceExceptionDuringUpdateTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         given(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
-                eq(Resource.class), eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
-                .willAnswer( invocation -> { throw new IOException("Test exception: updateResource"); });
+            eq(Resource.class), eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
+            .willAnswer(invocation -> {
+                throw new IOException("Test exception: updateResource");
+            });
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .put(Entity.json(NON_UI_IMPORT_JSON));
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .put(Entity.json(NON_UI_IMPORT_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void updateResourceNonUiImportTest() {
+    void updateResourceNonUiImportTest() {
         String resourceId = RESOURCE_ID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(RESOURCE_ID, resourceId);
 
         String formatEndpoint = "/v1/catalog/resources/{resourceId}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Resource, ResponseFormat> updateResourceEither = Either.left(new Resource());
 
         when(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class), eq(Resource.class),
-                eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
-                .thenReturn(updateResourceEither);
+            eq(AuditingActionEnum.UPDATE_RESOURCE_METADATA), eq(ComponentTypeEnum.RESOURCE)))
+            .thenReturn(updateResourceEither);
 
         when(resourceBusinessLogic.validateAndUpdateResourceFromCsar(any(), any(), any(), any(), eq(resourceId)))
-                .thenReturn(new Resource());
+            .thenReturn(new Resource());
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .put(Entity.json(NON_UI_IMPORT_JSON));
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .put(Entity.json(NON_UI_IMPORT_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
     }
 
     @Test
-    public void getResourceFromCsarTryGetNonExistingResourceTest() {
+    void getResourceFromCsarTryGetNonExistingResourceTest() {
         String csarUuid = CSAR_UUID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(CSAR_UUID, csarUuid);
 
         String formatEndpoint = "/v1/catalog/resources/csar/{csaruuid}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
-        
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
+
         Either<Resource, ResponseFormat> getResourceFromCsarEither = Either.right(notFoundResponseFormat);
         when(resourceBusinessLogic.getLatestResourceFromCsarUuid(eq(csarUuid), any(User.class)))
-                .thenReturn(getResourceFromCsarEither);
+            .thenReturn(getResourceFromCsarEither);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
     }
 
     @Test
-    public void getResourceFromCsarExceptionDuringGettingTest() {
+    void getResourceFromCsarExceptionDuringGettingTest() {
         String csarUuid = CSAR_UUID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(CSAR_UUID, csarUuid);
 
         String formatEndpoint = "/v1/catalog/resources/csar/{csaruuid}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         given(resourceBusinessLogic.getLatestResourceFromCsarUuid(eq(csarUuid), any(User.class)))
-                .willAnswer( invocation -> { throw new IOException("Test exception: getResourceFromCsar"); });
+            .willAnswer(invocation -> {
+                throw new IOException("Test exception: getResourceFromCsar");
+            });
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void getResourceFromCsarTest() {
+    void getResourceFromCsarTest() {
         String csarUuid = CSAR_UUID;
-        Map<String,String> parametersMap = new HashMap<>();
+        Map<String, String> parametersMap = new HashMap<>();
         parametersMap.put(CSAR_UUID, csarUuid);
 
         String formatEndpoint = "/v1/catalog/resources/csar/{csaruuid}";
-        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{","}");
+        String path = StrSubstitutor.replace(formatEndpoint, parametersMap, "{", "}");
 
         Either<Resource, ResponseFormat> getResourceFromCsarEither = Either.left(new Resource());
         when(resourceBusinessLogic.getLatestResourceFromCsarUuid(eq(csarUuid), any(User.class)))
-                .thenReturn(getResourceFromCsarEither);
+            .thenReturn(getResourceFromCsarEither);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .get();
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .get();
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_OK);
     }
 
     @Test
-    public void createResourceExceptionDuringCreateTest() {
+    void createResourceExceptionDuringCreateTest() {
         String path = "/v1/catalog/resources";
 
         given(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
-                eq(Resource.class), eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.RESOURCE)))
-                .willAnswer( invocation -> { throw new IOException("Test exception: createResource"); });
+            eq(Resource.class), eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.RESOURCE)))
+            .willAnswer(invocation -> {
+                throw new IOException("Test exception: createResource");
+            });
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .post(Entity.json(NON_UI_IMPORT_JSON));
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .post(Entity.json(NON_UI_IMPORT_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
     }
 
     @Test
-    public void createResourceNonUiImportProcessingFailedTest() {
+    void createResourceNonUiImportProcessingFailedTest() {
         String path = "/v1/catalog/resources";
 
         Either<Resource, ResponseFormat> createResourceEither = Either.right(badRequestResponseFormat);
 
         when(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
-                eq(Resource.class), eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.RESOURCE)))
-                .thenReturn(createResourceEither);
+            eq(Resource.class), eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.RESOURCE)))
+            .thenReturn(createResourceEither);
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .post(Entity.json(NON_UI_IMPORT_JSON));
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .post(Entity.json(NON_UI_IMPORT_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
     }
 
     @Test
-    public void createResourceNonUiImportTest() {
+    void createResourceNonUiImportTest() {
         String path = "/v1/catalog/resources";
 
         Either<Resource, ResponseFormat> createResourceEither = Either.left(new Resource());
 
         when(componentUtils.convertJsonToObjectUsingObjectMapper(eq(NON_UI_IMPORT_JSON), any(User.class),
-                eq(Resource.class), eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.RESOURCE)))
-                .thenReturn(createResourceEither);
+            eq(Resource.class), eq(AuditingActionEnum.CREATE_RESOURCE), eq(ComponentTypeEnum.RESOURCE)))
+            .thenReturn(createResourceEither);
 
         when(resourceBusinessLogic.createResource(eq(createResourceEither.left().value()), eq(AuditingActionEnum.CREATE_RESOURCE),
-                any(User.class), any(), any()))
-                .thenReturn(new Resource());
+            any(User.class), any(), any()))
+            .thenReturn(new Resource());
 
         Response response = target()
-                .path(path)
-                .request()
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, user.getUserId())
-                .post(Entity.json(NON_UI_IMPORT_JSON));
+            .path(path)
+            .request()
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, user.getUserId())
+            .post(Entity.json(NON_UI_IMPORT_JSON));
 
         assertThat(response.getStatus()).isEqualTo(HttpStatus.SC_CREATED);
     }
@@ -988,10 +1018,11 @@
 
     private void runAndVerifyActionStatusError(UploadResourceInfo mdJson, ActionStatus invalidResourcePayload) {
         setMD5OnRequest(true, mdJson);
-        Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON).post(Entity.json(gson.toJson(mdJson)), Response.class);
+        Response response = target().path("/v1/catalog/resources").request(MediaType.APPLICATION_JSON)
+            .post(Entity.json(gson.toJson(mdJson)), Response.class);
         Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(Mockito.any(ActionStatus.class));
         Mockito.verify(componentUtils, Mockito.times(1)).getResponseFormat(invalidResourcePayload);
-        assertEquals(response.getStatus(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
+        assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus());
     }
 
     private void setMD5OnRequest(boolean isValid, UploadResourceInfo json) {
@@ -1012,7 +1043,7 @@
         ret.setIcon("router");
         ret.setTags(Collections.singletonList("ciMyCompute"));
         ret.setPayloadData(
-                "dG9zY2FfZGVmaW5pdGlvbnNfdmVyc2lvbjogdG9zY2Ffc2ltcGxlX3lhbWxfMV8wXzANCm5vZGVfdHlwZXM6IA0KICBvcmcub3BlbmVjb21wLnJlc291cmNlLk15Q29tcHV0ZToNCiAgICBkZXJpdmVkX2Zyb206IHRvc2NhLm5vZGVzLlJvb3QNCiAgICBhdHRyaWJ1dGVzOg0KICAgICAgcHJpdmF0ZV9hZGRyZXNzOg0KICAgICAgICB0eXBlOiBzdHJpbmcNCiAgICAgIHB1YmxpY19hZGRyZXNzOg0KICAgICAgICB0eXBlOiBzdHJpbmcNCiAgICAgIG5ldHdvcmtzOg0KICAgICAgICB0eXBlOiBtYXANCiAgICAgICAgZW50cnlfc2NoZW1hOg0KICAgICAgICAgIHR5cGU6IHRvc2NhLmRhdGF0eXBlcy5uZXR3b3JrLk5ldHdvcmtJbmZvDQogICAgICBwb3J0czoNCiAgICAgICAgdHlwZTogbWFwDQogICAgICAgIGVudHJ5X3NjaGVtYToNCiAgICAgICAgICB0eXBlOiB0b3NjYS5kYXRhdHlwZXMubmV0d29yay5Qb3J0SW5mbw0KICAgIHJlcXVpcmVtZW50czoNCiAgICAgIC0gbG9jYWxfc3RvcmFnZTogDQogICAgICAgICAgY2FwYWJpbGl0eTogdG9zY2EuY2FwYWJpbGl0aWVzLkF0dGFjaG1lbnQNCiAgICAgICAgICBub2RlOiB0b3NjYS5ub2Rlcy5CbG9ja1N0b3JhZ2UNCiAgICAgICAgICByZWxhdGlvbnNoaXA6IHRvc2NhLnJlbGF0aW9uc2hpcHMuQXR0YWNoZXNUbw0KICAgICAgICAgIG9jY3VycmVuY2VzOiBbMCwgVU5CT1VOREVEXSAgDQogICAgY2FwYWJpbGl0aWVzOg0KICAgICAgaG9zdDogDQogICAgICAgIHR5cGU6IHRvc2NhLmNhcGFiaWxpdGllcy5Db250YWluZXINCiAgICAgICAgdmFsaWRfc291cmNlX3R5cGVzOiBbdG9zY2Eubm9kZXMuU29mdHdhcmVDb21wb25lbnRdIA0KICAgICAgZW5kcG9pbnQgOg0KICAgICAgICB0eXBlOiB0b3NjYS5jYXBhYmlsaXRpZXMuRW5kcG9pbnQuQWRtaW4gDQogICAgICBvczogDQogICAgICAgIHR5cGU6IHRvc2NhLmNhcGFiaWxpdGllcy5PcGVyYXRpbmdTeXN0ZW0NCiAgICAgIHNjYWxhYmxlOg0KICAgICAgICB0eXBlOiB0b3NjYS5jYXBhYmlsaXRpZXMuU2NhbGFibGUNCiAgICAgIGJpbmRpbmc6DQogICAgICAgIHR5cGU6IHRvc2NhLmNhcGFiaWxpdGllcy5uZXR3b3JrLkJpbmRhYmxl");
+            "dG9zY2FfZGVmaW5pdGlvbnNfdmVyc2lvbjogdG9zY2Ffc2ltcGxlX3lhbWxfMV8wXzANCm5vZGVfdHlwZXM6IA0KICBvcmcub3BlbmVjb21wLnJlc291cmNlLk15Q29tcHV0ZToNCiAgICBkZXJpdmVkX2Zyb206IHRvc2NhLm5vZGVzLlJvb3QNCiAgICBhdHRyaWJ1dGVzOg0KICAgICAgcHJpdmF0ZV9hZGRyZXNzOg0KICAgICAgICB0eXBlOiBzdHJpbmcNCiAgICAgIHB1YmxpY19hZGRyZXNzOg0KICAgICAgICB0eXBlOiBzdHJpbmcNCiAgICAgIG5ldHdvcmtzOg0KICAgICAgICB0eXBlOiBtYXANCiAgICAgICAgZW50cnlfc2NoZW1hOg0KICAgICAgICAgIHR5cGU6IHRvc2NhLmRhdGF0eXBlcy5uZXR3b3JrLk5ldHdvcmtJbmZvDQogICAgICBwb3J0czoNCiAgICAgICAgdHlwZTogbWFwDQogICAgICAgIGVudHJ5X3NjaGVtYToNCiAgICAgICAgICB0eXBlOiB0b3NjYS5kYXRhdHlwZXMubmV0d29yay5Qb3J0SW5mbw0KICAgIHJlcXVpcmVtZW50czoNCiAgICAgIC0gbG9jYWxfc3RvcmFnZTogDQogICAgICAgICAgY2FwYWJpbGl0eTogdG9zY2EuY2FwYWJpbGl0aWVzLkF0dGFjaG1lbnQNCiAgICAgICAgICBub2RlOiB0b3NjYS5ub2Rlcy5CbG9ja1N0b3JhZ2UNCiAgICAgICAgICByZWxhdGlvbnNoaXA6IHRvc2NhLnJlbGF0aW9uc2hpcHMuQXR0YWNoZXNUbw0KICAgICAgICAgIG9jY3VycmVuY2VzOiBbMCwgVU5CT1VOREVEXSAgDQogICAgY2FwYWJpbGl0aWVzOg0KICAgICAgaG9zdDogDQogICAgICAgIHR5cGU6IHRvc2NhLmNhcGFiaWxpdGllcy5Db250YWluZXINCiAgICAgICAgdmFsaWRfc291cmNlX3R5cGVzOiBbdG9zY2Eubm9kZXMuU29mdHdhcmVDb21wb25lbnRdIA0KICAgICAgZW5kcG9pbnQgOg0KICAgICAgICB0eXBlOiB0b3NjYS5jYXBhYmlsaXRpZXMuRW5kcG9pbnQuQWRtaW4gDQogICAgICBvczogDQogICAgICAgIHR5cGU6IHRvc2NhLmNhcGFiaWxpdGllcy5PcGVyYXRpbmdTeXN0ZW0NCiAgICAgIHNjYWxhYmxlOg0KICAgICAgICB0eXBlOiB0b3NjYS5jYXBhYmlsaXRpZXMuU2NhbGFibGUNCiAgICAgIGJpbmRpbmc6DQogICAgICAgIHR5cGU6IHRvc2NhLmNhcGFiaWxpdGllcy5uZXR3b3JrLkJpbmRhYmxl");
         return ret;
     }
 
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java
index c649f71..c948910 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,8 +20,26 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static java.util.Collections.emptyMap;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import fj.data.Either;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.eclipse.jetty.http.HttpStatus;
 import org.glassfish.jersey.client.ClientConfig;
@@ -34,8 +52,10 @@
 import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.openecomp.sdc.be.components.impl.CommonImportManager;
 import org.openecomp.sdc.be.components.validation.AccessValidations;
@@ -55,26 +75,7 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Import;
 
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import static java.util.Collections.emptyMap;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.isA;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class TypesUploadEndpointTest extends JerseySpringBaseTest {
+class TypesUploadEndpointTest extends JerseySpringBaseTest {
 
     static final String userId = "jh0003";
 
@@ -92,7 +93,8 @@
         TypesUploadEndpoint typesUploadEndpoint() {
             UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class);
             ComponentsUtils componentsUtils = mock(ComponentsUtils.class);
-            return new TypesUploadEndpoint(userBusinessLogic, componentsUtils, commonImportManager(), annotationTypeOperations(), accessValidations);
+            return new TypesUploadEndpoint(userBusinessLogic, componentsUtils, commonImportManager(),
+                annotationTypeOperations(), accessValidations);
         }
 
         @Bean
@@ -111,7 +113,7 @@
         }
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void initClass() {
         janusGraphGenericDao = mock(HealingJanusGraphGenericDao.class);
         accessValidations = mock(AccessValidations.class);
@@ -120,10 +122,20 @@
         operationUtils = Mockito.mock(OperationUtils.class);
     }
 
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
+
     @Override
     protected void configureClient(ClientConfig config) {
         final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
-                .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         config.register(jacksonJsonProvider);
         config.register(MultiPartFeature.class);
     }
@@ -132,31 +144,37 @@
     protected ResourceConfig configure() {
         forceSet(TestProperties.CONTAINER_PORT, "0");
         return super.configure(TypesUploadEndpointTest.TypesUploadTestConfig.class)
-                .register(TypesUploadEndpoint.class)
-                .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, "WARNING");
+            .register(TypesUploadEndpoint.class)
+            .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, "WARNING");
     }
 
     @Test
-    public void creatingAnnotationTypeSuccessTest() {
+    void creatingAnnotationTypeSuccessTest() {
         doNothing().when(accessValidations).validateUserExists(eq(userId), anyString());
-        when(janusGraphGenericDao.createNode(isA(AnnotationTypeData.class), eq(AnnotationTypeData.class))).thenReturn(Either.left(new AnnotationTypeData()));
-        when(janusGraphGenericDao.getNode(anyString(), eq("org.openecomp.annotations.source.1.0.annotationtype"), eq(AnnotationTypeData.class))).thenReturn(Either.left(new AnnotationTypeData()));
-        when(janusGraphGenericDao.getByCriteria(eq(NodeTypeEnum.AnnotationType), anyMap(), eq(AnnotationTypeData.class))).thenReturn(Either.right(
-            JanusGraphOperationStatus.NOT_FOUND));
-        when(propertyOperation.addPropertiesToElementType(anyString(), eq(NodeTypeEnum.AnnotationType), anyList())).thenReturn(Either.left(emptyMap()));
+        when(janusGraphGenericDao.createNode(isA(AnnotationTypeData.class), eq(AnnotationTypeData.class)))
+            .thenReturn(Either.left(new AnnotationTypeData()));
+        when(janusGraphGenericDao.getNode(anyString(), eq("org.openecomp.annotations.source.1.0.annotationtype"),
+            eq(AnnotationTypeData.class))).thenReturn(Either.left(new AnnotationTypeData()));
+        when(
+            janusGraphGenericDao.getByCriteria(eq(NodeTypeEnum.AnnotationType), anyMap(), eq(AnnotationTypeData.class)))
+            .thenReturn(Either.right(
+                JanusGraphOperationStatus.NOT_FOUND));
+        when(propertyOperation.addPropertiesToElementType(anyString(), eq(NodeTypeEnum.AnnotationType), anyList()))
+            .thenReturn(Either.left(emptyMap()));
         when(propertyOperation.fillPropertiesList(anyString(), eq(NodeTypeEnum.AnnotationType), any())).thenReturn(
             JanusGraphOperationStatus.OK);
         when(propertyOperation.getJanusGraphGenericDao()).thenReturn(janusGraphGenericDao);
         when(janusGraphGenericDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
         when(janusGraphGenericDao.rollback()).thenReturn(JanusGraphOperationStatus.OK);
-        FileDataBodyPart filePart = new FileDataBodyPart("annotationTypesZip", new File("src/test/resources/types/annotationTypes.zip"));
+        FileDataBodyPart filePart = new FileDataBodyPart("annotationTypesZip",
+            new File("src/test/resources/types/annotationTypes.zip"));
         MultiPart multipartEntity = new FormDataMultiPart();
         multipartEntity.bodyPart(filePart);
 
         Response response = target().path("/v1/catalog/uploadType/annotationtypes")
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, userId)
-                .post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class);
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, userId)
+            .post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class);
         assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED_201);
         assertThat(Boolean.valueOf(getTypeActionResult(response))).isTrue();
     }
@@ -168,40 +186,46 @@
         if (indexColon > 0) {
             int indexCurly = body.indexOf('}', indexColon);
             if (indexCurly > 0) {
-                typeResult = body.substring(indexColon+1, indexCurly);
+                typeResult = body.substring(indexColon + 1, indexCurly);
             }
         }
         return typeResult;
     }
 
     @Test
-    public void creatingAnnotationTypeFailureTest() {
+    void creatingAnnotationTypeFailureTest() {
         doNothing().when(accessValidations).validateUserExists(eq(userId), anyString());
-        when(janusGraphGenericDao.createNode(isA(AnnotationTypeData.class), eq(AnnotationTypeData.class))).thenReturn(Either.left(new AnnotationTypeData()));
-        when(janusGraphGenericDao.getNode(anyString(), eq("org.openecomp.annotations.source.1.0.annotationtype"), eq(AnnotationTypeData.class))).thenReturn(Either.left(new AnnotationTypeData()));
-        when(janusGraphGenericDao.getByCriteria(eq(NodeTypeEnum.AnnotationType), anyMap(), eq(AnnotationTypeData.class))).thenReturn(Either.right(
-            JanusGraphOperationStatus.NOT_FOUND));
-        when(propertyOperation.addPropertiesToElementType(anyString(), eq(NodeTypeEnum.AnnotationType), anyList())).thenThrow(new StorageException(
-            JanusGraphOperationStatus.MATCH_NOT_FOUND));
+        when(janusGraphGenericDao.createNode(isA(AnnotationTypeData.class), eq(AnnotationTypeData.class)))
+            .thenReturn(Either.left(new AnnotationTypeData()));
+        when(janusGraphGenericDao.getNode(anyString(), eq("org.openecomp.annotations.source.1.0.annotationtype"),
+            eq(AnnotationTypeData.class))).thenReturn(Either.left(new AnnotationTypeData()));
+        when(
+            janusGraphGenericDao.getByCriteria(eq(NodeTypeEnum.AnnotationType), anyMap(), eq(AnnotationTypeData.class)))
+            .thenReturn(Either.right(
+                JanusGraphOperationStatus.NOT_FOUND));
+        when(propertyOperation.addPropertiesToElementType(anyString(), eq(NodeTypeEnum.AnnotationType), anyList()))
+            .thenThrow(new StorageException(
+                JanusGraphOperationStatus.MATCH_NOT_FOUND));
         when(propertyOperation.fillPropertiesList(anyString(), eq(NodeTypeEnum.AnnotationType), any())).thenReturn(
             JanusGraphOperationStatus.OK);
         when(propertyOperation.getJanusGraphGenericDao()).thenReturn(janusGraphGenericDao);
         when(janusGraphGenericDao.commit()).thenReturn(JanusGraphOperationStatus.OK);
         when(janusGraphGenericDao.rollback()).thenReturn(JanusGraphOperationStatus.OK);
-        FileDataBodyPart filePart = new FileDataBodyPart("annotationTypesZip", new File("src/test/resources/types/annotationTypes.zip"));
+        FileDataBodyPart filePart = new FileDataBodyPart("annotationTypesZip",
+            new File("src/test/resources/types/annotationTypes.zip"));
         MultiPart multipartEntity = new FormDataMultiPart();
         multipartEntity.bodyPart(filePart);
 
         Response response = target().path("/v1/catalog/uploadType/annotationtypes")
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, userId)
-                .post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class);
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, userId)
+            .post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class);
         assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST_400);
         assertThat(Boolean.valueOf(getTypeActionResult(response))).isFalse();
     }
 
     @Test
-    public void singleTypeSucceeded_statusIsCreated() {
+    void singleTypeSucceeded_statusIsCreated() {
         List<ImmutablePair<AnnotationTypeDefinition, Boolean>> typeActionResults = new ArrayList<>();
         AnnotationTypeDefinition dummyDefition = new AnnotationTypeDefinition();
         typeActionResults.add(new ImmutablePair(dummyDefition, true));
@@ -209,7 +233,7 @@
     }
 
     @Test
-    public void singleTypeExists_statusIsConflict() {
+    void singleTypeExists_statusIsConflict() {
         List<ImmutablePair<AnnotationTypeDefinition, Boolean>> typeActionResults = new ArrayList<>();
         AnnotationTypeDefinition dummyDefition = new AnnotationTypeDefinition();
         typeActionResults.add(new ImmutablePair(dummyDefition, null));
@@ -217,7 +241,7 @@
     }
 
     @Test
-    public void mixedSuccessAndExists_statusIsCreated() {
+    void mixedSuccessAndExists_statusIsCreated() {
         List<ImmutablePair<AnnotationTypeDefinition, Boolean>> typeActionResults = new ArrayList<>();
         AnnotationTypeDefinition dummyDefition = new AnnotationTypeDefinition();
         typeActionResults.add(new ImmutablePair(dummyDefition, true));
@@ -226,7 +250,7 @@
     }
 
     @Test
-    public void mixedSuccessAndFailure_statusIsBadRequest() {
+    void mixedSuccessAndFailure_statusIsBadRequest() {
         List<ImmutablePair<AnnotationTypeDefinition, Boolean>> typeActionResults = new ArrayList<>();
         AnnotationTypeDefinition dummyDefition = new AnnotationTypeDefinition();
         typeActionResults.add(new ImmutablePair(dummyDefition, true));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
index 5c6b7c9..993e68b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadServletTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,7 +20,19 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static java.util.Collections.emptyList;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
 import fj.data.Either;
+import java.io.File;
+import java.util.List;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.eclipse.jetty.http.HttpStatus;
 import org.glassfish.hk2.utilities.binding.AbstractBinder;
@@ -32,8 +44,10 @@
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.glassfish.jersey.test.TestProperties;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.openecomp.sdc.be.components.impl.CapabilityTypeImportManager;
 import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -55,20 +69,7 @@
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.web.context.WebApplicationContext;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.util.List;
-
-import static java.util.Collections.emptyList;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
-public class TypesUploadServletTest extends JerseyTest {
+class TypesUploadServletTest extends JerseyTest {
 
     public static final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
     private static final HttpSession session = Mockito.mock(HttpSession.class);
@@ -81,10 +82,11 @@
     private static final ComponentsUtils componentUtils = Mockito.mock(ComponentsUtils.class);
     private static final ResponseFormat responseFormat = Mockito.mock(ResponseFormat.class);
 
-    @BeforeClass
+    @BeforeAll
     public static void setup() {
         ExternalConfiguration.setAppName("catalog-be");
-        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+        when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+            .thenReturn(webAppContextWrapper);
         when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext);
         when(webApplicationContext.getBean(CapabilityTypeImportManager.class)).thenReturn(importManager);
         when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils);
@@ -101,17 +103,30 @@
 
     }
 
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
+    }
+
     @Test
-    public void creatingCapabilityTypeSuccessTest() {
-        Either<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, ResponseFormat> either = Either.left(emptyList());
+    void creatingCapabilityTypeSuccessTest() {
+        Either<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, ResponseFormat> either = Either
+            .left(emptyList());
         when(importManager.createCapabilityTypes(Mockito.anyString())).thenReturn(either);
-        FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip", new File("src/test/resources/types/capabilityTypes.zip"));
+        FileDataBodyPart filePart = new FileDataBodyPart("capabilityTypeZip",
+            new File("src/test/resources/types/capabilityTypes.zip"));
         MultiPart multipartEntity = new FormDataMultiPart();
         multipartEntity.bodyPart(filePart);
 
-        Response response = target().path("/v1/catalog/uploadType/capability").request(MediaType.APPLICATION_JSON).post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class);
+        Response response = target().path("/v1/catalog/uploadType/capability").request(MediaType.APPLICATION_JSON)
+            .post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA), Response.class);
 
-        assertEquals(response.getStatus(), HttpStatus.CREATED_201);
+        assertEquals(HttpStatus.CREATED_201, response.getStatus());
 
     }
 
@@ -123,37 +138,37 @@
     @Override
     protected ResourceConfig configure() {
 
-
-        forceSet(TestProperties.CONTAINER_PORT, "0");
         TypesUploadServlet typesUploadServlet = new TypesUploadServlet(null, null, componentUtils,
             servletUtils, null, importManager, null,
             null, null,
             null, null, null);
         ResourceConfig resourceConfig = new ResourceConfig()
-        .register(typesUploadServlet);
+            .register(typesUploadServlet);
 
         resourceConfig.register(MultiPartFeature.class);
         resourceConfig.register(new AbstractBinder() {
 
-                    @Override
-                    protected void configure() {
-                        // The below code was cut-pasted to here from setup() because
-                        // due to it now has
-                        // to be executed during servlet initialization
-                        bind(request).to(HttpServletRequest.class);
-                        when(request.getSession()).thenReturn(session);
-                        when(session.getServletContext()).thenReturn(servletContext);
-                        String appConfigDir = "src/test/resources/config/catalog-be";
-                        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
-                        ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
-                        for (String mandatoryHeader : configurationManager.getConfiguration().getIdentificationHeaderFields()) {
+            @Override
+            protected void configure() {
+                // The below code was cut-pasted to here from setup() because
+                // due to it now has
+                // to be executed during servlet initialization
+                bind(request).to(HttpServletRequest.class);
+                when(request.getSession()).thenReturn(session);
+                when(session.getServletContext()).thenReturn(servletContext);
+                String appConfigDir = "src/test/resources/config/catalog-be";
+                ConfigurationSource configurationSource = new FSConfigurationSource(
+                    ExternalConfiguration.getChangeListener(), appConfigDir);
+                ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+                for (String mandatoryHeader : configurationManager.getConfiguration().getIdentificationHeaderFields()) {
 
-                            when(request.getHeader(mandatoryHeader)).thenReturn(mandatoryHeader);
+                    when(request.getHeader(mandatoryHeader)).thenReturn(mandatoryHeader);
 
-                        }
+                }
 
-                        when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
-                    }
+                when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR))
+                    .thenReturn(configurationManager);
+            }
         });
         ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
         resourceConfig.property("contextConfig", context);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserEndpointTest.java
index 3e83199..ad97e02 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserEndpointTest.java
@@ -20,8 +20,22 @@
 
 package org.openecomp.sdc.be.servlets;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.openecomp.sdc.be.dao.utils.UserStatusEnum.ACTIVE;
+import static org.openecomp.sdc.be.dao.utils.UserStatusEnum.INACTIVE;
+import static org.openecomp.sdc.be.user.Role.ADMIN;
+import static org.openecomp.sdc.be.user.Role.DESIGNER;
+
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import fj.data.Either;
+import java.util.ArrayList;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import org.eclipse.jetty.http.HttpStatus;
 import org.glassfish.jersey.client.ClientConfig;
 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
@@ -31,9 +45,10 @@
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.TestProperties;
 import org.janusgraph.graphdb.types.system.EmptyVertex;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
@@ -54,26 +69,11 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Import;
 
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.ArrayList;
+class UserEndpointTest extends JerseySpringBaseTest {
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.openecomp.sdc.be.dao.utils.UserStatusEnum.ACTIVE;
-import static org.openecomp.sdc.be.dao.utils.UserStatusEnum.INACTIVE;
-import static org.openecomp.sdc.be.user.Role.ADMIN;
-import static org.openecomp.sdc.be.user.Role.DESIGNER;
-
-public class UserEndpointTest extends JerseySpringBaseTest {
-
-    static final String USER_ID = "jh0003";
-    static final String NEW_USER_ID = "ab0001";
-    static final String MODIFIER_ID = "admin1";
+    private static final String USER_ID = "jh0003";
+    private static final String NEW_USER_ID = "ab0001";
+    private static final String MODIFIER_ID = "admin1";
 
     private static ComponentsUtils componentUtils;
     private static JanusGraphGenericDao janusGraphGenericDao;
@@ -81,7 +81,6 @@
     private static LifecycleBusinessLogic lifecycleBusinessLogic;
     private static UserOperation facadeUserOperation;
 
-
     private UserData userData = new UserData();
     private UserData modifierData = new UserData();
 
@@ -102,7 +101,8 @@
 
         @Bean
         UserBusinessLogicExt userBusinessLogicExt() {
-            return new UserBusinessLogicExt(userBusinessLogic(), userAdminOperation(), lifecycleBusinessLogic, componentUtils);
+            return new UserBusinessLogicExt(userBusinessLogic(), userAdminOperation(), lifecycleBusinessLogic,
+                componentUtils);
         }
 
         @Bean
@@ -111,7 +111,7 @@
         }
     }
 
-    @BeforeClass
+    @BeforeAll
     public static void initClass() {
         janusGraphGenericDao = mock(JanusGraphGenericDao.class);
         componentUtils = mock(ComponentsUtils.class);
@@ -120,18 +120,26 @@
         facadeUserOperation = mock(UserOperation.class);
     }
 
-    @Before
-    public void setup() {
+    @BeforeEach
+    public void before() throws Exception {
+        super.setUp();
         setUserProperties(userData, USER_ID, DESIGNER, ACTIVE);
         setUserProperties(modifierData, MODIFIER_ID, ADMIN, ACTIVE);
         Either<UserData, JanusGraphOperationStatus> janusGraphValidUser = Either.left(userData);
         Either<UserData, JanusGraphOperationStatus> janusGraphValidModifier = Either.left(modifierData);
         when(janusGraphGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), USER_ID, UserData.class))
-                .thenReturn(janusGraphValidUser);
-        when(janusGraphGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), MODIFIER_ID, UserData.class))
-                .thenReturn(janusGraphValidModifier);
-        when(janusGraphGenericDao.getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), NEW_USER_ID, UserData.class))
-                .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+            .thenReturn(janusGraphValidUser);
+        when(janusGraphGenericDao
+            .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), MODIFIER_ID, UserData.class))
+            .thenReturn(janusGraphValidModifier);
+        when(janusGraphGenericDao
+            .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), NEW_USER_ID, UserData.class))
+            .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        super.tearDown();
     }
 
     private void setUserProperties(UserData user, String userId, Role role, UserStatusEnum statusEnum) {
@@ -143,7 +151,7 @@
     @Override
     protected void configureClient(ClientConfig config) {
         final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
-                .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+            .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         config.register(jacksonJsonProvider);
         config.register(MultiPartFeature.class);
     }
@@ -152,50 +160,50 @@
     protected ResourceConfig configure() {
         forceSet(TestProperties.CONTAINER_PORT, "0");
         return super.configure(UserEndpointTest.UserTestConfig.class)
-                .register(UserAdminServlet.class)
-                .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, "WARNING");
+            .register(UserAdminServlet.class)
+            .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, "WARNING");
     }
 
     @Test
-    public void getUser_success() {
+    void getUser_success() {
         User user = target().path("/v1/user/" + USER_ID)
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID)
-                .get(User.class);
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID)
+            .get(User.class);
         assertThat(user.getUserId()).isEqualTo(USER_ID);
     }
 
     @Test
-    public void getUserRole_success() {
+    void getUserRole_success() {
         String result = target().path("/v1/user/" + USER_ID + "/role")
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, MODIFIER_ID)
-                .get(String.class);
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, MODIFIER_ID)
+            .get(String.class);
         assertThat(result).isEqualTo("{ \"role\" : \"" + DESIGNER.name() + "\" }");
     }
 
     @Test
-    public void updateUserRole_success() {
+    void updateUserRole_success() {
         UserAdminServlet.UserRole role = new UserAdminServlet.UserRole();
         role.setRole(ADMIN);
         EmptyVertex emptyVertex = new EmptyVertex();
         UserData updatedUser = new UserData();
         setUserProperties(updatedUser, USER_ID, ADMIN, ACTIVE);
         when(janusGraphGenericDao.getVertexByProperty(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), USER_ID))
-                .thenReturn(Either.left(emptyVertex));
+            .thenReturn(Either.left(emptyVertex));
         when(janusGraphGenericDao.getOutgoingEdgesByCriteria(eq(emptyVertex), eq(GraphEdgeLabels.STATE), any()))
-                .thenReturn(Either.left(new ArrayList<>()));
+            .thenReturn(Either.left(new ArrayList<>()));
         when(janusGraphGenericDao.updateNode(eq(updatedUser), eq(UserData.class))).thenReturn(Either.left(updatedUser));
         User user = target().path("/v1/user/" + USER_ID + "/role")
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, MODIFIER_ID)
-                .post(Entity.entity(role, MediaType.APPLICATION_JSON),User.class);
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, MODIFIER_ID)
+            .post(Entity.entity(role, MediaType.APPLICATION_JSON), User.class);
         assertThat(user.getRole()).isEqualTo(ADMIN.name());
     }
 
     @Test
-    public void createUser_success() {
+    void createUser_success() {
         User newUser = new User();
         newUser.setUserId(NEW_USER_ID);
         UserData updatedUser = new UserData();
@@ -203,9 +211,9 @@
         //when(janusGraphGenericDao.updateNode(any(), eq(UserData.class))).thenReturn(Either.left(updatedUser));
         when(janusGraphGenericDao.createNode(any(), eq(UserData.class))).thenReturn(Either.left(updatedUser));
         Response response = target().path("/v1/user")
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, MODIFIER_ID)
-                .post(Entity.entity(newUser, MediaType.APPLICATION_JSON),Response.class);
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, MODIFIER_ID)
+            .post(Entity.entity(newUser, MediaType.APPLICATION_JSON), Response.class);
         assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED_201);
         User createdUser = response.readEntity(User.class);
         assertThat(createdUser.getUserId()).isEqualTo(NEW_USER_ID);
@@ -213,33 +221,33 @@
     }
 
     @Test
-    public void authorizeUser_success() {
+    void authorizeUser_success() {
         when(janusGraphGenericDao.updateNode(any(), eq(UserData.class))).thenReturn(Either.left(userData));
         User user = target().path("/v1/user/authorize")
-                .request(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, USER_ID)
-                .header("HTTP_CSP_FIRSTNAME", "Jimmy")
-                .header("HTTP_CSP_LASTNAME", "Hendrix")
-                .header("HTTP_CSP_EMAIL", "admin@sdc.com")
-                .get(User.class);
+            .request(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, USER_ID)
+            .header("HTTP_CSP_FIRSTNAME", "Jimmy")
+            .header("HTTP_CSP_LASTNAME", "Hendrix")
+            .header("HTTP_CSP_EMAIL", "admin@sdc.com")
+            .get(User.class);
         assertThat(user.getUserId()).isEqualTo(USER_ID);
     }
 
     @Test
-    public void deactivateUser_success() {
+    void deactivateUser_success() {
         EmptyVertex emptyVertex = new EmptyVertex();
         UserData updatedUser = new UserData();
         setUserProperties(updatedUser, USER_ID, DESIGNER, INACTIVE);
         when(janusGraphGenericDao.getVertexByProperty(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), USER_ID))
-                .thenReturn(Either.left(emptyVertex));
+            .thenReturn(Either.left(emptyVertex));
         when(janusGraphGenericDao.getOutgoingEdgesByCriteria(eq(emptyVertex), eq(GraphEdgeLabels.STATE), any()))
-                .thenReturn(Either.left(new ArrayList<>()));
+            .thenReturn(Either.left(new ArrayList<>()));
         when(janusGraphGenericDao.updateNode(eq(updatedUser), eq(UserData.class))).thenReturn(Either.left(updatedUser));
         User user = target().path("/v1/user/" + USER_ID)
-                .request(MediaType.APPLICATION_JSON)
-                .accept(MediaType.APPLICATION_JSON)
-                .header(Constants.USER_ID_HEADER, MODIFIER_ID)
-                .delete(User.class);
+            .request(MediaType.APPLICATION_JSON)
+            .accept(MediaType.APPLICATION_JSON)
+            .header(Constants.USER_ID_HEADER, MODIFIER_ID)
+            .delete(User.class);
         assertThat(user.getUserId()).isEqualTo(USER_ID);
     }
 
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserBusinessLogicTest.java
index 3e22152..3663076 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserBusinessLogicTest.java
@@ -7,9 +7,9 @@
  * 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.
@@ -20,8 +20,25 @@
 
 package org.openecomp.sdc.be.user;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import com.google.common.collect.Lists;
 import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
@@ -46,31 +63,12 @@
 import org.openecomp.sdc.be.model.operations.StorageException;
 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
 import org.openecomp.sdc.be.model.operations.impl.UserAdminOperation;
-import org.openecomp.sdc.common.api.ConfigurationSource;
 import org.openecomp.sdc.common.api.UserRoleEnum;
 import org.openecomp.sdc.common.datastructure.UserContext;
 import org.openecomp.sdc.common.impl.ExternalConfiguration;
 import org.openecomp.sdc.common.impl.FSConfigurationSource;
 import org.openecomp.sdc.common.util.ThreadLocalsHolder;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 @RunWith(MockitoJUnitRunner.class)
 public class UserBusinessLogicTest {
 
@@ -95,7 +93,8 @@
     @Before
     public void setUp() {
         new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be"));
-        doThrow(new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR)).when(componentsUtils).auditAdminUserActionAndThrowException(any(), any(), any(), any(), any(), any());
+        doThrow(new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR)).when(componentsUtils)
+            .auditAdminUserActionAndThrowException(any(), any(), any(), any(), any(), any());
     }
 
     @Test(expected = ComponentException.class)
@@ -110,6 +109,7 @@
 
     @Test(expected = ComponentException.class)
     public void testGetUserContextNull() {
+        ThreadLocalsHolder.setUserContext(null);
         testSubject.getUser("userId");
     }
 
@@ -127,7 +127,7 @@
         String userId = "userId";
         Set<String> userRoles = new HashSet<>();
         userRoles.add(Role.DESIGNER.name());
-        UserContext userContext = new UserContext(userId, userRoles, "test" ,"User");
+        UserContext userContext = new UserContext(userId, userRoles, "test", "User");
 
         User user = new User();
         user.setUserId(userId);
@@ -144,8 +144,7 @@
             ThreadLocalsHolder.setUserContext(userContext);
             User convertedUser = testSubject.getUser(userId);
             assertThat(convertedUser).isEqualTo(user);
-        }
-        finally {
+        } finally {
             ThreadLocalsHolder.setUserContext(originalUserContext);
         }
     }
@@ -156,7 +155,7 @@
         String userId = "userId";
         //Set<String> userRoles = new HashSet<>();
         //userRoles.add(Role.DESIGNER.name());
-        UserContext userContext = new UserContext(userId, null, "test" ,"User");
+        UserContext userContext = new UserContext(userId, null, "test", "User");
 
         User user = new User();
         user.setUserId(userId);
@@ -280,7 +279,7 @@
         verify(facadeUserOperation).updateUserCache(UserOperationEnum.CREATE, newUser.getUserId(), newUser.getRole());
     }
 
-    @Test(expected =  ComponentException.class)
+    @Test(expected = ComponentException.class)
     public void testUpdateUserRoleNotFound() {
         User modifier = new User(MOCK_MODIFIER);
         String userIdToUpdate = "";
@@ -292,7 +291,7 @@
         verify(facadeUserOperation, never()).updateUserCache(any(UserOperationEnum.class), anyString(), anyString());
     }
 
-    @Test(expected =  ComponentException.class)
+    @Test(expected = ComponentException.class)
     public void testUpdateUserRoleModifierWrongRole() {
         User modifier = new User(MOCK_MODIFIER);
         modifier.setRole(UserRoleEnum.DESIGNER.getName());
@@ -305,7 +304,7 @@
         verify(facadeUserOperation, never()).updateUserCache(any(UserOperationEnum.class), anyString(), anyString());
     }
 
-    @Test(expected =  ComponentException.class)
+    @Test(expected = ComponentException.class)
     public void testUpdateUserRoleSameId() {
         User modifier = new User(MOCK_MODIFIER);
         modifier.setRole(UserRoleEnum.ADMIN.getName());
@@ -317,7 +316,7 @@
         verify(facadeUserOperation, never()).updateUserCache(any(UserOperationEnum.class), anyString(), anyString());
     }
 
-    @Test(expected =  ComponentException.class)
+    @Test(expected = ComponentException.class)
     public void testUpdateUserRoleUpdatedNotFound() {
         User modifier = new User(MOCK_MODIFIER);
         modifier.setRole(UserRoleEnum.ADMIN.getName());
@@ -332,7 +331,7 @@
         verify(facadeUserOperation, never()).updateUserCache(any(UserOperationEnum.class), anyString(), anyString());
     }
 
-    @Test(expected =  ComponentException.class)
+    @Test(expected = ComponentException.class)
     public void testUpdateUserRoleUpdatedToInvalidRole() {
         User modifier = new User(MOCK_MODIFIER);
         modifier.setRole(UserRoleEnum.ADMIN.getName());
@@ -347,7 +346,7 @@
         verify(facadeUserOperation, never()).updateUserCache(any(UserOperationEnum.class), anyString(), anyString());
     }
 
-    @Test(expected =  StorageException.class)
+    @Test(expected = StorageException.class)
     public void testUpdateUserRolePendingTaskFetchFailed() {
         User modifier = new User(MOCK_MODIFIER);
         modifier.setRole(UserRoleEnum.ADMIN.getName());
@@ -360,7 +359,8 @@
 
         when(userAdminOperation.getUserData(modifier.getUserId(), false)).thenReturn(Either.left(modifier));
         when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(Either.left(updatedUser));
-        when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any())).thenThrow(new StorageException(StorageOperationStatus.INCONSISTENCY));
+        when(userAdminOperation.getUserPendingTasksList(Mockito.any(), Mockito.any()))
+            .thenThrow(new StorageException(StorageOperationStatus.INCONSISTENCY));
 
         // default test
         testSubject.updateUserRole(MOCK_MODIFIER, userIdToUpdate, userRole);
@@ -394,7 +394,7 @@
         verify(facadeUserOperation).updateUserCache(UserOperationEnum.CHANGE_ROLE, userIdToUpdate, UserRoleEnum.TESTER.name());
     }
 
-    @Test(expected =  ComponentException.class)
+    @Test(expected = ComponentException.class)
     public void testUpdateDesignerRoleListOfTasksNotEmpty_shouldFail() {
         User modifier = new User(MOCK_MODIFIER);
         modifier.setRole(UserRoleEnum.ADMIN.getName());
@@ -412,13 +412,13 @@
         when(userAdminOperation.getUserData(userIdToUpdate, false)).thenReturn(Either.left(updatedUser));
         List<Edge> list = new LinkedList<>();
         list.add(new DetachedEdge("sdas", "fdfs", new HashMap<>(), Pair.with("sadas", "sadasd"), "",
-                Pair.with("sadas", "sadasd"), ""));
+            Pair.with("sadas", "sadasd"), ""));
         testSubject.updateUserRole(MOCK_MODIFIER, userIdToUpdate, userRole);
 
         verify(facadeUserOperation, never()).updateUserCache(any(UserOperationEnum.class), anyString(), anyString());
     }
 
-    @Test(expected =  StorageException.class)
+    @Test(expected = StorageException.class)
     public void testUpdateUserRoleStorageError_shouldFail() {
         User modifier = new User(MOCK_MODIFIER);
         modifier.setRole(UserRoleEnum.ADMIN.getName());
@@ -478,7 +478,7 @@
     public void testGetAllAdminUsers() {
         Either<List<User>, ActionStatus> response = Either.left(new LinkedList<>());
         when(userAdminOperation.getAllUsersWithRole(anyString(), Mockito.nullable(String.class)))
-                .thenReturn(response);
+            .thenReturn(response);
         assertEquals(0, testSubject.getAllAdminUsers().size());
     }
 
@@ -486,7 +486,7 @@
     public void testGetAllAdminUsersFail() {
         Either<List<User>, ActionStatus> response = Either.right(ActionStatus.NOT_ALLOWED);
         when(userAdminOperation.getAllUsersWithRole(anyString(), Mockito.nullable(String.class)))
-                .thenReturn(response);
+            .thenReturn(response);
         testSubject.getAllAdminUsers();
     }
 
@@ -528,7 +528,7 @@
         when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3);
         Either<List<User>, ActionStatus> value = Either.left(new LinkedList<>());
         when(userAdminOperation.getAllUsersWithRole(Mockito.nullable(String.class), anyString()))
-                .thenReturn(value);
+            .thenReturn(value);
 
         assertEquals(0, testSubject.getUsersList(modifierAttId, roles, rolesStr).size());
     }
@@ -564,7 +564,7 @@
         when(userAdminOperation.getUserData(modifierAttId, false)).thenReturn(value3);
         Either<List<User>, ActionStatus> value = Either.left(new LinkedList<>());
         when(userAdminOperation.getAllUsersWithRole(Mockito.nullable(String.class), anyString()))
-                .thenReturn(value);
+            .thenReturn(value);
 
         assertEquals(0, testSubject.getUsersList(modifierAttId, roles, rolesStr).size());
     }
@@ -659,13 +659,13 @@
 
         when(userAdminOperation.updateUserData(Mockito.any(User.class))).thenReturn(updatedUserCred);
         assertEquals(updatedUserCred.getUserId(),
-                testSubject.updateUserCredentials(updatedUserCred).left().value().getUserId());
+            testSubject.updateUserCredentials(updatedUserCred).left().value().getUserId());
     }
 
     @Test
     public void getUsersPerRoleWhenListIsEmpty() {
         when(userAdminOperation.getAllUsersWithRole(any(), any()))
-                .thenReturn(Either.left(Lists.newArrayList()));
+            .thenReturn(Either.left(Lists.newArrayList()));
         assertEquals(0, testSubject.getUsersPerRole("all", user, "").left().value().size());
     }
 
@@ -675,7 +675,7 @@
         when(user.getUserId()).thenReturn("123");
         when(userNull.getUserId()).thenReturn(null);
         when(userAdminOperation.getAllUsersWithRole(any(), any()))
-                .thenReturn(Either.left(users));
+            .thenReturn(Either.left(users));
         List<User> result = testSubject.getUsersPerRole("all", user, "").left().value();
 
         assertEquals(1, result.size());
@@ -687,7 +687,7 @@
         List<User> users = Lists.newArrayList(user, user);
         when(user.getUserId()).thenReturn("123");
         when(userAdminOperation.getAllUsersWithRole(any(), any()))
-                .thenReturn(Either.left(users));
+            .thenReturn(Either.left(users));
         List<User> result = testSubject.getUsersPerRole("all", user, "").left().value();
 
         assertEquals(2, result.size());
@@ -699,7 +699,7 @@
         List<User> users = Lists.newArrayList(userNull);
         when(userNull.getUserId()).thenReturn(null);
         when(userAdminOperation.getAllUsersWithRole(any(), any()))
-                .thenReturn(Either.left(users));
+            .thenReturn(Either.left(users));
         List<User> result = testSubject.getUsersPerRole("all", user, "").left().value();
 
         assertEquals(0, result.size());
@@ -713,7 +713,7 @@
             String userId = "mock";
             Set<String> userRoles = new HashSet<>();
             userRoles.add(Role.DESIGNER.name());
-            UserContext userContext = new UserContext(userId, userRoles, "test" ,"User");
+            UserContext userContext = new UserContext(userId, userRoles, "test", "User");
             ThreadLocalsHolder.setUserContext(userContext);
 
             assertThat(testSubject.hasActiveUser(userId)).isTrue();
@@ -729,7 +729,7 @@
             originalUserContext = ThreadLocalsHolder.getUserContext();
             String userId = "mock";
             Set<String> userRoles = new HashSet<>();
-            UserContext userContext = new UserContext(userId, userRoles, "test" ,"User");
+            UserContext userContext = new UserContext(userId, userRoles, "test", "User");
             ThreadLocalsHolder.setUserContext(userContext);
 
             assertThat(testSubject.hasActiveUser(userId)).isFalse();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationTest.java
index 84f83d9..dd44e17 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/cucumber/runners/RunTenantIsolationTest.java
@@ -25,7 +25,6 @@
 import org.junit.runner.RunWith;
 import org.openecomp.sdc.be.components.BeConfDependentTest;
 
-// TODO - investigate NPE
 @RunWith(Cucumber.class)
 @CucumberOptions(features = "classpath:cucumber/tenantIsolation.feature", glue = "org.openecomp.sdc.be.components.distribution.engine")
 public class RunTenantIsolationTest extends BeConfDependentTest {
diff --git a/catalog-be/src/test/resources/application-context-test.xml b/catalog-be/src/test/resources/application-context-test.xml
index c45680c..10b12ff 100644
--- a/catalog-be/src/test/resources/application-context-test.xml
+++ b/catalog-be/src/test/resources/application-context-test.xml
@@ -29,4 +29,46 @@
   <bean id="userAdmin" class="org.mockito.Mockito" factory-method="mock">
     <constructor-arg value="org.openecomp.sdc.be.user.UserBusinessLogic" />
   </bean>
+  <bean id="componentInstanceBusinessLogic" class="org.mockito.Mockito" factory-method="mock">
+    <constructor-arg value="org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic" />
+  </bean>
+  <bean id="servletUtils" class="org.mockito.Mockito" factory-method="mock">
+    <constructor-arg value="org.openecomp.sdc.be.impl.ServletUtils" />
+  </bean>
+  <bean id="resourceImportManager" class="org.mockito.Mockito" factory-method="mock">
+    <constructor-arg value="org.openecomp.sdc.be.components.impl.ResourceImportManager" />
+  </bean>
+  <bean id="elementBusinessLogic" class="org.mockito.Mockito" factory-method="mock">
+    <constructor-arg value="org.openecomp.sdc.be.components.impl.ElementBusinessLogic" />
+  </bean>
+  <bean id="assetMetadataConverter" class="org.mockito.Mockito" factory-method="mock">
+    <constructor-arg value="org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter" />
+  </bean>
+  <bean id="lifecycleBusinessLogic" class="org.mockito.Mockito" factory-method="mock">
+    <constructor-arg value="org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic" />
+  </bean>
+  <bean id="resourceBusinessLogic" class="org.mockito.Mockito" factory-method="mock">
+    <constructor-arg value="org.openecomp.sdc.be.components.impl.ResourceBusinessLogic" />
+  </bean>
+  <bean id="serviceBusinessLogic" class="org.mockito.Mockito" factory-method="mock">
+    <constructor-arg value="org.openecomp.sdc.be.components.impl.ServiceBusinessLogic" />
+  </bean>
+  <bean id="compositionBusinessLogic" class="org.mockito.Mockito" factory-method="mock">
+    <constructor-arg value="org.openecomp.sdc.be.components.impl.CompositionBusinessLogic" />
+  </bean>
+
+  <bean class="org.openecomp.sdc.be.externalapi.servlet.CrudExternalServlet">
+    <constructor-arg ref="userAdmin" />
+    <constructor-arg ref="componentInstanceBusinessLogic" />
+    <constructor-arg ref="componentUtils"/>
+    <constructor-arg ref="servletUtils" />
+    <constructor-arg ref="resourceImportManager" />
+    <constructor-arg ref="elementBusinessLogic" />
+    <constructor-arg ref="assetMetadataConverter" />
+    <constructor-arg ref="lifecycleBusinessLogic" />
+    <constructor-arg ref="resourceBusinessLogic" />
+    <constructor-arg ref="serviceBusinessLogic" />
+  </bean>
+
+
 </beans>
