aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org
diff options
context:
space:
mode:
authorshrek2000 <orenkle@amdocs.com>2019-03-28 16:29:17 +0200
committerAvi Gaffa <avi.gaffa@amdocs.com>2019-03-30 07:53:05 +0000
commit969a4e89e2363f76212623d9e563665804682fcf (patch)
tree72edd634ca657513394b52b26eef5537d089e4a4 /catalog-be/src/test/java/org
parent5c980e10f4f6ef92a67de9cc1bd6f0043b4848be (diff)
Heal Vertex Data
Enable healing of vertex information when reading it. Issue-ID: SDC-2213 Change-Id: I907beeb25bd231d9e05d3a5b8e070d6bdf9cb781 Signed-off-by: shrek2000 <orenkle@amdocs.com>
Diffstat (limited to 'catalog-be/src/test/java/org')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/HealStatusDaoMock.java23
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefServletTest.java31
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArchiveEndpointTest.java133
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java5
4 files changed, 127 insertions, 65 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/HealStatusDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/HealStatusDaoMock.java
new file mode 100644
index 0000000000..1c9bd0ee79
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/HealStatusDaoMock.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.be.components.path.beans;
+
+
+
+public class HealStatusDaoMock {
+
+
+}
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 f7e59e65f1..7d949a1959 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
@@ -20,6 +20,7 @@
package org.openecomp.sdc.be.externalapi.servlet;
+import com.google.common.collect.ImmutableListMultimap;
import fj.data.Either;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
@@ -36,8 +37,14 @@ import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.DAOTitanStrategy;
import org.openecomp.sdc.be.dao.TitanClientStrategy;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
@@ -63,10 +70,12 @@ 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;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpStatus;
import org.springframework.web.context.WebApplicationContext;
@@ -105,11 +114,10 @@ public class ExternalRefServletTest extends JerseyTest {
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 TitanGenericDao titanGenericDao = Mockito.mock(TitanGenericDao.class);
+ private static final HealingTitanGenericDao titanGenericDao = Mockito.mock(HealingTitanGenericDao.class);
private static final ICacheMangerOperation cacheManagerOperation = Mockito.mock(ICacheMangerOperation.class);
private static final IGraphLockOperation graphLockOperation = Mockito.mock(IGraphLockOperation.class);
-
private static final String COMPONENT_ID = "ci-MyComponentName";
private static final String FAKE_COMPONENT_ID = "ci-MyFAKEComponentName";
@@ -126,12 +134,13 @@ public class ExternalRefServletTest extends JerseyTest {
private static final String REF_6 = "ref6";
@Configuration
+ @PropertySource("classpath:dao.properties")
static class TestSpringConfig {
private GraphVertex serviceVertex;
private GraphVertex resourceVertex;
private ExternalReferencesOperation externalReferenceOperation;
- private TitanDao titanDao;
+ private HealingTitanDao titanDao;
private OperationUtils operationUtils;
@Bean
@@ -170,6 +179,7 @@ public class ExternalRefServletTest extends JerseyTest {
@Bean
ExternalReferencesOperation externalReferencesOperation() {
this.externalReferenceOperation = new ExternalReferencesOperation(titanDao(), nodeTypeOpertaion(), topologyTemplateOperation(), idMapper());
+ this.externalReferenceOperation.setHealingPipelineDao(healingPipelineDao());
GraphTestUtils.clearGraph(titanDao);
initGraphForTest();
return this.externalReferenceOperation;
@@ -191,7 +201,7 @@ public class ExternalRefServletTest extends JerseyTest {
@Bean
TopologyTemplateOperation topologyTemplateOperation() {
- return new TopologyTemplateOperation();
+ return new TopologyTemplateOperation();
}
@Bean
@@ -225,8 +235,8 @@ public class ExternalRefServletTest extends JerseyTest {
}
@Bean
- TitanDao titanDao() {
- this.titanDao = new TitanDao(titanGraphClient());
+ HealingTitanDao titanDao() {
+ this.titanDao = new HealingTitanDao(titanGraphClient());
return titanDao;
}
@@ -255,6 +265,15 @@ public class ExternalRefServletTest extends JerseyTest {
return titanGenericDao;
}
+ @Bean("healingPipelineDao")
+ HealingPipelineDao healingPipelineDao() {
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao() ;
+ healingPipelineDao.setHealVersion(1);
+ healingPipelineDao.initHealVersion();
+ return healingPipelineDao;
+ }
+
+
private void initGraphForTest() {
if (!setupDone) {
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 2c3d411922..aea9908650 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
@@ -20,11 +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.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.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.openecomp.sdc.be.components.impl.ArchiveBusinessLogic;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
@@ -35,20 +53,32 @@ import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.DAOTitanStrategy;
import org.openecomp.sdc.be.dao.TitanClientStrategy;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.*;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.catalog.CatalogComponent;
-import org.openecomp.sdc.be.model.jsontitan.operations.*;
+import org.openecomp.sdc.be.model.jsontitan.operations.ArchiveOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.CategoryOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.GroupsOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -66,27 +96,10 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
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.*;
-
public class ArchiveEndpointTest extends JerseyTest {
private static final ServletContext servletContext = mock(ServletContext.class);
@@ -105,16 +118,17 @@ public class ArchiveEndpointTest extends JerseyTest {
private static final AccessValidations accessValidationsMock = mock(AccessValidations.class);
private static final ComponentValidations componentValidationsMock = mock(ComponentValidations.class);
private static final IGraphLockOperation graphLockOperation = mock(IGraphLockOperation.class);
- private static final TitanGenericDao titanGenericDao = mock(TitanGenericDao.class);
-
+ private static final HealingTitanGenericDao titanGenericDao = mock(HealingTitanGenericDao.class);
+ private static final HealingPipelineDao HEALING_PIPELINE_DAO = mock(HealingPipelineDao.class);
private static final ICacheMangerOperation cacheManagerOperation = mock(ICacheMangerOperation.class);
private static GraphVertex serviceVertex;
private static GraphVertex resourceVertex;
private static GraphVertex resourceVertexVspArchived;
- private static TitanDao titanDao;
+ private static HealingTitanDao titanDao;
@Configuration
+ @PropertySource("classpath:dao.properties")
static class TestSpringConfig {
private ArchiveOperation archiveOperation;
private GraphVertex catalogVertex;
@@ -193,8 +207,8 @@ public class ArchiveEndpointTest extends JerseyTest {
}
@Bean
- TitanDao titanDao() {
- titanDao = new TitanDao(titanGraphClient());
+ HealingTitanDao titanDao() {
+ titanDao = new HealingTitanDao(titanGraphClient());
return titanDao;
}
@@ -223,6 +237,11 @@ public class ArchiveEndpointTest extends JerseyTest {
return titanGenericDao;
}
+ @Bean
+ HealingPipelineDao healingPipelineDao(){
+ return HEALING_PIPELINE_DAO;
+ }
+
private void initGraphForTest() {
//Create Catalog Root
catalogVertex = GraphTestUtils.createRootCatalogVertex(titanDao);
@@ -264,7 +283,7 @@ public class ArchiveEndpointTest extends JerseyTest {
/* 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());
+ .currentTimeMillis());
private static final User otherUser = new User("other", "other", "other", "other@email.com", Role.OPS.name(), System.currentTimeMillis());
@BeforeClass
@@ -336,11 +355,11 @@ public class ArchiveEndpointTest extends JerseyTest {
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);
@@ -353,11 +372,11 @@ public class ArchiveEndpointTest extends JerseyTest {
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);
@@ -380,11 +399,11 @@ public class ArchiveEndpointTest extends JerseyTest {
public 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());
}
@@ -410,11 +429,11 @@ public class ArchiveEndpointTest extends JerseyTest {
private void archiveOrRestoreComponent(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);
}
@@ -423,11 +442,11 @@ public class ArchiveEndpointTest extends JerseyTest {
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>>>() { });
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
@@ -444,9 +463,9 @@ public class ArchiveEndpointTest extends JerseyTest {
protected Application configure() {
ApplicationContext context = new AnnotationConfigApplicationContext(TestSpringConfig.class);
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/TypesUploadEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java
index 8638de334a..5eecc77136 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
@@ -18,6 +18,7 @@ import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.sdc.be.components.impl.CommonImportManager;
import org.openecomp.sdc.be.components.validation.AccessValidations;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -55,7 +56,7 @@ public class TypesUploadEndpointTest extends JerseySpringBaseTest {
static final String userId = "jh0003";
private static AccessValidations accessValidations;
- private static TitanGenericDao titanGenericDao;
+ private static HealingTitanGenericDao titanGenericDao;
private static PropertyOperation propertyOperation;
private static ComponentsUtils componentUtils;
private static OperationUtils operationUtils;
@@ -87,7 +88,7 @@ public class TypesUploadEndpointTest extends JerseySpringBaseTest {
@BeforeClass
public static void initClass() {
- titanGenericDao = mock(TitanGenericDao.class);
+ titanGenericDao = mock(HealingTitanGenericDao.class);
accessValidations = mock(AccessValidations.class);
propertyOperation = mock(PropertyOperation.class);
componentUtils = Mockito.mock(ComponentsUtils.class);