Fix test cases failing incorrectly
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / jsonjanusgraph / operations / PolicyOperationIntegrationTest.java
index 37e360c..64cad65 100644 (file)
@@ -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.
 
 package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
 
+import static org.apache.commons.collections.ListUtils.union;
+import static org.assertj.core.api.Assertions.assertThat;
+
 import fj.data.Either;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Resource;
+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.dao.config.JanusGraphSpringConfig;
-import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
 import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
 import org.openecomp.sdc.be.datatypes.elements.PolicyDataDefinition;
@@ -43,24 +50,13 @@ import org.openecomp.sdc.be.model.config.ModelOperationsSpringConfig;
 import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
 import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
 
-import javax.annotation.Resource;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.commons.collections.ListUtils.union;
-import static org.assertj.core.api.Assertions.assertThat;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class})
+@SpringJUnitConfig(classes = {JanusGraphSpringConfig.class, ModelOperationsSpringConfig.class})
 public class PolicyOperationIntegrationTest extends ModelTestBase {
 
-    private static final String CONTAINER_ID = "container";
     public static final String POLICY_ID = "policy";
+    private static final String CONTAINER_ID = "container";
     @Resource
     private TopologyTemplateOperation topologyTemplateOperation;
     @Resource
@@ -70,13 +66,13 @@ public class PolicyOperationIntegrationTest extends ModelTestBase {
     private PropertyDataDefinition prop1, prop2;
     private PolicyDefinition policy;
 
-    @BeforeClass
+    @BeforeAll
     public static void setupBeforeClass() {
 
         ModelTestBase.init();
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         prop1 = new PropertyDataDefinition();
         prop1.setUniqueId("prop1");
@@ -97,11 +93,12 @@ public class PolicyOperationIntegrationTest extends ModelTestBase {
         resource.addMetadataProperty(GraphPropertyEnum.UNIQUE_ID, CONTAINER_ID);
         janusGraphDao.createVertex(resource);
         GraphVertex loadedResource = janusGraphDao.getVertexById(CONTAINER_ID).left().value();
-        topologyTemplateOperation.addToscaDataToToscaElement(loadedResource, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policy, JsonPresentationFields.UNIQUE_ID);
+        topologyTemplateOperation.addToscaDataToToscaElement(loadedResource, EdgeLabelEnum.POLICIES, VertexTypeEnum.POLICIES, policy,
+            JsonPresentationFields.UNIQUE_ID);
 //        janusGraphDao.commit();
     }
 
-    @After
+    @AfterEach
     public void tearDown() {
         janusGraphDao.rollback();
     }
@@ -134,7 +131,8 @@ public class PolicyOperationIntegrationTest extends ModelTestBase {
         ComponentParametersView componentParametersView = new ComponentParametersView();
         componentParametersView.disableAll();
         componentParametersView.setIgnorePolicies(false);
-        Either<ToscaElement, StorageOperationStatus> loadedCmptEither = topologyTemplateOperation.getToscaElement(CONTAINER_ID, componentParametersView);
+        Either<ToscaElement, StorageOperationStatus> loadedCmptEither = topologyTemplateOperation.getToscaElement(CONTAINER_ID,
+            componentParametersView);
 
         assertThat(loadedCmptEither.isLeft()).isTrue();
         ToscaElement loadedCmpt = loadedCmptEither.left().value();
@@ -148,6 +146,6 @@ public class PolicyOperationIntegrationTest extends ModelTestBase {
         PolicyDataDefinition policy = policies.get(POLICY_ID);
         List<PropertyDataDefinition> policyProperties = policy.getProperties();
         assertThat(policyProperties).usingElementComparatorOnFields("value")
-                                    .containsAll(expectedUpdatedProperties);
+            .containsAll(expectedUpdatedProperties);
     }
 }