aboutsummaryrefslogtreecommitdiffstats
path: root/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap')
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/CamundaConfigurationTest.java43
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/CamundaRestUrlProviderTest.java78
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/HttpServiceProviderConfigurationTest.java69
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/PojoClassesTests.java78
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/database/DatabaseUrlProviderTest.java51
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/db/api/DatabaseServiceProviderTest.java104
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderTest.java230
-rw-r--r--so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/utils/ObjectEqualsUtilsTest.java69
8 files changed, 722 insertions, 0 deletions
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/CamundaConfigurationTest.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/CamundaConfigurationTest.java
new file mode 100644
index 0000000..b08d247
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/CamundaConfigurationTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.configuration;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.onap.so.monitoring.configuration.camunda.CamundaConfiguration;
+import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider;
+
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public class CamundaConfigurationTest {
+
+ @Test
+ public void test_CamundaRestURIConfiguration_ValidUrl() {
+ final CamundaConfiguration objUnderTest = new CamundaConfiguration();
+ final CamundaRestUrlProvider provider = objUnderTest.camundaRestUrlProvider("http://localhost:8080", "default");
+ assertEquals(
+ "http://localhost:8080/default/history/activity-instance?processInstanceId=Deadpool&sortBy=startTime&sortOrder=asc",
+ provider.getActivityInstanceUrl("Deadpool"));
+ }
+
+}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/CamundaRestUrlProviderTest.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/CamundaRestUrlProviderTest.java
new file mode 100644
index 0000000..e2d6ddb
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/CamundaRestUrlProviderTest.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.configuration;
+
+import static org.junit.Assert.assertEquals;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ */
+public class CamundaRestUrlProviderTest {
+ private static final String DEFAULT = "default";
+ private static final String CAMUNDA_REST_API_URL = "http://localhost:9080/engine-rest/engine/";
+ private static final String BASE_URL = CAMUNDA_REST_API_URL + DEFAULT;
+ private final CamundaRestUrlProvider objUnderTest = new CamundaRestUrlProvider(CAMUNDA_REST_API_URL, DEFAULT);
+ private static final String ID = UUID.randomUUID().toString();
+
+
+ @Test
+ public void test_GetHistoryProcessInstanceUrl() {
+ final String expectedUrl = BASE_URL + "/history/process-instance?variables=requestId_eq_" + ID;
+ final String actualUrl = objUnderTest.getHistoryProcessInstanceUrl(ID);
+ assertEquals(expectedUrl, actualUrl);
+ }
+
+ @Test
+ public void test_GetProcessInstanceUrl() {
+ final String expectedUrl = BASE_URL + "/history/process-instance/" + ID;
+ final String actualUrl = objUnderTest.getSingleProcessInstanceUrl(ID);
+ assertEquals(expectedUrl, actualUrl);
+ }
+
+
+ @Test
+ public void test_GetProcessDefinitionUrl() {
+ final String expectedUrl = BASE_URL + "/process-definition/" + ID + "/xml";
+ final String actualUrl = objUnderTest.getProcessDefinitionUrl(ID);
+ assertEquals(expectedUrl, actualUrl);
+
+ }
+
+ @Test
+ public void test_GetActivityIntanceUrl() {
+ final String expectedUrl =
+ BASE_URL + "/history/activity-instance?processInstanceId=" + ID + "&sortBy=startTime&sortOrder=asc";
+ final String actualUrl = objUnderTest.getActivityInstanceUrl(ID);
+ assertEquals(expectedUrl, actualUrl);
+
+ }
+
+ @Test
+ public void test_GetProcessInstanceVariablesUrl() {
+ final String expectedUrl = BASE_URL + "/history/variable-instance?processInstanceId=" + ID;
+ final String actualUrl = objUnderTest.getProcessInstanceVariablesUrl(ID);
+ assertEquals(expectedUrl, actualUrl);
+
+ }
+
+}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/HttpServiceProviderConfigurationTest.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/HttpServiceProviderConfigurationTest.java
new file mode 100644
index 0000000..d85a034
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/HttpServiceProviderConfigurationTest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.configuration;
+
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+import org.onap.so.monitoring.configuration.rest.HttpServiceProviderConfiguration;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public class HttpServiceProviderConfigurationTest {
+
+ private final HttpServiceProviderConfiguration objUnderTest = new HttpServiceProviderConfiguration();
+ private static final String AUTHORIZATION =
+ "Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==";
+
+ @Test
+ public void test_CamundaHttpRestServiceProvider_NotNull() {
+
+ final HttpRestServiceProvider serviceProvider =
+ objUnderTest.camundaHttpRestServiceProvider(new RestTemplate(), AUTHORIZATION);
+
+ assertNotNull(serviceProvider);
+ }
+
+ @Test
+ public void test_DatabaseHttpRestServiceProvider_NotNull() {
+
+ final HttpRestServiceProvider serviceProvider =
+ objUnderTest.databaseHttpRestServiceProvider(new RestTemplate(), AUTHORIZATION);
+
+ assertNotNull(serviceProvider);
+ }
+
+ @Test
+ public void test_DatabaseHttpRestServiceProviderWithAuthorizationNullOrEmpty_NotNull() {
+
+ HttpRestServiceProvider serviceProvider =
+ objUnderTest.databaseHttpRestServiceProvider(new RestTemplate(), null);
+
+ assertNotNull(serviceProvider);
+
+ serviceProvider = objUnderTest.databaseHttpRestServiceProvider(new RestTemplate(), "");
+
+ assertNotNull(serviceProvider);
+ }
+
+}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/PojoClassesTests.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/PojoClassesTests.java
new file mode 100644
index 0000000..fbd0aea
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/PojoClassesTests.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.configuration;
+
+import static org.junit.Assert.assertFalse;
+import java.util.Set;
+import java.util.regex.Pattern;
+import org.junit.Test;
+import org.onap.so.openpojo.rules.ToStringTester;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
+import org.springframework.core.type.filter.RegexPatternTypeFilter;
+import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+import nl.jqno.equalsverifier.EqualsVerifier;
+import nl.jqno.equalsverifier.Warning;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ */
+public class PojoClassesTests {
+
+ @Test
+ public void test_camunda_module_pojo_classes() throws ClassNotFoundException {
+ test("org.onap.so.monitoring.camunda.model");
+ assertEqualMethod("org.onap.so.monitoring.camunda.model");
+ }
+
+ @Test
+ public void test_so_monitoring_pojo_classes() throws ClassNotFoundException {
+ test("org.onap.so.monitoring.model");
+ assertEqualMethod("org.onap.so.monitoring.model");
+ }
+
+ public void assertEqualMethod(final String pojoPackage) throws ClassNotFoundException {
+ final Set<BeanDefinition> classes = getBeanDefinition(pojoPackage);
+ assertFalse(classes.isEmpty());
+ for (final BeanDefinition bean : classes) {
+ final Class<?> clazz = Class.forName(bean.getBeanClassName());
+ if (!clazz.getName().endsWith("Builder")) {
+ EqualsVerifier.forClass(clazz).suppress(Warning.STRICT_INHERITANCE, Warning.NONFINAL_FIELDS).verify();
+ }
+ }
+ }
+
+ private Set<BeanDefinition> getBeanDefinition(final String pojoPackage) {
+ final ClassPathScanningCandidateComponentProvider provider =
+ new ClassPathScanningCandidateComponentProvider(false);
+ provider.addIncludeFilter(new RegexPatternTypeFilter(Pattern.compile(pojoPackage + ".*")));
+ return provider.findCandidateComponents(pojoPackage);
+ }
+
+ private void test(final String pojoPackage) {
+ final Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester())
+ .with(new ToStringTester()).build();
+ validator.validate(pojoPackage, new FilterPackageInfo());
+ }
+}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/database/DatabaseUrlProviderTest.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/database/DatabaseUrlProviderTest.java
new file mode 100644
index 0000000..5484b7a
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/configuration/database/DatabaseUrlProviderTest.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.configuration.database;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+
+/**
+ * @author waqas.ikram@ericsson.com
+ */
+public class DatabaseUrlProviderTest {
+
+ private static final int MAX_RESULT = 1;
+ private static final String URL = "http://localhost:8081/infraActiveRequests/";
+ private final DatabaseUrlProvider objUnderTest = new DatabaseUrlProvider(URL);
+
+ @Test
+ public void test_maxResultNull() {
+ final long from = System.currentTimeMillis();
+ final long to = System.currentTimeMillis();
+ final String actualUrl = objUnderTest.getSearchUrl(from, to, null);
+ assertEquals(URL + "v1/getInfraActiveRequests?from=" + from + "&to=" + to, actualUrl);
+ }
+
+ @Test
+ public void test_maxResultNotNull() {
+ final long from = System.currentTimeMillis();
+ final long to = System.currentTimeMillis();
+ final String actualUrl = objUnderTest.getSearchUrl(from, to, MAX_RESULT);
+ assertEquals(URL + "v1/getInfraActiveRequests?from=" + from + "&to=" + to + "&maxResult=" + MAX_RESULT,
+ actualUrl);
+ }
+}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/db/api/DatabaseServiceProviderTest.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/db/api/DatabaseServiceProviderTest.java
new file mode 100644
index 0000000..36a39d9
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/db/api/DatabaseServiceProviderTest.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.db.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.so.monitoring.camunda.model.SoActiveInfraRequests;
+import org.onap.so.monitoring.configuration.database.DatabaseUrlProvider;
+import org.onap.so.monitoring.db.service.DatabaseServiceProvider;
+import org.onap.so.monitoring.db.service.DatabaseServiceProviderImpl;
+import org.onap.so.monitoring.model.SoInfraRequest;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import com.google.common.base.Optional;
+
+
+/**
+ * @author waqas.ikram@ericsson.com
+ */
+public class DatabaseServiceProviderTest {
+
+ private final static DatabaseUrlProvider URL_PROVIDER =
+ new DatabaseUrlProvider("http://localhost:8081/infraActiveRequests/");
+
+ @Test
+ public void test_GetSoInfraRequest_WithEmptyFilters_EmptyList() {
+ final HttpRestServiceProvider mockServiceProvider = mock(HttpRestServiceProvider.class);
+ final String searchUrl = URL_PROVIDER.getSearchUrl(0, 0, null);
+ final Optional<SoActiveInfraRequests[]> response = Optional.of(new SoActiveInfraRequests[] {});
+
+ when(mockServiceProvider.post(eq(Collections.emptyMap()), eq(searchUrl), eq(SoActiveInfraRequests[].class)))
+ .thenReturn(response);
+
+ final DatabaseServiceProvider objUnderTest = new DatabaseServiceProviderImpl(URL_PROVIDER, mockServiceProvider);
+
+ assertTrue(objUnderTest.getSoInfraRequest(Collections.emptyMap(), 0, 0, null).isEmpty());
+ }
+
+ @Test
+ public void test_GetSoInfraRequest_OptionalAbsent_EmptyList() {
+ final HttpRestServiceProvider mockServiceProvider = mock(HttpRestServiceProvider.class);
+ final String searchUrl = URL_PROVIDER.getSearchUrl(0, 0, null);
+ final Optional<SoActiveInfraRequests[]> response = Optional.absent();
+
+ when(mockServiceProvider.post(eq(Collections.emptyMap()), eq(searchUrl), eq(SoActiveInfraRequests[].class)))
+ .thenReturn(response);
+
+ final DatabaseServiceProvider objUnderTest = new DatabaseServiceProviderImpl(URL_PROVIDER, mockServiceProvider);
+
+ assertTrue(objUnderTest.getSoInfraRequest(Collections.emptyMap(), 0, 0, null).isEmpty());
+ }
+
+ @Test
+ public void test_GetSoInfraRequest_WithFilters_InfraActiveRequestsList() {
+ final String searchUrl = URL_PROVIDER.getSearchUrl(0, 0, null);
+ final String requestID = UUID.randomUUID().toString();
+ final Map<String, String[]> filters = new HashMap<>();
+ filters.put("requestId", new String[] {"EQ", requestID});
+
+ final SoActiveInfraRequests soActiveInfraRequests = new SoActiveInfraRequests();
+ soActiveInfraRequests.setRequestId(requestID);
+
+ final Optional<SoActiveInfraRequests[]> response =
+ Optional.of(new SoActiveInfraRequests[] {soActiveInfraRequests});
+
+ final HttpRestServiceProvider mockServiceProvider = mock(HttpRestServiceProvider.class);
+
+ when(mockServiceProvider.post(eq(filters), eq(searchUrl), eq(SoActiveInfraRequests[].class)))
+ .thenReturn(response);
+
+ final DatabaseServiceProvider objUnderTest = new DatabaseServiceProviderImpl(URL_PROVIDER, mockServiceProvider);
+
+ final List<SoInfraRequest> actualList = objUnderTest.getSoInfraRequest(filters, 0, 0, null);
+ assertFalse(actualList.isEmpty());
+ assertEquals(requestID, actualList.get(0).getRequestId());
+
+ }
+}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderTest.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderTest.java
new file mode 100644
index 0000000..61b8b89
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderTest.java
@@ -0,0 +1,230 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.rest.service;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.util.List;
+import java.util.UUID;
+import org.junit.Test;
+import org.onap.so.monitoring.camunda.model.ActivityInstance;
+import org.onap.so.monitoring.camunda.model.ProcessDefinition;
+import org.onap.so.monitoring.camunda.model.ProcessInstance;
+import org.onap.so.monitoring.camunda.model.ProcessInstanceVariable;
+import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider;
+import org.onap.so.monitoring.model.ActivityInstanceDetail;
+import org.onap.so.monitoring.model.ProcessDefinitionDetail;
+import org.onap.so.monitoring.model.ProcessInstanceIdDetail;
+import org.onap.so.monitoring.model.ProcessInstanceVariableDetail;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import com.google.common.base.Optional;
+
+
+/**
+ * @author waqas.ikram@ericsson.com
+ */
+public class CamundaProcessDataServiceProviderTest {
+ private static final String DURATION = "1";
+ private static final String FLOW_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ private static final String NAME = "Test";
+ private static final String DEFAULT = "default";
+ private static final String CAMUNDA_REST_API_URL = "http://localhost:9080/engine-rest/engine/";
+
+ private static final String ID = UUID.randomUUID().toString();
+ private static final String PROCESS_ID = UUID.randomUUID().toString();
+ private static final String DEF_ID = UUID.randomUUID().toString();
+ private static final String SUPER_PROCESS_ID = UUID.randomUUID().toString();
+ private final HttpRestServiceProvider httpRestServiceProvider = mock(HttpRestServiceProvider.class);
+ private final CamundaRestUrlProvider camundaRestUrlProvider =
+ new CamundaRestUrlProvider(CAMUNDA_REST_API_URL, DEFAULT);
+
+
+ @Test
+ public void test_GetProcessInstanceDetail_EmptyResponse() {
+ final Optional<ProcessInstance[]> response = Optional.<ProcessInstance[]>absent();
+ final String url = CAMUNDA_REST_API_URL + DEFAULT + "/history/process-instance?variables=requestId_eq_" + ID;
+ when(httpRestServiceProvider.get(url, ProcessInstance[].class)).thenReturn(response);
+ final CamundaProcessDataServiceProvider objUnderTest =
+ new CamundaProcessDataServiceProviderImpl(camundaRestUrlProvider, httpRestServiceProvider);
+
+ final Optional<ProcessInstanceIdDetail> actualResponse = objUnderTest.getProcessInstanceIdDetail(ID);
+ assertFalse(actualResponse.isPresent());
+ }
+
+ @Test
+ public void test_GetProcessInstanceDetail_NonEmptyResponseWithSuperProcessIdNull() {
+ final Optional<ProcessInstance[]> response = Optional.of(getProcessInstance());
+ final String url = CAMUNDA_REST_API_URL + DEFAULT + "/history/process-instance?variables=requestId_eq_" + ID;
+ when(httpRestServiceProvider.get(url, ProcessInstance[].class)).thenReturn(response);
+ final CamundaProcessDataServiceProvider objUnderTest =
+ new CamundaProcessDataServiceProviderImpl(camundaRestUrlProvider, httpRestServiceProvider);
+
+ final Optional<ProcessInstanceIdDetail> actualResponse = objUnderTest.getProcessInstanceIdDetail(ID);
+ assertTrue(actualResponse.isPresent());
+
+ final ProcessInstanceIdDetail actualProcessInstanceDetail = actualResponse.get();
+ assertEquals(PROCESS_ID, actualProcessInstanceDetail.getProcessInstanceId());
+ }
+
+ @Test
+ public void test_GetProcessInstanceDetail_NonEmptyResponseWithSuperProcessIdNotNull() {
+ final Optional<ProcessInstance[]> response = Optional.of(getProcessInstance(SUPER_PROCESS_ID));
+ final String url = CAMUNDA_REST_API_URL + DEFAULT + "/history/process-instance?variables=requestId_eq_" + ID;
+ when(httpRestServiceProvider.get(url, ProcessInstance[].class)).thenReturn(response);
+ final CamundaProcessDataServiceProvider objUnderTest =
+ new CamundaProcessDataServiceProviderImpl(camundaRestUrlProvider, httpRestServiceProvider);
+
+ final Optional<ProcessInstanceIdDetail> actualResponse = objUnderTest.getProcessInstanceIdDetail(ID);
+ assertFalse(actualResponse.isPresent());
+
+ }
+
+ @Test
+ public void test_GetProcessDefinition_EmptyResponse() {
+ final Optional<ProcessDefinition> response = Optional.<ProcessDefinition>absent();
+ final String url = CAMUNDA_REST_API_URL + DEFAULT + "/process-definition/" + ID + "/xml";
+ when(httpRestServiceProvider.get(url, ProcessDefinition.class)).thenReturn(response);
+ final CamundaProcessDataServiceProvider objUnderTest =
+ new CamundaProcessDataServiceProviderImpl(camundaRestUrlProvider, httpRestServiceProvider);
+
+ final Optional<ProcessDefinitionDetail> actualResponse = objUnderTest.getProcessDefinition(ID);
+ assertFalse(actualResponse.isPresent());
+ }
+
+ @Test
+ public void test_GetProcessDefinition_NonEmptyResponse() {
+ final Optional<ProcessDefinition> response = getProcessDefinition();
+ final String url = CAMUNDA_REST_API_URL + DEFAULT + "/process-definition/" + PROCESS_ID + "/xml";
+ when(httpRestServiceProvider.get(url, ProcessDefinition.class)).thenReturn(response);
+ final CamundaProcessDataServiceProvider objUnderTest =
+ new CamundaProcessDataServiceProviderImpl(camundaRestUrlProvider, httpRestServiceProvider);
+
+ final Optional<ProcessDefinitionDetail> actualResponse = objUnderTest.getProcessDefinition(PROCESS_ID);
+ assertTrue(actualResponse.isPresent());
+ assertEquals(PROCESS_ID, actualResponse.get().getProcessDefinitionId());
+ assertEquals(FLOW_XML, actualResponse.get().getProcessDefinitionXml());
+ }
+
+ @Test
+ public void test_GetActivityInstance_EmptyResponse() {
+ final Optional<ActivityInstance[]> response = Optional.<ActivityInstance[]>absent();
+ final String url = CAMUNDA_REST_API_URL + DEFAULT + "/history/activity-instance?processInstanceId=" + PROCESS_ID
+ + "&sortBy=startTime&sortOrder=asc";
+ when(httpRestServiceProvider.get(url, ActivityInstance[].class)).thenReturn(response);
+ final CamundaProcessDataServiceProvider objUnderTest =
+ new CamundaProcessDataServiceProviderImpl(camundaRestUrlProvider, httpRestServiceProvider);
+
+ final List<ActivityInstanceDetail> actualResponse = objUnderTest.getActivityInstance(PROCESS_ID);
+ assertTrue(actualResponse.isEmpty());
+
+ }
+
+ @Test
+ public void test_GetActivityInstance_NonEmptyResponse() {
+ final Optional<ActivityInstance[]> response = getActivityInstance();
+ final String url = CAMUNDA_REST_API_URL + DEFAULT + "/history/activity-instance?processInstanceId=" + PROCESS_ID
+ + "&sortBy=startTime&sortOrder=asc";
+ when(httpRestServiceProvider.get(url, ActivityInstance[].class)).thenReturn(response);
+ final CamundaProcessDataServiceProvider objUnderTest =
+ new CamundaProcessDataServiceProviderImpl(camundaRestUrlProvider, httpRestServiceProvider);
+
+ final List<ActivityInstanceDetail> actualResponse = objUnderTest.getActivityInstance(PROCESS_ID);
+ assertFalse(actualResponse.isEmpty());
+ final ActivityInstanceDetail actualActivityInstanceDetail = actualResponse.get(0);
+ assertEquals(ID, actualActivityInstanceDetail.getActivityId());
+ assertEquals(NAME, actualActivityInstanceDetail.getActivityName());
+ assertEquals(NAME, actualActivityInstanceDetail.getActivityType());
+
+ }
+
+ @Test
+ public void test_GetProcessInstanceVariable_EmptyResponse() {
+ final Optional<ProcessInstanceVariable[]> response = Optional.<ProcessInstanceVariable[]>absent();
+ final String url =
+ CAMUNDA_REST_API_URL + DEFAULT + "/history/variable-instance?processInstanceId=" + PROCESS_ID;
+ when(httpRestServiceProvider.get(url, ProcessInstanceVariable[].class)).thenReturn(response);
+ final CamundaProcessDataServiceProvider objUnderTest =
+ new CamundaProcessDataServiceProviderImpl(camundaRestUrlProvider, httpRestServiceProvider);
+
+ final List<ProcessInstanceVariableDetail> actualResponse = objUnderTest.getProcessInstanceVariable(PROCESS_ID);
+ assertTrue(actualResponse.isEmpty());
+
+ }
+
+ @Test
+ public void test_GetProcessInstanceVariable_NonEmptyResponse() {
+ final Optional<ProcessInstanceVariable[]> response = getProcessInstanceVariable();
+ final String url =
+ CAMUNDA_REST_API_URL + DEFAULT + "/history/variable-instance?processInstanceId=" + PROCESS_ID;
+ when(httpRestServiceProvider.get(url, ProcessInstanceVariable[].class)).thenReturn(response);
+ final CamundaProcessDataServiceProvider objUnderTest =
+ new CamundaProcessDataServiceProviderImpl(camundaRestUrlProvider, httpRestServiceProvider);
+
+ final List<ProcessInstanceVariableDetail> actualResponse = objUnderTest.getProcessInstanceVariable(PROCESS_ID);
+ assertFalse(actualResponse.isEmpty());
+ final ProcessInstanceVariableDetail variableDetail = actualResponse.get(0);
+ assertEquals(NAME, variableDetail.getName());
+ assertEquals(NAME, variableDetail.getType());
+ assertEquals(NAME, variableDetail.getValue());
+
+ }
+
+ private Optional<ProcessInstanceVariable[]> getProcessInstanceVariable() {
+ final ProcessInstanceVariable instanceVariable = new ProcessInstanceVariable();
+ instanceVariable.setName(NAME);
+ instanceVariable.setType(NAME);
+ instanceVariable.setValue(NAME);
+ return Optional.of(new ProcessInstanceVariable[] {instanceVariable});
+ }
+
+ private Optional<ActivityInstance[]> getActivityInstance() {
+ final ActivityInstance activityInstance = new ActivityInstance();
+ activityInstance.setActivityId(ID);
+ activityInstance.setActivityName(NAME);
+ activityInstance.setActivityType(NAME);
+ activityInstance.setDurationInMillis(DURATION);
+ return Optional.of(new ActivityInstance[] {activityInstance});
+ }
+
+ private Optional<ProcessDefinition> getProcessDefinition() {
+ final ProcessDefinition processDefinition = new ProcessDefinition();
+ processDefinition.setId(PROCESS_ID);
+ processDefinition.setBpmn20Xml(FLOW_XML);
+ return Optional.of(processDefinition);
+ }
+
+ private ProcessInstance[] getProcessInstance() {
+ return getProcessInstance(null);
+ }
+
+ private ProcessInstance[] getProcessInstance(final String superProcessInstanceId) {
+ final ProcessInstance instance = new ProcessInstance();
+ instance.setId(PROCESS_ID);
+ instance.setProcessDefinitionId(DEF_ID);
+ instance.setProcessDefinitionName(NAME);
+ instance.setSuperProcessInstanceId(superProcessInstanceId);
+ return new ProcessInstance[] {instance};
+ }
+
+
+}
diff --git a/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/utils/ObjectEqualsUtilsTest.java b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/utils/ObjectEqualsUtilsTest.java
new file mode 100644
index 0000000..b4dd271
--- /dev/null
+++ b/so-admin-cockpit-monitoring-workflow/so-admin-cockpit-monitoring-workflow-handler/src/test/java/org/onap/so/monitoring/utils/ObjectEqualsUtilsTest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2018 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.monitoring.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Test;
+
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+public class ObjectEqualsUtilsTest {
+
+ private static final String VALUE = "Humpty Dumpty Sat On The Wall";
+
+ @Test
+ public void test_ObjectEqualsUtils_isEqual_NullValues() {
+ assertTrue(ObjectEqualsUtils.isEqual(null, null));
+ }
+
+ @Test
+ public void test_ObjectEqualsUtils_isEqual_FirstValueNullSecondNotNull() {
+ assertFalse(ObjectEqualsUtils.isEqual(null, VALUE));
+ }
+
+ @Test
+ public void test_ObjectEqualsUtils_isEqual_FirstValueNotNullSecondNull() {
+ assertFalse(ObjectEqualsUtils.isEqual(VALUE, null));
+ }
+
+ @Test
+ public void test_ObjectEqualsUtils_isEqual_NotNullValues() {
+ assertTrue(ObjectEqualsUtils.isEqual(VALUE, VALUE));
+ }
+
+ @Test
+ public void test_ObjectEqualsUtils_isEqual_CollectionValues() {
+ final List<Object> firstObject = Arrays.asList(VALUE);
+ final List<Object> secondObject = Arrays.asList(VALUE);
+ assertTrue(ObjectEqualsUtils.isEqual(firstObject, secondObject));
+ }
+
+ @Test
+ public void test_ObjectEqualsUtils_isEqual_CollectionAndStringValues() {
+ final List<Object> firstObject = Arrays.asList(VALUE);
+ assertFalse(ObjectEqualsUtils.isEqual(firstObject, VALUE));
+ }
+}