010d29a66d1817aa055dba64a5ea76ec571813f6
[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.acm.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.acm.participant.http.main.models.ConfigurationEntity;
28 import org.onap.policy.clamp.acm.participant.http.main.models.RestParams;
29 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
30 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
31 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
32
33 public class CommonTestData {
34
35     private static final String TEST_KEY_NAME =
36         "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement";
37
38     /**
39      * Get a automationComposition Element.
40      *
41      * @return automationCompositionElement object
42      */
43     public AutomationCompositionElement getAutomationCompositionElement() {
44         AutomationCompositionElement element = new AutomationCompositionElement();
45         element.setId(UUID.randomUUID());
46         element.setDefinition(new ToscaConceptIdentifier(TEST_KEY_NAME, "1.0.1"));
47         element.setOrderedState(AutomationCompositionOrderedState.PASSIVE);
48         return element;
49     }
50
51     /**
52      * Get query params.
53      *
54      * @return Map of query params
55      */
56     public Map<String, String> getQueryParams() {
57         return Map.of("name", "dummy", "version", "1.0");
58     }
59
60     /**
61      * Get path params.
62      *
63      * @return Map of path params
64      */
65     public Map<String, Object> getPathParams() {
66         return Map.of("id", "123", "name", "dummy");
67     }
68
69     /**
70      * Rest params with GET request.
71      *
72      * @return RestParams obj
73      */
74     public RestParams restParamsWithGet() {
75         return new RestParams(new ToscaConceptIdentifier("getRequest", "1.0"), "GET", "get", 200, null,
76             getQueryParams(), null);
77     }
78
79     /**
80      * Rest params with POST request.
81      *
82      * @return RestParams obj
83      */
84     public RestParams restParamsWithPost() {
85         return new RestParams(new ToscaConceptIdentifier("postRequest", "1.0"), "POST", "post", 200, null,
86             getQueryParams(), "Test body");
87     }
88
89     /**
90      * Rest params with POST request.
91      *
92      * @return RestParams obj
93      */
94     public RestParams restParamsWithInvalidPost() {
95         return new RestParams(new ToscaConceptIdentifier("postRequest", "1.0"), "POST", "post/{id}/{name}", 200,
96             getPathParams(), getQueryParams(), "Test body");
97     }
98
99     /**
100      * Get invalid configuration entity.
101      *
102      * @return ConfigurationEntity obj
103      */
104     public ConfigurationEntity getInvalidConfigurationEntity() {
105         return new ConfigurationEntity(new ToscaConceptIdentifier("config1", "1.0.1"),
106             List.of(restParamsWithGet(), restParamsWithInvalidPost()));
107     }
108
109     /**
110      * Get configuration entity.
111      *
112      * @return ConfigurationEntity obj
113      */
114     public ConfigurationEntity getConfigurationEntity() {
115         return new ConfigurationEntity(new ToscaConceptIdentifier("config1", "1.0.1"),
116             List.of(restParamsWithGet(), restParamsWithPost()));
117     }
118
119     /**
120      * Get automation composition id.
121      *
122      * @return ToscaConceptIdentifier automationCompositionId
123      */
124     public ToscaConceptIdentifier getAutomationCompositionId() {
125         return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
126     }
127
128     /**
129      * Get headers for config request.
130      *
131      * @return Map of headers
132      */
133     public Map<String, String> getHeaders() {
134         return Map.of("Content-Type", "application/json", "Accept", "application/json");
135     }
136
137 }