2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.pap.main.rest;
24 import static org.junit.Assert.assertEquals;
26 import javax.ws.rs.client.Invocation;
27 import javax.ws.rs.core.Response;
28 import org.junit.Test;
31 * Note: this tests failure cases; success cases are tested by tests in the "e2e" package.
33 public class TestPolicyStatusControllerV1 extends CommonPapRestServer {
35 private static final String POLICY_STATUS_ENDPOINT = "policies/deployed";
38 public void testSwagger() throws Exception {
39 super.testSwagger(POLICY_STATUS_ENDPOINT);
41 super.testSwagger(POLICY_STATUS_ENDPOINT + "/{name}");
42 super.testSwagger(POLICY_STATUS_ENDPOINT + "/{name}/{version}");
46 public void testQueryAllDeployedPolicies() throws Exception {
47 String uri = POLICY_STATUS_ENDPOINT;
49 // verify it fails when no authorization info is included
50 checkUnauthRequest(uri, req -> req.get());
54 public void testQueryDeployedPolicies() throws Exception {
55 String uri = POLICY_STATUS_ENDPOINT + "/my-name";
57 Invocation.Builder invocationBuilder = sendRequest(uri);
58 Response rawresp = invocationBuilder.get();
59 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawresp.getStatus());
61 // verify it fails when no authorization info is included
62 checkUnauthRequest(uri, req -> req.get());
66 public void testQueryDeployedPolicy() throws Exception {
67 String uri = POLICY_STATUS_ENDPOINT + "/my-name/1.2.3";
69 Invocation.Builder invocationBuilder = sendRequest(uri);
70 Response rawresp = invocationBuilder.get();
71 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawresp.getStatus());
73 // verify it fails when no authorization info is included
74 checkUnauthRequest(uri, req -> req.get());