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
 
   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.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;
 
  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;
 
  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{
 
  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" +
 
  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" +
 
  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" +
 
  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());