2 * ============LICENSE_START=======================================================
3 * Copyright (C) 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.contract;
23 import static org.assertj.core.api.Assertions.assertThat;
25 import jakarta.ws.rs.client.Entity;
26 import jakarta.ws.rs.core.MediaType;
27 import jakarta.ws.rs.core.Response;
28 import org.junit.jupiter.api.BeforeEach;
29 import org.junit.jupiter.api.Test;
30 import org.junit.jupiter.api.extension.ExtendWith;
31 import org.onap.policy.clamp.acm.runtime.util.rest.CommonRestController;
32 import org.springframework.boot.test.context.SpringBootTest;
33 import org.springframework.boot.test.web.server.LocalServerPort;
34 import org.springframework.test.context.ActiveProfiles;
35 import org.springframework.test.context.junit.jupiter.SpringExtension;
37 @ExtendWith(SpringExtension.class)
38 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
39 @ActiveProfiles({ "test", "stub" })
40 class ParticipantControllerStubTest extends CommonRestController {
41 private static final String PARTICIPANT_ENDPOINT = "participants";
42 private static final String PARTICIPANT_ID = "101c62b3-8918-41b9-a747-d21eb79c6c03";
45 private int randomServerPort;
48 public void setUpPort() {
49 super.setHttpPrefix(randomServerPort);
54 var invocationBuilder = super.sendRequest(PARTICIPANT_ENDPOINT + "/" + PARTICIPANT_ID);
55 var respPost = invocationBuilder.get();
56 assertThat(Response.Status.OK.getStatusCode()).isEqualTo(respPost.getStatus());
61 var invocationBuilder = super.sendRequest(PARTICIPANT_ENDPOINT);
62 var respPost = invocationBuilder.get();
63 assertThat(Response.Status.OK.getStatusCode()).isEqualTo(respPost.getStatus());
67 void testOrderReport() {
68 var invocationBuilder = super.sendRequest(PARTICIPANT_ENDPOINT + "/" + PARTICIPANT_ID);
70 var respPost = invocationBuilder.header("Content-Length", 0).put(Entity.entity(""
71 + "", MediaType.APPLICATION_JSON));
72 assertThat(Response.Status.ACCEPTED.getStatusCode()).isEqualTo(respPost.getStatus());
76 void testOrderAllReport() {
77 var invocationBuilder = super.sendRequest(PARTICIPANT_ENDPOINT);
79 var respPost = invocationBuilder.header("Content-Length", 0).put(Entity.entity(""
80 + "", MediaType.APPLICATION_JSON));
81 assertThat(Response.Status.ACCEPTED.getStatusCode()).isEqualTo(respPost.getStatus());