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