diff --git a/catalog-be/pom.xml b/catalog-be/pom.xml
index 85674cb..0452c76 100644
--- a/catalog-be/pom.xml
+++ b/catalog-be/pom.xml
@@ -365,6 +365,10 @@
             <scope>compile</scope>
             <exclusions>
                 <exclusion>
+                    <artifactId>gremlin-groovy</artifactId>
+                    <groupId>org.apache.tinkerpop</groupId>
+                </exclusion>
+                <exclusion>
                     <groupId>org.json</groupId>
                     <artifactId>json</artifactId>
                 </exclusion>
@@ -539,9 +543,22 @@
         <!--Jetty Proxy-->
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-http</artifactId>
+            <version>${jetty.version}</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-proxy</artifactId>
             <version>${jetty.version}</version>
             <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.eclipse.jetty</groupId>
+                    <artifactId>jetty-http</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -549,6 +566,12 @@
             <artifactId>jetty-servlets</artifactId>
             <version>${jetty.version}</version>
             <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.eclipse.jetty</groupId>
+                    <artifactId>jetty-http</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <!-- System metrics -->
         <dependency>
@@ -634,6 +657,16 @@
             <version>${jersey-bom.version}</version>
             <type>pom</type>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.eclipse.jetty</groupId>
+                    <artifactId>jetty-server</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.eclipse.jetty</groupId>
+                    <artifactId>jetty-continuation</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -647,6 +680,12 @@
             <artifactId>jetty-webapp</artifactId>
             <version>${jetty.version}</version>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.eclipse.jetty</groupId>
+                    <artifactId>jetty-servlet</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>
@@ -740,7 +779,7 @@
         <dependency>
             <groupId>org.codehaus.groovy</groupId>
             <artifactId>groovy</artifactId>
-            <version>2.4.8</version>
+            <version>${groovy.version}</version>
         </dependency>
 
         <dependency>
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducer.java b/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducer.java
index 2cc9426..a442481 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducer.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/catalog/impl/DmaapProducer.java
@@ -22,6 +22,8 @@
 
 import com.att.nsa.mr.client.MRBatchingPublisher;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import org.openecomp.sdc.be.catalog.api.IMessageQueueHandlerProducer;
 import org.openecomp.sdc.be.catalog.api.IStatus;
 import org.openecomp.sdc.be.catalog.api.ITypeMessage;
@@ -29,112 +31,108 @@
 import org.openecomp.sdc.be.components.distribution.engine.DmaapClientFactory;
 import org.openecomp.sdc.be.config.ConfigurationManager;
 import org.openecomp.sdc.be.config.DmaapProducerConfiguration;
+import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
 import org.openecomp.sdc.common.log.enums.StatusCode;
 import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-
 @Component
 public class DmaapProducer implements IMessageQueueHandlerProducer {
-	private static final Logger LOG = Logger.getLogger(DmaapProducer.class.getName());
-	private static final Logger metricLog = Logger.getLogger(DmaapProducer.class.getName());
 
-	@Autowired
-	private DmaapClientFactory dmaapClientFactory;
-	private ConfigurationManager configurationManager = ConfigurationManager.getConfigurationManager();
-	private MRBatchingPublisher publisher;
-	@Autowired
-	private DmaapProducerHealth dmaapHealth;
+    private static final Logger LOG = Logger.getLogger(DmaapProducer.class.getName());
+    private final DmaapClientFactory dmaapClientFactory;
+    private final DmaapProducerHealth dmaapHealth;
+    private final ConfigurationManager configurationManager = ConfigurationManager.getConfigurationManager();
+    private MRBatchingPublisher publisher;
 
-	public MRBatchingPublisher getPublisher() {
-		return publisher;
-	}
+    public DmaapProducer(final DmaapClientFactory dmaapClientFactory,
+                         final DmaapProducerHealth dmaapHealth) {
+        this.dmaapClientFactory = dmaapClientFactory;
+        this.dmaapHealth = dmaapHealth;
+    }
 
-	@Override
-	public IStatus pushMessage(ITypeMessage message) {
-		try {
-			DmaapProducerConfiguration producerConfiguration = configurationManager.getConfiguration()
-					.getDmaapProducerConfiguration();
-			if (!producerConfiguration.getActive()) {
-				LOG.info(
-						"[Microservice DMAAP] producer is disabled [re-enable in configuration->isActive],message not sent.");
-				dmaapHealth.report(false);
-				return IStatus.getServiceDisabled();
-			}
-			if (publisher == null) {
-				IStatus initStatus = init();
-				if (initStatus.getResultStatus() != ResultStatusEnum.SUCCESS) {
+    @Override
+    public IStatus pushMessage(ITypeMessage message) {
+        try {
+            DmaapProducerConfiguration producerConfiguration = configurationManager.getConfiguration()
+                .getDmaapProducerConfiguration();
+            if (!producerConfiguration.getActive()) {
+                LOG.info(
+                    "[Microservice DMAAP] producer is disabled [re-enable in configuration->isActive],message not sent.");
+                dmaapHealth.report(false);
+                return IStatus.getServiceDisabled();
+            }
+            if (publisher == null) {
+                IStatus initStatus = init();
+                if (initStatus.getResultStatus() != ResultStatusEnum.SUCCESS) {
 
-					return initStatus;
-				}
-			}
-			ObjectMapper mapper = new ObjectMapper();
-			String jsonInString = mapper.writeValueAsString(message);
-			if (publisher != null) {
-			    LOG.info("before send message . response {}", jsonInString);
+                    return initStatus;
+                }
+            }
+            ObjectMapper mapper = new ObjectMapper();
+            String jsonInString = mapper.writeValueAsString(message);
+            if (publisher != null) {
+                LOG.info("before send message . response {}", jsonInString);
 
-				LOG.invoke("Dmaap Producer", "DmaapProducer-pushMessage", DmaapProducer.class.getName(), message.toString());
+                LOG.invoke("Dmaap Producer", "DmaapProducer-pushMessage", DmaapProducer.class.getName(),
+                    message.toString());
 
-				int pendingMsg = publisher.send(jsonInString);
-				LOG.info("sent message . response {}", pendingMsg);
-				LOG.invokeReturn(producerConfiguration.getConsumerId(), "Dmaap Producer", StatusCode.COMPLETE.getStatusCode(), "DmaapProducer-pushMessage",message.toString(), pendingMsg );
+                int pendingMsg = publisher.send(jsonInString);
+                LOG.info("sent message . response {}", pendingMsg);
+                LOG.invokeReturn(producerConfiguration.getConsumerId(), "Dmaap Producer",
+                    StatusCode.COMPLETE.getStatusCode(), "DmaapProducer-pushMessage", message.toString(), pendingMsg);
 
-			}
+            }
 
-			
-			
-			dmaapHealth.report(true);
-		} catch (Exception e) {
-			LOG.error("Failed to send message . Exception {}", e.getMessage());
-			return IStatus.getFailStatus();
-		}
+            dmaapHealth.report(true);
+        } catch (Exception e) {
+            LOG.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, "Failed to send message . Exception {}", e.getMessage());
+            return IStatus.getFailStatus();
+        }
 
-		return IStatus.getSuccessStatus();
-	}
+        return IStatus.getSuccessStatus();
+    }
 
-	@PostConstruct
-	@Override
-	public IStatus init() {
-		LOG.debug("MessageQueueHandlerProducer:: Start initializing");
-		DmaapProducerConfiguration configuration = configurationManager.getConfiguration()
-				.getDmaapProducerConfiguration();
-		if (configuration.getActive()) {
-			try {
-				publisher = dmaapClientFactory.createProducer(configuration);
-				if (publisher == null) {
-					LOG.error("Failed to connect to topic ");
-					dmaapHealth.report(false);
-					return IStatus.getFailStatus();
-				}
+    @PostConstruct
+    @Override
+    public IStatus init() {
+        LOG.debug("MessageQueueHandlerProducer:: Start initializing");
+        DmaapProducerConfiguration configuration = configurationManager.getConfiguration()
+            .getDmaapProducerConfiguration();
+        if (configuration.getActive()) {
+            try {
+                publisher = dmaapClientFactory.createProducer(configuration);
+                if (publisher == null) {
+                    LOG.error("Failed to connect to topic ");
+                    dmaapHealth.report(false);
+                    return IStatus.getFailStatus();
+                }
 
-			} catch (Exception e) {
-				LOG.error("Failed to connect to topic . Exeption {}", e.getMessage());
-				dmaapHealth.report(false);
-				return IStatus.getFailStatus();
-			}
-			dmaapHealth.report(true);
-			return IStatus.getSuccessStatus();
-		}
-		LOG.info("[Microservice DMAAP] producer is disabled [re-enable in configuration->isActive],message not sent.");
-		dmaapHealth.report(false);
-		return IStatus.getServiceDisabled();
-	}
+            } catch (Exception e) {
+                LOG.error("Failed to connect to topic . Exeption {}", e.getMessage());
+                dmaapHealth.report(false);
+                return IStatus.getFailStatus();
+            }
+            dmaapHealth.report(true);
+            return IStatus.getSuccessStatus();
+        }
+        LOG.info("[Microservice DMAAP] producer is disabled [re-enable in configuration->isActive],message not sent.");
+        dmaapHealth.report(false);
+        return IStatus.getServiceDisabled();
+    }
 
-	@PreDestroy
-	public void shutdown() {
-		LOG.debug("DmaapProducer::shutdown...");
-		try {
-			if (publisher != null) {
-				publisher.close();
-			}
-		} catch (Exception e) {
-			LOG.error("Failed to close  messageQ . Exeption {}", e.getMessage());
+    @PreDestroy
+    public void shutdown() {
+        LOG.debug("DmaapProducer::shutdown...");
+        try {
+            if (publisher != null) {
+                publisher.close();
+            }
+        } catch (Exception e) {
+            LOG.error("Failed to close  messageQ . Exeption {}", e.getMessage());
 
-		}
+        }
 
-	}
+    }
 
 }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index dfc9166..9eb9c34 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -1758,14 +1758,12 @@
 
         ActivationRequestInformation activationRequestInformation = activationRequestInformationEither.left().value();
 
-        Either<String, ResponseFormat> result = null;
         String did = ThreadLocalsHolder.getUuid();
         Service service = activationRequestInformation.getServiceToActivate();
-        result = buildAndSendServiceNotification(service, envId, did, activationRequestInformation.getWorkloadContext(), modifier);
-        return result;
+        return buildAndSendServiceNotification(service, envId, did, activationRequestInformation.getWorkloadContext(), modifier);
     }
 
-    public Either<String, ResponseFormat> buildAndSendServiceNotification(Service service, String envId, String did, String workloadContext, User modifier) {
+    private Either<String, ResponseFormat> buildAndSendServiceNotification(Service service, String envId, String did, String workloadContext, User modifier) {
         String envName = getEnvNameFromConfiguration();
         INotificationData notificationData = distributionEngine.buildServiceForDistribution(service, did, workloadContext);
         ActionStatus notifyServiceResponse = distributionEngine.notifyService(did, service, notificationData, envId, envName, modifier);
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>
