2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 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=========================================================
20 package org.onap.aaisimulator.controller;
22 import org.junit.Test;
23 import org.onap.aaisimulator.models.ServiceModelVersion;
24 import org.springframework.boot.test.context.SpringBootTest;
25 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
26 import org.springframework.http.HttpStatus;
27 import org.springframework.http.MediaType;
28 import org.springframework.http.ResponseEntity;
30 import static org.junit.Assert.assertEquals;
31 import static org.junit.Assert.assertNotNull;
32 import static org.junit.Assert.assertTrue;
33 import static org.onap.aaisimulator.utils.TestConstants.SERVICE_DESIGN_AND_CREATION_URL;
35 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
36 properties = "SERVICE_DESIGN_AND_CREATION_RESPONSES_LOCATION=./src/test/resources/test-data/service-design-and-creation-responses")
37 public class ServiceDesignAndCreationControllerTest extends AbstractSpringBootTest{
40 public void should_reply_sample_modelvers_response() {
41 final String url = getUrl(SERVICE_DESIGN_AND_CREATION_URL, "/models/model/a51e2bef-961c-496f-b235-b4540400e885/model-vers");
43 ResponseEntity<?> actual = testRestTemplateService.invokeHttpGet(url, String.class);
45 String expectedXml = "{\n"
46 + " \"model-vers\": {\n"
47 + " \"model-ver\": [\n"
49 + " \"model-version-id\": \"cd4decf6-4f27-4775-9561-0e683ed43635\",\n"
50 + " \"model-name\": \"EricService\",\n"
51 + " \"model-version\": \"1.0\",\n"
52 + " \"model-description\": \"service_instance_1.0\",\n"
53 + " \"resource-version\": \"1594657102313\"\n"
56 + " \"model-version-id\": \"4442dfc1-0d2d-46b4-b0bc-a2ac10448269\",\n"
57 + " \"model-name\": \"EricService\",\n"
58 + " \"model-version\": \"2.0\",\n"
59 + " \"model-description\": \"service_instance_2.0\",\n"
60 + " \"resource-version\": \"1594707742646\"\n"
66 assertEquals(HttpStatus.OK, actual.getStatusCode());
67 MediaType contentType = actual.getHeaders().getContentType();
68 assertNotNull(contentType);
69 assertTrue(contentType.isCompatibleWith(MediaType.APPLICATION_JSON));
70 assertEquals(expectedXml, actual.getBody());