2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2022-2023 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.concepts.AutomationCompositionDefinition;
28 import org.onap.policy.clamp.models.acm.messages.rest.commissioning.AcTypeStateUpdate;
29 import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse;
30 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
31 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates;
32 import org.springframework.beans.factory.annotation.Value;
33 import org.springframework.context.annotation.Profile;
34 import org.springframework.http.ResponseEntity;
35 import org.springframework.web.bind.annotation.RestController;
39 @RequiredArgsConstructor
40 public class CommissioningControllerStub extends AbstractRestController implements AutomationCompositionDefinitionApi {
42 private final StubUtils stubUtils;
44 @Value("${stub.deleteCompositionDefinitionResponse}")
45 private String pathToResponseFile;
47 @Value("${stub.getAllCompositionDefinitions}")
48 private String pathToAllDefinitions;
50 @Value("${stub.getSingleCompositionDefinition}")
51 private String pathToSingleDefinition;
53 @Value("${stub.postCommissionResponse}")
54 private String pathToPostResponse;
56 @Value("${stub.putCompositionDefinitionUpdateResponse}")
57 private String pathToPutUpdate;
60 public ResponseEntity<CommissioningResponse> createCompositionDefinitions(ToscaServiceTemplate body,
61 UUID xonaprequestid) {
62 var compositionId = body.getMetadata() != null ? body.getMetadata().get("compositionId") : null;
63 if (compositionId == null) {
64 return stubUtils.getResponse(pathToPostResponse, CommissioningResponse.class);
66 return stubUtils.getResponse(pathToPutUpdate, CommissioningResponse.class);
71 public ResponseEntity<CommissioningResponse> deleteCompositionDefinition(UUID compositionId, UUID xonaprequestid) {
72 return stubUtils.getResponse(pathToResponseFile, CommissioningResponse.class);
76 public ResponseEntity<AutomationCompositionDefinition> getCompositionDefinition(UUID compositionId,
77 UUID xonaprequestid) {
78 return stubUtils.getResponse(pathToSingleDefinition, AutomationCompositionDefinition.class);
82 public ResponseEntity<ToscaServiceTemplates> queryCompositionDefinitions(String name, String version,
83 UUID xonaprequestid) {
84 return stubUtils.getResponse(pathToAllDefinitions, ToscaServiceTemplates.class);
88 public ResponseEntity<Void> compositionDefinitionPriming(UUID compositionId, UUID requestId,
89 AcTypeStateUpdate body) {
90 // TODO Auto-generated method stub