Remove raw-type related warnings in resources
[aai/resources.git] / aai-resources / src / test / java / org / onap / aai / rest / PserverWrongHeaderTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.aai.rest;
22
23 import static org.hamcrest.Matchers.containsString;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertThat;
26
27 import java.util.UUID;
28
29 import org.junit.Test;
30 import org.springframework.http.HttpEntity;
31 import org.springframework.http.HttpHeaders;
32 import org.springframework.http.HttpMethod;
33 import org.springframework.http.HttpStatus;
34 import org.springframework.http.ResponseEntity;
35
36 public class PserverWrongHeaderTest extends AbstractSpringRestTest {
37
38     @Test
39     public void testWhenNoHeadersItFailsWithBadRequestAndReturnsXml() {
40
41         HttpHeaders httpHeaders = new HttpHeaders();
42
43         httpEntity = new HttpEntity<String>(httpHeaders);
44
45         String endpoint = "/aai/v11/cloud-infrastructure/pservers/pserver/test" + UUID.randomUUID().toString();
46
47         ResponseEntity<String> responseEntity;
48         responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.GET, httpEntity, String.class);
49
50         String body = responseEntity.getBody().toString();
51
52         assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
53         assertThat(body, containsString("<Fault>"));
54         assertThat(body, containsString("Invalid X-FromAppId in header"));
55     }
56 }