summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2018-09-05 17:47:16 +0300
committerMichael Lando <ml636r@att.com>2018-09-05 19:16:34 +0300
commit503be6d4ac7cfd63d5e17a54bd990de39b201d83 (patch)
treee94882f7e5849f395dc4b1051211b92f43f1fd8c
parentf773610d0952940db42376cbb36ba63cb2cacc35 (diff)
add ability to disable tenant isolation.
Change-Id: I35b6db5ec0d3aa91295f57b60c04243b3f3d2208 Issue-ID: SDC-1571 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
-rw-r--r--catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb3
-rw-r--r--catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_2_setup_configuration.rb3
-rw-r--r--catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb1
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java12
-rw-r--r--catalog-be/src/main/resources/config/configuration.yaml13
-rw-r--r--catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineMockTest.java190
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineTest.java603
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/configuration.yaml11
-rw-r--r--common-app-api/pom.xml7
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/be/config/DmaapConsumerConfiguration.java10
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/be/config/DmaapConsumerConfigurationTest.java571
15 files changed, 389 insertions, 1053 deletions
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb
index 14d3bdff95..49ac86aaec 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/attributes/default.rb
@@ -33,3 +33,6 @@ default['UEB']['PublicKey'] = "sSJc5qiBnKy2qrlc"
default['UEB']['SecretKey'] = "4ZRPzNJfEUK0sSNBvccd2m7X"
default['Pair_EnvName'] = ""
+
+#DmaapConsumer
+default['DMAAP']['active'] = false \ No newline at end of file
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_2_setup_configuration.rb b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_2_setup_configuration.rb
index 155ea24077..74d867d699 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_2_setup_configuration.rb
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_2_setup_configuration.rb
@@ -61,7 +61,8 @@ template "catalog-be-config" do
:cassandra_usr => node['cassandra'][:cassandra_user],
:cassandra_truststore_password => node['cassandra'][:truststore_password],
:cassandra_ssl_enabled => "#{ENV['cassandra_ssl_enabled']}",
- :dcae_be_vip => node['DCAE_BE_VIP']
+ :dcae_be_vip => node['DCAE_BE_VIP'],
+ :dmaap_active => node['DMAAP']['active']
})
end
diff --git a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
index af1e5fadf7..c7710c503e 100644
--- a/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
+++ b/catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
@@ -668,6 +668,7 @@ environmentContext:
- General_Non-Revenue
dmaapConsumerConfiguration:
+ active: <%= @dmaap_active %>
hosts: localhost:3905
consumerGroup: sdc
consumerId: mama
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java
index 9d428c812a..334b3f63d9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngine.java
@@ -94,7 +94,6 @@ public class DistributionEngine implements IDistributionEngine {
@PostConstruct
private void init() {
-
LOGGER.trace("Enter init method of DistributionEngine");
DistributionEngineConfiguration distributionEngineConfiguration = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration();
@@ -131,7 +130,6 @@ public class DistributionEngine implements IDistributionEngine {
distributionEngineClusterHealth.startHealthCheckTask(envNamePerStatus);
LOGGER.trace("Exit init method of DistributionEngine");
-
}
@PreDestroy
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java
index b48ed78190..653c9c6510 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DmaapHealth.java
@@ -73,6 +73,10 @@ public class DmaapHealth {
@PostConstruct
public DmaapHealth init() {
+ if(!ConfigurationManager.getConfigurationManager().getConfiguration().getDmaapConsumerConfiguration().isActive()){
+ log.debug("Dmaap health check task disabled");
+ return this;
+ }
log.trace("Enter init method of Dmaap health");
synchronized (DmaapHealth.class){
this.configuration = ConfigurationManager.getConfigurationManager().getConfiguration().getDmaapConsumerConfiguration();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
index 7eb00ba988..9a875e5d48 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
@@ -51,7 +51,7 @@ public class EnvironmentsEngine implements INotificationHandler {
private static final Logger log = Logger.getLogger(EnvironmentsEngine.class.getName());
private ConfigurationManager configurationManager = ConfigurationManager.getConfigurationManager();
- private Map<String, OperationalEnvironmentEntry> environments;
+ private Map<String, OperationalEnvironmentEntry> environments = new HashMap<>();
private Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>();
private Map<String, DistributionEnginePollingTask> envNamePerPollingTask = new HashMap<>();
private Map<String, DistributionEngineInitTask> envNamePerInitTask = new HashMap<>();
@@ -79,13 +79,17 @@ public class EnvironmentsEngine implements INotificationHandler {
@VisibleForTesting
@PostConstruct
void init() {
- log.trace("Environments engine has been initialized. ");
try {
environments = populateEnvironments();
createUebTopicsForEnvironments();
initDmeGlobalConfig();
+ if(!configurationManager.getConfiguration().getDmaapConsumerConfiguration().isActive()){
+ log.info("Environments engine is disabled");
+ return;
+ }
dmaapConsumer.consumeDmaapTopic(this::handleMessage,
- (t, e) -> log.error("An error occurred upon consuming topic by Dmaap consumer client: ", e));
+ (t, e) -> log.error("An error occurred upon consuming topic by Dmaap consumer client: ", e));
+ log.info("Environments engine has been initialized.");
} catch (Exception e) {
log.error("An error occurred upon consuming topic by Dmaap consumer client.", e);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java
index be534f326a..c0a89d6954 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/health/HealthCheckBusinessLogic.java
@@ -126,6 +126,7 @@ public class HealthCheckBusinessLogic {
//Dmaap
getDmaapHealthCheck(healthCheckInfos);
+
// BE
getBeHealthCheck(healthCheckInfos);
@@ -182,9 +183,14 @@ public class HealthCheckBusinessLogic {
}
private List<HealthCheckInfo> getDmaapHealthCheck(List<HealthCheckInfo> healthCheckInfos) {
- String appVersion = getAppVersion();
- dmaapHealth.getHealthCheckInfo().setVersion(appVersion);
- healthCheckInfos.add(dmaapHealth.getHealthCheckInfo());
+ if(ConfigurationManager.getConfigurationManager().getConfiguration().getDmaapConsumerConfiguration().isActive()){
+ String appVersion = getAppVersion();
+ dmaapHealth.getHealthCheckInfo().setVersion(appVersion);
+ healthCheckInfos.add(dmaapHealth.getHealthCheckInfo());
+ } else {
+ log.debug("Dmaap health check disabled");
+ }
+
return healthCheckInfos;
}
diff --git a/catalog-be/src/main/resources/config/configuration.yaml b/catalog-be/src/main/resources/config/configuration.yaml
index 36cb54c788..3c5565ee36 100644
--- a/catalog-be/src/main/resources/config/configuration.yaml
+++ b/catalog-be/src/main/resources/config/configuration.yaml
@@ -7,7 +7,7 @@ identificationHeaderFields:
# catalog backend hostname
beFqdn: localhost
-# sdccatalog.att.com
+# sdccatalog.com
# catalog backend http port
beHttpPort: 8080
@@ -670,17 +670,18 @@ environmentContext:
- General_Non-Revenue
dmaapConsumerConfiguration:
- hosts: olsd004.wnsnet.attws.com:3905
+ active: true
+ hosts: olsd004.wnsnet.ws.com:3905
consumerGroup: asdc
consumerId: mama #mama - in Order To Consume Remove This String And Replace It With -> mama
timeoutMs: 15000
limit: 1
pollingInterval: 2
- topic: com.att.sdc.23911-SDCforTestDev-v001
+ topic: com.sdc.23911-SDCforTestDev-v001
latitude: 32.109333
longitude: 34.855499
version: 1.0
- serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events
+ serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.com/events
environment: TEST
partner: BOT_R
routeOffer: MR1
@@ -694,8 +695,8 @@ dmaapConsumerConfiguration:
dme2preferredRouterFilePath: DME2preferredRouter.txt
timeLimitForNotificationHandleMs: 120000
credential:
- username: m09875@sdc.att.com
- password: hmXYcznAljMSisdy8zgcag==
+ username: m09875@sdc.com
+ password: mockhmXYcznAljMSisdy8zgcag==
diff --git a/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json b/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json
index 8090649613..1ef72856a4 100644
--- a/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json
+++ b/catalog-be/src/main/resources/scripts/import/tosca/typesToUpgrade.json
@@ -1,7 +1,5 @@
{
"heat": [
- "configuration",
- "fabricConfiguration",
"Generic_PNF"
],
"normative": [
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineMockTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineMockTest.java
deleted file mode 100644
index f1ec0d8da6..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineMockTest.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package org.openecomp.sdc.be.components.distribution.engine;
-
-import fj.data.Either;
-import org.apache.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
-import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
-import org.openecomp.sdc.be.dao.cassandra.OperationalEnvironmentDao;
-import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum;
-import org.openecomp.sdc.be.info.OperationalEnvInfo;
-import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
-import org.openecomp.sdc.common.http.client.api.HttpResponse;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-@RunWith(value = MockitoJUnitRunner.class)
-public class EnvironmentsEngineMockTest {
-
- @InjectMocks
- private EnvironmentsEngine envEngine;
- @Mock
- private DmaapConsumer dmaapConsumer;
- @Mock
- private OperationalEnvironmentDao operationalEnvironmentDao;
- @Mock
- private DME2EndpointIteratorCreator epIterCreator;
- @Mock
- private ConfigurationManager configurationManager;
- @Mock
- private DistributionEngineConfiguration distributionEngineConfiguration;
- @Mock
- private AaiRequestHandler aaiRequestHandler;
-
- @Before
- public void preStart() {
- when(configurationManager.getDistributionEngineConfiguration()).thenReturn(distributionEngineConfiguration);
- envEngine.setConfigurationManager(configurationManager);
- }
-
- @Test
- public void testInit() {
- List<OperationalEnvironmentEntry> entryList = Arrays.asList(createOpEnvEntry("Env1"), createOpEnvEntry("Env2"));
- Either<List<OperationalEnvironmentEntry>, CassandraOperationStatus> successEither = Either.left(entryList);
- when(operationalEnvironmentDao.getByEnvironmentsStatus(EnvironmentStatusEnum.COMPLETED)).thenReturn(successEither);
-
- when(distributionEngineConfiguration.getEnvironments()).thenReturn(Arrays.asList("Env Loaded From Configuration"));
- when(distributionEngineConfiguration.getUebPublicKey()).thenReturn("Dummy Public Key");
- when(distributionEngineConfiguration.getUebSecretKey()).thenReturn("Dummy Private Key");
- when(distributionEngineConfiguration.getUebServers()).thenReturn(
- Arrays.asList("uebsb91kcdc.it.att.com:3904", "uebsb92kcdc.it.att.com:3904", "uebsb91kcdc.it.att.com:3904"));
-
- envEngine.init();
-
- Map<String, OperationalEnvironmentEntry> mapEnvs = envEngine.getEnvironments();
- assertEquals("unexpected size of map",3, mapEnvs.size());
- }
-
-
- @Test
- public void testGetFullOperationalEnvByIdSuccess() {
- String json = getFullOperationalEnvJson();
-
- HttpResponse<String> restResponse = new HttpResponse<String>(json, HttpStatus.SC_OK, "Successfully completed");
- when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse);
-
- Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId");
- assertTrue("The operational environment request ran as not expected", response.isLeft());
-
- OperationalEnvInfo operationalEnvInfo = response.left().value();
-
- assertEquals("The operational environment json is not as expected", operationalEnvInfo.toString(), json);
- }
-
- @Test
- public void testGetPartialOperationalEnvByIdSuccess() {
- String json = getPartialOperationalEnvJson();
-
- HttpResponse<String> restResponse = new HttpResponse<String>(json, HttpStatus.SC_OK, "Successfully completed");
- when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse);
-
- Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId");
- assertTrue("The operational environment request ran as not expected", response.isLeft());
-
- OperationalEnvInfo operationalEnvInfo = response.left().value();
-
- assertEquals("The operational environment json is not as expected", operationalEnvInfo.toString(), json);
- }
-
-
- @Test
- public void testGetOperationalEnvByIdFailedByJsonConvert() {
- String jsonCorrupted = getCorruptedOperationalEnvJson();
-
- HttpResponse<String> restResponse = new HttpResponse<String>(jsonCorrupted, HttpStatus.SC_OK, "Successfully Completed");
- when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse);
-
- Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId");
- assertTrue("The operational environment request ran as not expected", response.isRight());
- assertEquals("The operational environment request status code is not as expected", (Integer)HttpStatus.SC_INTERNAL_SERVER_ERROR, response.right().value());
- }
-
- @Test
- public void testGetOperationalEnvByIdFailed404() {
- String json = getFullOperationalEnvJson();
- HttpResponse<String> restResponse = new HttpResponse<String>(json, HttpStatus.SC_NOT_FOUND, "Not Found");
- when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse);
-
- Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId");
- assertTrue("The operational environment request ran as not expected", response.isRight());
- assertEquals("The operational environment request status code is not as expected", (Integer)HttpStatus.SC_NOT_FOUND, response.right().value());
- }
-
-
- @Test(expected = IOException.class)
- public void testCorruptedOperationalEnvJson() throws IOException {
- String jsonCorrupted = getCorruptedOperationalEnvJson();
- OperationalEnvInfo.createFromJson(jsonCorrupted);
- }
-
- private String getCorruptedOperationalEnvJson() {
- return "{\"OPERATIONAL-environment-name\":\"Op Env Name\","
- + "\"OPERATIONAL-environment-type\":\"VNF\","
- + "\"OPERATIONAL-environment-status\":\"Activate\","
- + "\"tenant-context\":\"Test\"}";
- }
-
- private String getPartialOperationalEnvJson() {
- return "{" +
- "\"operational-environment-id\":\"UUID of Operational Environment\"," +
- "\"operational-environment-name\":\"Op Env Name\"," +
- "\"operational-environment-type\":\"VNF\"," +
- "\"operational-environment-status\":\"Activate\"," +
- "\"tenant-context\":\"Test\"," +
- "\"workload-context\":\"VNF_Development\"," +
- "\"resource-version\":\"1505228226913\"," +
- "\"relationship-list\":{" +
- "\"relationship\":[]" +
- "}" +
- "}";
- }
-
- private String getFullOperationalEnvJson() {
- return "{" +
- "\"operational-environment-id\":\"OEid1\"," +
- "\"operational-environment-name\":\"OEname1\"," +
- "\"operational-environment-type\":\"OEtype1\"," +
- "\"operational-environment-status\":\"OEstatus1\"," +
- "\"tenant-context\":\"OEtenantcontext1\"," +
- "\"workload-context\":\"OEworkloadcontext1\"," +
- "\"resource-version\":\"1511363173278\"," +
- "\"relationship-list\":{" +
- "\"relationship\":[" +
- "{" +
- "\"related-to\":\"operational-environment\"," +
- "\"relationship-label\":\"managedBy\"," +
- "\"related-link\":\"/aai/v12/cloud-infrastructure/operational-environments/operational-environment/OEid3\"," +
- "\"relationship-data\":[" +
- "{" +
- "\"relationship-key\":\"operational-environment.operational-environment-id\"," +
- "\"relationship-value\":\"OEid3\"" +
- "}" +
- "]," +
- "\"related-to-property\":[" +
- "{" +
- "\"property-key\":\"operational-environment.operational-environment-name\"," +
- "\"property-value\":\"OEname3\"" +
- "}]}]}}";
- }
-
- private OperationalEnvironmentEntry createOpEnvEntry(String name) {
- OperationalEnvironmentEntry entry = new OperationalEnvironmentEntry();
- entry.setEnvironmentId(name);
- return entry;
- }
-
-}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineTest.java
index bec17b5d08..1050d9a321 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngineTest.java
@@ -3,310 +3,331 @@ package org.openecomp.sdc.be.components.distribution.engine;
import com.att.nsa.apiClient.credentials.ApiCredential;
import fj.data.Either;
import mockit.Deencapsulation;
+import org.apache.http.HttpStatus;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.be.components.BeConfDependentTest;
-import org.openecomp.sdc.be.components.distribution.engine.IDmaapNotificationData.DmaapActionEnum;
-import org.openecomp.sdc.be.components.distribution.engine.IDmaapNotificationData.OperationaEnvironmentTypeEnum;
+import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
+import org.openecomp.sdc.be.config.DmaapConsumerConfiguration;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.cassandra.OperationalEnvironmentDao;
import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum;
-import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.info.OperationalEnvInfo;
import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
import org.openecomp.sdc.common.datastructure.Wrapper;
import org.openecomp.sdc.common.http.client.api.HttpResponse;
-import org.springframework.test.util.ReflectionTestUtils;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.io.IOException;
+import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
-public class EnvironmentsEngineTest extends BeConfDependentTest {
-
- @InjectMocks
- EnvironmentsEngine testSubject;
-
- @Mock
- ComponentsUtils componentUtils;
-
- @Mock
- OperationalEnvironmentDao operationalEnvironmentDao;
-
- @Mock
- CambriaHandler cambriaHandler;
-
- @Mock
- AaiRequestHandler aaiRequestHandler;
-
- @Before
- public void setUpMocks() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testInit() throws Exception {
-
- // default test
- Deencapsulation.invoke(testSubject, "init");
- }
-
- @Test
- public void testConnectUebTopicTenantIsolation() throws Exception {
- OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
- opEnvEntry.setEnvironmentId("mock");
- AtomicBoolean status = null;
- Map<String, DistributionEngineInitTask> envNamePerInitTask = new HashMap<>();
- Map<String, DistributionEnginePollingTask> envNamePerPollingTask = new HashMap<>();
-
- // default test
- testSubject.connectUebTopicTenantIsolation(opEnvEntry, status, envNamePerInitTask, envNamePerPollingTask);
- }
-
- @Test
- public void testConnectUebTopic() throws Exception {
- OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
- AtomicBoolean status = new AtomicBoolean(true);
- Map<String, DistributionEngineInitTask> envNamePerInitTask = new HashMap<>();
- Map<String, DistributionEnginePollingTask> envNamePerPollingTask = new HashMap<>();
-
- // default test
- Deencapsulation.invoke(testSubject, "connectUebTopic", opEnvEntry, status, envNamePerInitTask,
- envNamePerPollingTask);
- }
-
- @Test
- public void testHandleMessage() throws Exception {
- String notification = "";
- boolean result;
-
- // default test
- result = testSubject.handleMessage(notification);
- }
-
- @Test
- public void testHandleMessageLogic() throws Exception {
- String notification = "";
- boolean result;
-
- // default test
- result = testSubject.handleMessageLogic(notification);
- }
-
- @Test
- public void testValidateNotification() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- errorWrapper.setInnerElement(true);
- IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
- IDmaapAuditNotificationData auditNotificationData = Mockito.mock(IDmaapAuditNotificationData.class);
-
- // default test
- Deencapsulation.invoke(testSubject, "validateNotification", errorWrapper, notificationData,
- auditNotificationData);
- }
-
- @Test
- public void testSaveEntryWithFailedStatus() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
-
- // default test
- Deencapsulation.invoke(testSubject, "saveEntryWithFailedStatus", errorWrapper, opEnvEntry);
- }
-
- @Test
- public void testRetrieveUebAddressesFromAftDme() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
-
- // default test
- Deencapsulation.invoke(testSubject, "retrieveUebAddressesFromAftDme", errorWrapper, opEnvEntry);
- }
-
- @Test
- public void testCreateUebKeys() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
-
- Set<String> dmaapUebAddress = new HashSet<>();
- dmaapUebAddress.add("mock");
- opEnvEntry.setDmaapUebAddress(dmaapUebAddress);
-
- Mockito.when(cambriaHandler.createUebKeys(Mockito.any())).thenReturn(Either.left(new ApiCredential("mock", "mock")));
-
- // default test
- Deencapsulation.invoke(testSubject, "createUebKeys", errorWrapper, opEnvEntry);
- }
-
- @Test
- public void testCreateUebKeysError() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
-
- Set<String> dmaapUebAddress = new HashSet<>();
- dmaapUebAddress.add("mock");
- opEnvEntry.setDmaapUebAddress(dmaapUebAddress);
-
- Mockito.when(cambriaHandler.createUebKeys(Mockito.any())).thenReturn(Either.right(new CambriaErrorResponse()));
-
- // default test
- Deencapsulation.invoke(testSubject, "createUebKeys", errorWrapper, opEnvEntry);
- }
-
- @Test
- public void testRetrieveOpEnvInfoFromAAI() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
- opEnvEntry.setEnvironmentId("mock");
- Mockito.when(aaiRequestHandler.getOperationalEnvById(Mockito.nullable(String.class))).thenReturn(new HttpResponse<String>("{}", 200));
- // default test
- Deencapsulation.invoke(testSubject, "retrieveOpEnvInfoFromAAI", new Wrapper<>(), opEnvEntry);
- }
-
- @Test
- public void testRetrieveOpEnvInfoFromAAIError() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
- opEnvEntry.setEnvironmentId("mock");
- Mockito.when(aaiRequestHandler.getOperationalEnvById(Mockito.nullable(String.class))).thenReturn(new HttpResponse<String>("{}", 500));
- // default test
- Deencapsulation.invoke(testSubject, "retrieveOpEnvInfoFromAAI", new Wrapper<>(), opEnvEntry);
- }
-
- @Test
- public void testSaveEntryWithInProgressStatus() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- Wrapper<OperationalEnvironmentEntry> opEnvEntryWrapper = new Wrapper<>();
- IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
-
- Deencapsulation.invoke(testSubject, "saveEntryWithInProgressStatus", errorWrapper, opEnvEntryWrapper,
- notificationData);
- }
-
- @Test
- public void testValidateStateGeneralError() throws Exception {
- Wrapper<Boolean> errorWrapper = null;
- IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
-
- Mockito.when(operationalEnvironmentDao.get(Mockito.nullable(String.class)))
- .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
-
- Deencapsulation.invoke(testSubject, "validateState", new Wrapper<>(), notificationData);
- }
-
- @Test
- public void testValidateState() throws Exception {
- Wrapper<Boolean> errorWrapper = null;
- IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
-
- OperationalEnvironmentEntry a = new OperationalEnvironmentEntry();
- a.setStatus(EnvironmentStatusEnum.IN_PROGRESS.getName());
- Mockito.when(operationalEnvironmentDao.get(Mockito.nullable(String.class))).thenReturn(Either.left(a));
-
- Deencapsulation.invoke(testSubject, "validateState", new Wrapper<>(), notificationData);
- }
-
- @Test
- public void testValidateActionType() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
- Mockito.when(notificationData.getAction()).thenReturn(DmaapActionEnum.DELETE);
-
- Deencapsulation.invoke(testSubject, "validateActionType", errorWrapper, notificationData);
- }
-
- @Test
- public void testValidateActionType2() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
- Mockito.when(notificationData.getAction()).thenReturn(DmaapActionEnum.CREATE);
-
- Deencapsulation.invoke(testSubject, "validateActionType", errorWrapper, notificationData);
- }
-
- @Test
- public void testValidateEnvironmentType() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
- IDmaapAuditNotificationData auditNotificationData = Mockito.mock(IDmaapAuditNotificationData.class);
- Mockito.when(auditNotificationData.getOperationalEnvironmentName()).thenReturn("mock");
- Mockito.when(notificationData.getOperationalEnvironmentType()).thenReturn(OperationaEnvironmentTypeEnum.ECOMP);
-
- // default test
- Deencapsulation.invoke(testSubject, "validateEnvironmentType", errorWrapper, notificationData,
- auditNotificationData);
- }
-
- @Test
- public void testValidateEnvironmentType1() throws Exception {
- Wrapper<Boolean> errorWrapper = new Wrapper<>();
- IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
- IDmaapAuditNotificationData auditNotificationData = Mockito.mock(IDmaapAuditNotificationData.class);
- Mockito.when(auditNotificationData.getOperationalEnvironmentName()).thenReturn("mock");
- Mockito.when(notificationData.getOperationalEnvironmentType()).thenReturn(OperationaEnvironmentTypeEnum.UNKONW);
- Mockito.when(notificationData.getAction()).thenReturn(DmaapActionEnum.CREATE);
-
- Deencapsulation.invoke(testSubject, "validateEnvironmentType", errorWrapper, notificationData,
- auditNotificationData);
- }
-
- @Test
- public void testMap2OpEnvKey() throws Exception {
- OperationalEnvironmentEntry entry = new OperationalEnvironmentEntry();
- String result;
-
- // default test
- result = Deencapsulation.invoke(testSubject, "map2OpEnvKey", entry);
- }
-
- @Test
- public void testReadEnvFromConfig() throws Exception {
- OperationalEnvironmentEntry result;
-
- // default test
- result = Deencapsulation.invoke(testSubject, "readEnvFromConfig");
- }
-
- @Test
- public void testCreateUebTopicsForEnvironment() throws Exception {
- OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
-
- // default test
- testSubject.createUebTopicsForEnvironment(opEnvEntry);
- }
-
- @Test
- public void testSetConfigurationManager() throws Exception {
- ConfigurationManager configurationManager = null;
-
- // default test
- Deencapsulation.invoke(testSubject, "setConfigurationManager", new Object[] { ConfigurationManager.class });
- }
-
- @Test
- public void testGetEnvironments() throws Exception {
- Map<String, OperationalEnvironmentEntry> result;
-
- // default test
- result = testSubject.getEnvironments();
- }
-
- @Test
- public void testIsInMap() throws Exception {
- OperationalEnvironmentEntry env = new OperationalEnvironmentEntry();
- env.setEnvironmentId("mock");
- Map<String, OperationalEnvironmentEntry> mockEnvironments = new HashMap<>();
- mockEnvironments.put("mock", new OperationalEnvironmentEntry());
- boolean result;
-
- // default test
- ReflectionTestUtils.setField(testSubject, "environments", mockEnvironments);
- result = testSubject.isInMap(env);
- }
-} \ No newline at end of file
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+public class EnvironmentsEngineTest {
+
+ @InjectMocks
+ private EnvironmentsEngine envEngine;
+ @Mock
+ private OperationalEnvironmentDao operationalEnvironmentDao;
+ @Mock
+ private ConfigurationManager configurationManager;
+ @Mock
+ private DistributionEngineConfiguration distributionEngineConfiguration;
+ @Mock
+ private AaiRequestHandler aaiRequestHandler;
+
+ @Before
+ public void preStart() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testInit() {
+ envEngine.setConfigurationManager(configurationManager);
+ Configuration config = Mockito.mock(Configuration.class);
+ DmaapConsumerConfiguration dmaapConf = Mockito.mock(DmaapConsumerConfiguration.class);
+ List<OperationalEnvironmentEntry> entryList = Arrays.asList(createOpEnvEntry("Env1"), createOpEnvEntry("Env2"));
+ Either<List<OperationalEnvironmentEntry>, CassandraOperationStatus> successEither = Either.left(entryList);
+ when(operationalEnvironmentDao.getByEnvironmentsStatus(EnvironmentStatusEnum.COMPLETED)).thenReturn(successEither);
+ when(configurationManager.getDistributionEngineConfiguration()).thenReturn(distributionEngineConfiguration);
+ when(distributionEngineConfiguration.getEnvironments()).thenReturn(Arrays.asList("Env Loaded From Configuration"));
+ when(distributionEngineConfiguration.getUebPublicKey()).thenReturn("Dummy Public Key");
+ when(distributionEngineConfiguration.getUebSecretKey()).thenReturn("Dummy Private Key");
+ when(distributionEngineConfiguration.getUebServers()).thenReturn(
+ Arrays.asList("uebsb91kcdc.it.com:3904", "uebsb92kcdc.it.com:3904", "uebsb91kcdc.it.com:3904"));
+ when(configurationManager.getConfiguration()).thenReturn(config);
+ when(config.getDmaapConsumerConfiguration()).thenReturn(dmaapConf);
+ when(dmaapConf.isActive()).thenReturn(false);
+ envEngine.init();
+
+ Map<String, OperationalEnvironmentEntry> mapEnvs = envEngine.getEnvironments();
+ assertEquals("unexpected size of map",3, mapEnvs.size());
+ }
+
+
+ @Test
+ public void testGetFullOperationalEnvByIdSuccess() {
+ String json = getFullOperationalEnvJson();
+
+ HttpResponse restResponse = new HttpResponse(json, HttpStatus.SC_OK, "Successfully completed");
+ when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse);
+
+ Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId");
+ assertTrue("The operational environment request ran as not expected", response.isLeft());
+
+ OperationalEnvInfo operationalEnvInfo = response.left().value();
+
+ assertEquals("The operational environment json is not as expected", operationalEnvInfo.toString(), json);
+ }
+
+ @Test
+ public void testGetPartialOperationalEnvByIdSuccess() {
+ String json = getPartialOperationalEnvJson();
+
+ HttpResponse<String> restResponse = new HttpResponse<String>(json, HttpStatus.SC_OK, "Successfully completed");
+ when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse);
+
+ Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId");
+ assertTrue("The operational environment request ran as not expected", response.isLeft());
+
+ OperationalEnvInfo operationalEnvInfo = response.left().value();
+
+ assertEquals("The operational environment json is not as expected", operationalEnvInfo.toString(), json);
+ }
+
+
+ @Test
+ public void testGetOperationalEnvByIdFailedByJsonConvert() {
+ String jsonCorrupted = getCorruptedOperationalEnvJson();
+
+ HttpResponse<String> restResponse = new HttpResponse<String>(jsonCorrupted, HttpStatus.SC_OK, "Successfully Completed");
+ when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse);
+
+ Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId");
+ assertTrue("The operational environment request ran as not expected", response.isRight());
+ assertEquals("The operational environment request status code is not as expected", (Integer)HttpStatus.SC_INTERNAL_SERVER_ERROR, response.right().value());
+ }
+
+ @Test
+ public void testGetOperationalEnvByIdFailed404() {
+ String json = getFullOperationalEnvJson();
+ HttpResponse<String> restResponse = new HttpResponse<String>(json, HttpStatus.SC_NOT_FOUND, "Not Found");
+ when(aaiRequestHandler.getOperationalEnvById(Mockito.anyString())).thenReturn(restResponse);
+
+ Either<OperationalEnvInfo, Integer> response = envEngine.getOperationalEnvById("DummyId");
+ assertTrue("The operational environment request ran as not expected", response.isRight());
+ assertEquals("The operational environment request status code is not as expected", (Integer)HttpStatus.SC_NOT_FOUND, response.right().value());
+ }
+
+
+ @Test(expected = IOException.class)
+ public void testCorruptedOperationalEnvJson() throws IOException {
+ String jsonCorrupted = getCorruptedOperationalEnvJson();
+ OperationalEnvInfo.createFromJson(jsonCorrupted);
+ }
+
+ @Test
+ public void getEnvironmentById() {
+ OperationalEnvironmentEntry oe = new OperationalEnvironmentEntry();
+ oe.setEnvironmentId("mock");
+ envEngine.addToMap(oe);
+ assertTrue(envEngine.isInMap("mock"));
+ assertTrue(envEngine.isInMap(oe));
+ OperationalEnvironmentEntry returnedOe = envEngine.getEnvironmentById("mock");
+ assertTrue(oe == returnedOe);
+ }
+
+ private String getCorruptedOperationalEnvJson() {
+ return "{\"OPERATIONAL-environment-name\":\"Op Env Name\","
+ + "\"OPERATIONAL-environment-type\":\"VNF\","
+ + "\"OPERATIONAL-environment-status\":\"Activate\","
+ + "\"tenant-context\":\"Test\"}";
+ }
+
+ private String getPartialOperationalEnvJson() {
+ return "{" +
+ "\"operational-environment-id\":\"UUID of Operational Environment\"," +
+ "\"operational-environment-name\":\"Op Env Name\"," +
+ "\"operational-environment-type\":\"VNF\"," +
+ "\"operational-environment-status\":\"Activate\"," +
+ "\"tenant-context\":\"Test\"," +
+ "\"workload-context\":\"VNF_Development\"," +
+ "\"resource-version\":\"1505228226913\"," +
+ "\"relationship-list\":{" +
+ "\"relationship\":[]" +
+ "}" +
+ "}";
+ }
+
+ private String getFullOperationalEnvJson() {
+ return "{" +
+ "\"operational-environment-id\":\"OEid1\"," +
+ "\"operational-environment-name\":\"OEname1\"," +
+ "\"operational-environment-type\":\"OEtype1\"," +
+ "\"operational-environment-status\":\"OEstatus1\"," +
+ "\"tenant-context\":\"OEtenantcontext1\"," +
+ "\"workload-context\":\"OEworkloadcontext1\"," +
+ "\"resource-version\":\"1511363173278\"," +
+ "\"relationship-list\":{" +
+ "\"relationship\":[" +
+ "{" +
+ "\"related-to\":\"operational-environment\"," +
+ "\"relationship-label\":\"managedBy\"," +
+ "\"related-link\":\"/aai/v12/cloud-infrastructure/operational-environments/operational-environment/OEid3\"," +
+ "\"relationship-data\":[" +
+ "{" +
+ "\"relationship-key\":\"operational-environment.operational-environment-id\"," +
+ "\"relationship-value\":\"OEid3\"" +
+ "}" +
+ "]," +
+ "\"related-to-property\":[" +
+ "{" +
+ "\"property-key\":\"operational-environment.operational-environment-name\"," +
+ "\"property-value\":\"OEname3\"" +
+ "}]}]}}";
+ }
+
+ private OperationalEnvironmentEntry createOpEnvEntry(String name) {
+ OperationalEnvironmentEntry entry = new OperationalEnvironmentEntry();
+ entry.setEnvironmentId(name);
+ return entry;
+ }
+
+ public void testHandleMessageLogic() throws Exception {
+ String notification = "";
+ boolean result;
+
+ // default test
+ result = envEngine.handleMessageLogic(notification);
+ }
+
+ @Test
+ public void testValidateNotification() throws Exception {
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ errorWrapper.setInnerElement(true);
+ IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
+ IDmaapAuditNotificationData auditNotificationData = Mockito.mock(IDmaapAuditNotificationData.class);
+
+ // default test
+ Deencapsulation.invoke(envEngine, "validateNotification", errorWrapper, notificationData,
+ auditNotificationData);
+ }
+
+ @Test
+ public void testSaveEntryWithFailedStatus() throws Exception {
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
+
+ // default test
+ Deencapsulation.invoke(envEngine, "saveEntryWithFailedStatus", errorWrapper, opEnvEntry);
+ }
+
+ @Test
+ public void testRetrieveUebAddressesFromAftDme() throws Exception {
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
+
+ // default test
+ Deencapsulation.invoke(envEngine, "retrieveUebAddressesFromAftDme", errorWrapper, opEnvEntry);
+ }
+
+ @Test
+ public void testRetrieveOpEnvInfoFromAAI() throws Exception {
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
+ opEnvEntry.setEnvironmentId("mock");
+ Mockito.when(aaiRequestHandler.getOperationalEnvById(Mockito.nullable(String.class))).thenReturn(new HttpResponse<String>("{}", 200));
+ // default test
+ Deencapsulation.invoke(envEngine, "retrieveOpEnvInfoFromAAI", new Wrapper<>(), opEnvEntry);
+ }
+
+ @Test
+ public void testRetrieveOpEnvInfoFromAAIError() throws Exception {
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ OperationalEnvironmentEntry opEnvEntry = new OperationalEnvironmentEntry();
+ opEnvEntry.setEnvironmentId("mock");
+ Mockito.when(aaiRequestHandler.getOperationalEnvById(Mockito.nullable(String.class))).thenReturn(new HttpResponse<String>("{}", 500));
+ // default test
+ Deencapsulation.invoke(envEngine, "retrieveOpEnvInfoFromAAI", new Wrapper<>(), opEnvEntry);
+ }
+
+ @Test
+ public void testSaveEntryWithInProgressStatus() throws Exception {
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ Wrapper<OperationalEnvironmentEntry> opEnvEntryWrapper = new Wrapper<>();
+ IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
+
+ Deencapsulation.invoke(envEngine, "saveEntryWithInProgressStatus", errorWrapper, opEnvEntryWrapper,
+ notificationData);
+ }
+
+ @Test
+ public void testValidateStateGeneralError() throws Exception {
+ Wrapper<Boolean> errorWrapper = null;
+ IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
+
+ Mockito.when(operationalEnvironmentDao.get(Mockito.nullable(String.class)))
+ .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
+
+ Deencapsulation.invoke(envEngine, "validateState", new Wrapper<>(), notificationData);
+ }
+
+ @Test
+ public void testValidateState() throws Exception {
+ Wrapper<Boolean> errorWrapper = null;
+ IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
+
+ OperationalEnvironmentEntry a = new OperationalEnvironmentEntry();
+ a.setStatus(EnvironmentStatusEnum.IN_PROGRESS.getName());
+ Mockito.when(operationalEnvironmentDao.get(Mockito.nullable(String.class))).thenReturn(Either.left(a));
+
+ Deencapsulation.invoke(envEngine, "validateState", new Wrapper<>(), notificationData);
+ }
+
+ @Test
+ public void testValidateActionType() throws Exception {
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
+ Mockito.when(notificationData.getAction()).thenReturn(IDmaapNotificationData.DmaapActionEnum.DELETE);
+
+ Deencapsulation.invoke(envEngine, "validateActionType", errorWrapper, notificationData);
+ }
+
+ @Test
+ public void testValidateActionType2() throws Exception {
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
+ Mockito.when(notificationData.getAction()).thenReturn(IDmaapNotificationData.DmaapActionEnum.CREATE);
+
+ Deencapsulation.invoke(envEngine, "validateActionType", errorWrapper, notificationData);
+ }
+
+ @Test
+ public void testValidateEnvironmentType() throws Exception {
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ IDmaapNotificationData notificationData = Mockito.mock(IDmaapNotificationData.class);
+ IDmaapAuditNotificationData auditNotificationData = Mockito.mock(IDmaapAuditNotificationData.class);
+ Mockito.when(auditNotificationData.getOperationalEnvironmentName()).thenReturn("mock");
+ Mockito.when(notificationData.getOperationalEnvironmentType()).thenReturn(IDmaapNotificationData.OperationaEnvironmentTypeEnum.ECOMP);
+
+ // default test
+ Deencapsulation.invoke(envEngine, "validateEnvironmentType", errorWrapper, notificationData,
+ auditNotificationData);
+ }
+
+ @Test
+ public void testMap2OpEnvKey() throws Exception {
+ OperationalEnvironmentEntry entry = new OperationalEnvironmentEntry();
+ String result;
+
+ // default test
+ result = Deencapsulation.invoke(envEngine, "map2OpEnvKey", entry);
+ }
+}
diff --git a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
index b54e072291..6211a77042 100644
--- a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
+++ b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
@@ -7,7 +7,7 @@ identificationHeaderFields:
# catalog backend hostname
beFqdn: localhost
-# sdccatalog.att.com
+# sdccatalog.com
# catalog backend http port
beHttpPort: 8080
@@ -645,17 +645,18 @@ environmentContext:
- General_Non-Revenue
dmaapConsumerConfiguration:
- hosts: olsd004.wnsnet.attws.com:3905
+ active: true
+ hosts: olsd004.wnsnet.com:3905
consumerGroup: asdc
consumerId: invalidMamaUser #mama - in Order To Consume Remove This String And Replace It With -> mama
timeoutMs: 15000
limit: 1
pollingInterval: 2
- topic: com.att.sdc.23911-SDCforTestDev-v001
+ topic: com.sdc.23911-SDCforTestDev-v001
latitude: 32.109333
longitude: 34.855499
version: 1.0
- serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events
+ serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.com/events
environment: TEST
partner: BOT_R
routeOffer: MR1
@@ -669,7 +670,7 @@ dmaapConsumerConfiguration:
dme2preferredRouterFilePath: DME2preferredRouter.txt
timeLimitForNotificationHandleMs: 0
credential:
- username: m09875@sdc.att.com
+ username: m09875@sdc.com
password: hmXYcznAljMSisdy8zgcag==
dmeConfiguration:
diff --git a/common-app-api/pom.xml b/common-app-api/pom.xml
index 5a0824b3b8..4b58258dc6 100644
--- a/common-app-api/pom.xml
+++ b/common-app-api/pom.xml
@@ -171,6 +171,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.google.code.bean-matchers</groupId>
+ <artifactId>bean-matchers</artifactId>
+ <version>${bean-matchers.version}</version>
+ <scope>test</scope>
+ </dependency>
+
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
<dependency>
<groupId>org.jsoup</groupId>
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/be/config/DmaapConsumerConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DmaapConsumerConfiguration.java
index 1ba539b942..2493d53dd0 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/be/config/DmaapConsumerConfiguration.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/be/config/DmaapConsumerConfiguration.java
@@ -3,7 +3,7 @@ package org.openecomp.sdc.be.config;
* Contains DMAAP Client configuration parameters
*/
public class DmaapConsumerConfiguration {
-
+ private boolean active;
private String hosts;
private String consumerGroup;
private String consumerId;
@@ -216,7 +216,11 @@ public class DmaapConsumerConfiguration {
public void setCredential(Credential credential) {
this.credential = credential;
}
-
+
+ public boolean isActive() { return active; }
+
+ public void setActive(boolean isActive) { this.active = isActive; }
+
/**
* Contains Dmaap Client credential parameters: username and password
*/
@@ -246,7 +250,7 @@ public class DmaapConsumerConfiguration {
@Override
public String toString() {
- return "DmaapConsumerConfiguration [hosts=" + hosts + ", consumerGroup=" + consumerGroup + ", consumerId="
+ return "DmaapConsumerConfiguration [active=" + active + ", hosts=" + hosts + ", consumerGroup=" + consumerGroup + ", consumerId="
+ consumerId + ", timeoutMs=" + timeoutMs + ", limit=" + limit + ", pollingInterval=" + pollingInterval
+ ", topic=" + topic + ", latitude=" + latitude + ", longitude=" + longitude + ", version=" + version
+ ", serviceName=" + serviceName + ", environment=" + environment + ", partner=" + partner
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmaapConsumerConfigurationTest.java b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmaapConsumerConfigurationTest.java
index a4087b34c5..8c19a0a48f 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmaapConsumerConfigurationTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/be/config/DmaapConsumerConfigurationTest.java
@@ -1,561 +1,38 @@
package org.openecomp.sdc.be.config;
+import com.google.code.beanmatchers.BeanMatchers;
import org.junit.Test;
-import org.openecomp.sdc.be.config.DmaapConsumerConfiguration.Credential;
+import static org.hamcrest.MatcherAssert.assertThat;
public class DmaapConsumerConfigurationTest {
- private DmaapConsumerConfiguration createTestSubject() {
- return new DmaapConsumerConfiguration();
- }
-
-
- @Test
- public void testGetHosts() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getHosts();
- }
-
-
- @Test
- public void testSetHosts() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String hosts = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setHosts(hosts);
- }
-
-
- @Test
- public void testGetConsumerGroup() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getConsumerGroup();
- }
-
-
- @Test
- public void testSetConsumerGroup() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String consumerGroup = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setConsumerGroup(consumerGroup);
- }
-
-
- @Test
- public void testGetConsumerId() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getConsumerId();
- }
-
-
- @Test
- public void testSetConsumerId() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String consumerId = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setConsumerId(consumerId);
- }
-
-
- @Test
- public void testGetTimeoutMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTimeoutMs();
- }
-
-
- @Test
- public void testSetTimeoutMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer timeoutMs = 0;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTimeoutMs(timeoutMs);
- }
-
-
- @Test
- public void testGetLimit() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLimit();
- }
-
-
- @Test
- public void testSetLimit() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer limit = 0;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setLimit(limit);
- }
-
-
- @Test
- public void testGetPollingInterval() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getPollingInterval();
- }
-
-
- @Test
- public void testSetPollingInterval() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer pollingInterval = 0;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setPollingInterval(pollingInterval);
- }
-
-
- @Test
- public void testGetTopic() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTopic();
- }
-
-
- @Test
- public void testSetTopic() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String topic = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTopic(topic);
- }
-
-
- @Test
- public void testGetLatitude() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Double result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLatitude();
- }
-
-
- @Test
- public void testSetLatitude() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Double latitude = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setLatitude(latitude);
- }
-
-
- @Test
- public void testGetLongitude() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Double result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getLongitude();
- }
-
-
- @Test
- public void testSetLongitude() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Double longitude = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setLongitude(longitude);
- }
-
-
- @Test
- public void testGetVersion() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getVersion();
- }
-
-
- @Test
- public void testSetVersion() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String version = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setVersion(version);
- }
-
-
- @Test
- public void testGetServiceName() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getServiceName();
- }
-
-
- @Test
- public void testSetServiceName() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String serviceName = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setServiceName(serviceName);
- }
-
-
- @Test
- public void testGetEnvironment() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getEnvironment();
- }
-
-
- @Test
- public void testSetEnvironment() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String environment = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setEnvironment(environment);
- }
-
-
@Test
- public void testGetPartner() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getPartner();
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(DmaapConsumerConfiguration.class, BeanMatchers.hasValidGettersAndSetters());
}
-
- @Test
- public void testSetPartner() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String partner = "";
+ @Test
+ public void shouldHaveValidCtor() {
+ assertThat(DmaapConsumerConfiguration.class, BeanMatchers.hasValidBeanConstructor());
+ }
- // default test
- testSubject = createTestSubject();
- testSubject.setPartner(partner);
- }
+ @Test
+ public void shouldHaveValidToString() {
+ assertThat(DmaapConsumerConfiguration.class, BeanMatchers.hasValidBeanToString());
+ }
-
- @Test
- public void testGetRouteOffer() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
+ @Test
+ public void shouldHaveValidGettersAndSettersNested() {
+ assertThat(DmaapConsumerConfiguration.Credential.class, BeanMatchers.hasValidGettersAndSetters());
+ }
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRouteOffer();
- }
+ @Test
+ public void shouldHaveValidCtorNested() {
+ assertThat(DmaapConsumerConfiguration.Credential.class, BeanMatchers.hasValidBeanConstructor());
+ }
-
- @Test
- public void testSetRouteOffer() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String routeOffer = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setRouteOffer(routeOffer);
- }
-
-
- @Test
- public void testGetProtocol() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getProtocol();
- }
-
-
- @Test
- public void testSetProtocol() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String protocol = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setProtocol(protocol);
- }
-
-
- @Test
- public void testGetContenttype() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getContenttype();
- }
-
-
- @Test
- public void testSetContenttype() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String contenttype = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setContenttype(contenttype);
- }
-
-
- @Test
- public void testIsDme2TraceOn() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isDme2TraceOn();
- }
-
-
- @Test
- public void testGetDme2TraceOn() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDme2TraceOn();
- }
-
-
- @Test
- public void testSetDme2TraceOn() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Boolean dme2TraceOn = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDme2TraceOn(dme2TraceOn);
- }
-
-
- @Test
- public void testGetAftEnvironment() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAftEnvironment();
- }
-
-
- @Test
- public void testSetAftEnvironment() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String aftEnvironment = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAftEnvironment(aftEnvironment);
- }
-
-
- @Test
- public void testGetAftDme2ConnectionTimeoutMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAftDme2ConnectionTimeoutMs();
- }
-
-
- @Test
- public void testSetAftDme2ConnectionTimeoutMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer aftDme2ConnectionTimeoutMs = 0;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAftDme2ConnectionTimeoutMs(aftDme2ConnectionTimeoutMs);
- }
-
-
- @Test
- public void testGetAftDme2RoundtripTimeoutMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAftDme2RoundtripTimeoutMs();
- }
-
-
- @Test
- public void testSetAftDme2RoundtripTimeoutMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer aftDme2RoundtripTimeoutMs = 0;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAftDme2RoundtripTimeoutMs(aftDme2RoundtripTimeoutMs);
- }
-
-
- @Test
- public void testGetAftDme2ReadTimeoutMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAftDme2ReadTimeoutMs();
- }
-
-
- @Test
- public void testSetAftDme2ReadTimeoutMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer aftDme2ReadTimeoutMs = 0;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAftDme2ReadTimeoutMs(aftDme2ReadTimeoutMs);
- }
-
-
- @Test
- public void testGetDme2preferredRouterFilePath() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getDme2preferredRouterFilePath();
- }
-
-
- @Test
- public void testSetDme2preferredRouterFilePath() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String dme2preferredRouterFilePath = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setDme2preferredRouterFilePath(dme2preferredRouterFilePath);
- }
-
-
- @Test
- public void testGetCredential() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Credential result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCredential();
- }
-
-
- @Test
- public void testSetCredential() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Credential credential = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setCredential(credential);
- }
-
-
- @Test
- public void testToString() throws Exception {
- DmaapConsumerConfiguration testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-
-
- @Test
- public void testGetTimeLimitForNotificationHandleMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTimeLimitForNotificationHandleMs();
- }
-
-
- @Test
- public void testSetTimeLimitForNotificationHandleMs() throws Exception {
- DmaapConsumerConfiguration testSubject;
- Integer timeLimitForNotificationHandleMs = 0;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTimeLimitForNotificationHandleMs(timeLimitForNotificationHandleMs);
- }
+ @Test
+ public void shouldHaveValidToStringNested() {
+ assertThat(DmaapConsumerConfiguration.Credential.class, BeanMatchers.hasValidBeanToString());
+ }
} \ No newline at end of file