d0e652bdc4d4b4723af295cf5b8905b2869123b7
[integration/csit.git] / plans / usecases-pnf-sw-upgrade / pnf-sw-upgrade / sorch / simulator / aai-simulator / src / test / java / org / onap / aaisimulator / controller / ServiceDesignAndCreationControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.aaisimulator.controller;
21
22 import org.junit.Test;
23 import org.springframework.boot.test.context.SpringBootTest;
24 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
25 import org.springframework.http.HttpStatus;
26 import org.springframework.http.MediaType;
27 import org.springframework.http.ResponseEntity;
28
29 import static org.junit.Assert.assertEquals;
30 import static org.junit.Assert.assertNotNull;
31 import static org.junit.Assert.assertTrue;
32 import static org.onap.aaisimulator.utils.TestConstants.SERVICE_DESIGN_AND_CREATION_URL;
33
34 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
35         properties = "SERVICE_DESIGN_AND_CREATION_RESPONSES_LOCATION=./src/test/resources/test-data/service-design-and-creation-responses")
36 public class ServiceDesignAndCreationControllerTest extends AbstractSpringBootTest{
37
38     @Test
39     public void should_reply_sample_modelvers_response() {
40         final String url = getUrl(SERVICE_DESIGN_AND_CREATION_URL,
41                 "/models/model/a51e2bef-961c-496f-b235-b4540400e885/model-vers");
42         ResponseEntity<String> actual = testRestTemplateService.invokeHttpGet(url, String.class);
43         String expectedXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
44                 "<model-vers xmlns=\"http://org.onap.aai.inventory/v11\">\n" +
45                 "    <model-ver>\n" +
46                 "        <model-version-id>c0818142-324d-4a8c-8065-45a61df247a5</model-version-id>\n" +
47                 "        <model-name>EricService</model-name>\n" +
48                 "        <model-version>1.0</model-version>\n" +
49                 "        <model-description>blah</model-description>\n" +
50                 "        <resource-version>1594657102313</resource-version>\n" +
51                 "    </model-ver>\n" +
52                 "    <model-ver>\n" +
53                 "        <model-version-id>4442dfc1-0d2d-46b4-b0bc-a2ac10448269</model-version-id>\n" +
54                 "        <model-name>EricService</model-name>\n" +
55                 "        <model-version>2.0</model-version>\n" +
56                 "        <model-description>blahhhh</model-description>\n" +
57                 "        <resource-version>1594707742646</resource-version>\n" +
58                 "    </model-ver>\n" +
59                 "</model-vers>";
60
61         assertEquals(HttpStatus.OK, actual.getStatusCode());
62         MediaType contentType = actual.getHeaders().getContentType();
63         assertNotNull(contentType);
64         assertTrue(contentType.isCompatibleWith(MediaType.APPLICATION_XML));
65         assertEquals(expectedXml, actual.getBody());
66     }
67 }