2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2022 Nordix Foundation.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.clamp.acm.runtime.main.rest.stub;
23 import java.util.UUID;
24 import lombok.RequiredArgsConstructor;
25 import org.onap.policy.clamp.acm.runtime.main.rest.gen.AutomationCompositionDefinitionApi;
26 import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController;
27 import org.onap.policy.clamp.models.acm.messages.rest.commissioning.AcTypeStateUpdate;
28 import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse;
29 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
30 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates;
31 import org.springframework.beans.factory.annotation.Value;
32 import org.springframework.context.annotation.Profile;
33 import org.springframework.http.ResponseEntity;
34 import org.springframework.web.bind.annotation.RestController;
38 @RequiredArgsConstructor
39 public class CommissioningControllerStub extends AbstractRestController implements AutomationCompositionDefinitionApi {
41 private final StubUtils stubUtils;
43 @Value("${stub.deleteCompositionDefinitionResponse}")
44 private String pathToResponseFile;
46 @Value("${stub.getAllCompositionDefinitions}")
47 private String pathToAllDefinitions;
49 @Value("${stub.getSingleCompositionDefinition}")
50 private String pathToSingleDefinition;
52 @Value("${stub.postCommissionResponse}")
53 private String pathToPostResponse;
55 @Value("${stub.putCompositionDefinitionUpdateResponse}")
56 private String pathToPutUpdate;
59 public ResponseEntity<CommissioningResponse> createCompositionDefinitions(ToscaServiceTemplate body,
60 UUID xonaprequestid) {
61 var compositionId = body.getMetadata() != null ? body.getMetadata().get("compositionId") : null;
62 if (compositionId == null) {
63 return stubUtils.getResponse(pathToPostResponse, CommissioningResponse.class);
65 return stubUtils.getResponse(pathToPutUpdate, CommissioningResponse.class);
70 public ResponseEntity<CommissioningResponse> deleteCompositionDefinition(UUID compositionId, UUID xonaprequestid) {
71 return stubUtils.getResponse(pathToResponseFile, CommissioningResponse.class);
75 public ResponseEntity<ToscaServiceTemplate> getCompositionDefinition(UUID compositionId, UUID xonaprequestid) {
76 return stubUtils.getResponse(pathToSingleDefinition, ToscaServiceTemplate.class);
80 public ResponseEntity<ToscaServiceTemplates> queryCompositionDefinitions(String name, String version,
81 UUID xonaprequestid) {
82 return stubUtils.getResponse(pathToAllDefinitions, ToscaServiceTemplates.class);
86 public ResponseEntity<Void> compositionDefinitionPriming(UUID compositionId, UUID requestId,
87 AcTypeStateUpdate body) {
88 // TODO Auto-generated method stub