1f92a86e03c18f6971f53463e787852fe168d034
[policy/clamp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 Nordix Foundation.
4  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.clamp.controlloop.participant.http.utils;
23
24 import java.util.List;
25 import java.util.Map;
26 import java.util.UUID;
27 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
28 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
29 import org.onap.policy.clamp.controlloop.participant.http.main.models.ConfigurationEntity;
30 import org.onap.policy.clamp.controlloop.participant.http.main.models.RestParams;
31 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
32
33 public class CommonTestData {
34
35     private static final String TEST_KEY_NAME = "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement";
36
37
38     /**
39      * Get a controlLoop Element.
40      * @return controlLoopElement object
41      */
42     public ControlLoopElement getControlLoopElement() {
43         ControlLoopElement element = new ControlLoopElement();
44         element.setId(UUID.randomUUID());
45         element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1"));
46         element.setOrderedState(ControlLoopOrderedState.PASSIVE);
47         return element;
48     }
49
50     /**
51      * Get query params.
52      * @return Map of query params
53      */
54     public Map<String, String> getQueryParams() {
55         return Map.of("name", "dummy", "version", "1.0");
56     }
57
58     /**
59      * Get path params.
60      * @return Map of path params
61      */
62     public Map<String, Object> getPathParams() {
63         return Map.of("id", "123", "name", "dummy");
64     }
65
66     /**
67      * Rest params with GET request.
68      * @return RestParams obj
69      */
70     public RestParams restParamsWithGet() {
71         return new RestParams(
72             new ToscaConceptIdentifier("getRequest", "1.0"),
73             "GET",
74             "get",
75             200,
76             null,
77             getQueryParams(),
78             null
79         );
80     }
81
82     /**
83      * Rest params with POST request.
84      * @return RestParams obj
85      */
86     public RestParams restParamsWithPost() {
87         return new RestParams(
88             new ToscaConceptIdentifier("postRequest", "1.0"),
89             "POST",
90             "post",
91             200,
92             null,
93             getQueryParams(),
94             "Test body"
95         );
96     }
97
98     /**
99      * Rest params with POST request.
100      * @return RestParams obj
101      */
102     public RestParams restParamsWithInvalidPost() {
103         return new RestParams(
104             new ToscaConceptIdentifier("postRequest", "1.0"),
105             "POST",
106             "post/{id}/{name}",
107             200,
108             getPathParams(),
109             getQueryParams(),
110             "Test body"
111         );
112     }
113
114     /**
115      * Get invalid configuration entity.
116      * @return ConfigurationEntity obj
117      */
118     public ConfigurationEntity getInvalidConfigurationEntity() {
119         return new ConfigurationEntity(
120             new ToscaConceptIdentifier("config1", "1.0.1"),
121             List.of(restParamsWithGet(), restParamsWithInvalidPost())
122         );
123     }
124
125     /**
126      * Get configuration entity.
127      * @return ConfigurationEntity obj
128      */
129     public ConfigurationEntity getConfigurationEntity() {
130         return new ConfigurationEntity(
131             new ToscaConceptIdentifier("config1", "1.0.1"),
132             List.of(restParamsWithGet(), restParamsWithPost())
133         );
134     }
135
136     /**
137      * Get controlloop id.
138      * @return ToscaConceptIdentifier controlLoopId
139      */
140     public ToscaConceptIdentifier getControlLoopId() {
141         return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
142     }
143
144     /**
145      * Get headers for config request.
146      * @return Map of headers
147      */
148     public Map<String, String> getHeaders() {
149         return  Map.of("Content-Type", "application/json", "Accept", "application/json");
150     }
151
152 }