3cd8a33d7773cc895098732f2ff943f121e10758
[so.git] / so-monitoring / so-monitoring-handler / src / test / java / org / onap / so / montoring / configuration / CamundaRestUrlProviderTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.monitoring.configuration;
21
22 import static org.junit.Assert.assertEquals;
23
24 import java.util.UUID;
25
26 import org.junit.Test;
27 import org.onap.so.monitoring.configuration.camunda.CamundaRestUrlProvider;
28
29 /**
30  * @author waqas.ikram@ericsson.com
31  */
32 public class CamundaRestUrlProviderTest {
33     private static final String DEFAULT = "default";
34     private static final String CAMUNDA_REST_API_URL = "http://localhost:9080/engine-rest/engine/";
35     private static final String BASE_URL = CAMUNDA_REST_API_URL + DEFAULT;
36     private final CamundaRestUrlProvider objUnderTest = new CamundaRestUrlProvider(CAMUNDA_REST_API_URL, DEFAULT);
37     private static final String ID = UUID.randomUUID().toString();
38
39
40     @Test
41     public void test_GetHistoryProcessInstanceUrl() {
42         final String expectedUrl = BASE_URL + "/history/process-instance?variables=requestId_eq_" + ID;
43         final String actualUrl = objUnderTest.getHistoryProcessInstanceUrl(ID);
44         assertEquals(expectedUrl, actualUrl);
45     }
46
47     @Test
48     public void test_GetProcessInstanceUrl() {
49         final String expectedUrl = BASE_URL + "/history/process-instance/" + ID;
50         final String actualUrl = objUnderTest.getSingleProcessInstanceUrl(ID);
51         assertEquals(expectedUrl, actualUrl);
52     }
53
54
55     @Test
56     public void test_GetProcessDefinitionUrl() {
57         final String expectedUrl = BASE_URL + "/process-definition/" + ID + "/xml";
58         final String actualUrl = objUnderTest.getProcessDefinitionUrl(ID);
59         assertEquals(expectedUrl, actualUrl);
60
61     }
62
63     @Test
64     public void test_GetActivityIntanceUrl() {
65         final String expectedUrl =
66                 BASE_URL + "/history/activity-instance?processInstanceId=" + ID + "&sortBy=startTime&sortOrder=asc";
67         final String actualUrl = objUnderTest.getActivityInstanceUrl(ID);
68         assertEquals(expectedUrl, actualUrl);
69
70     }
71
72     @Test
73     public void test_GetProcessInstanceVariablesUrl() {
74         final String expectedUrl = BASE_URL + "/history/variable-instance?processInstanceId=" + ID;
75         final String actualUrl = objUnderTest.getProcessInstanceVariablesUrl(ID);
76         assertEquals(expectedUrl, actualUrl);
77
78     }
79
80 }