aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-05-13 19:11:38 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-06-01 06:38:17 +0000
commit1e9c8c5f47a707dc8ea1d7cff7ef39b91462b137 (patch)
treeaf756321160cc221b66b5819841cb5160e14c262 /catalog-be/src/test
parent6fc8a352e6b0d32bf166c0547d5fe9d1507917e7 (diff)
Plugin to customize prop. during Service creation
Creates an entry point to customize properties of a Service Component before its creation. Change-Id: I102a70b37eec498dd9c6df009c38da57d0e5b17f Issue-ID: SDC-3062 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java69
1 files changed, 51 insertions, 18 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
index 88ab995be9..7fc92fb362 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogicTest.java
@@ -20,9 +20,26 @@
package org.openecomp.sdc.be.components.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
+
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fj.data.Either;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Assert;
import org.junit.Test;
@@ -43,6 +60,7 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.plugins.ServiceCreationPlugin;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.resources.data.auditing.DistributionDeployEvent;
import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
@@ -52,24 +70,6 @@ import org.openecomp.sdc.common.util.ValidationUtils;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.http.HttpStatus;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.when;
-
public class ServiceBusinessLogicTest extends ServiceBussinessLogicBaseTestSetup {
private final static String DEFAULT_ICON = "defaulticon";
@@ -102,6 +102,39 @@ public class ServiceBusinessLogicTest extends ServiceBussinessLogicBaseTestSetup
}
assertEqualsServiceObject(createServiceObject(true), createResponse.left().value());
}
+
+ @Test
+ public void testServiceCreationPluginCall() {
+ final Service service = createServiceObject(false);
+ when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service)).thenReturn(Either.left(genericService));
+ final List<ServiceCreationPlugin> serviceCreationPlugins = new ArrayList<>();
+ serviceCreationPlugins.add(new ServiceCreationPlugin() {
+ @Override
+ public void beforeCreate(Service service) {
+ //do nothing
+ }
+
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+ });
+ serviceCreationPlugins.add(new ServiceCreationPlugin() {
+ @Override
+ public void beforeCreate(Service service) {
+ throw new RuntimeException();
+ }
+
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+ });
+ bl.setServiceCreationPluginList(serviceCreationPlugins);
+ final Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
+ assertTrue(createResponse.isLeft());
+ }
+
@Test
public void testHappyScenarioCRNullProjectCode() {
Service service = createServiceObject(false);