View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.fit.core;
20  
21  import static org.junit.jupiter.api.Assertions.assertEquals;
22  import static org.junit.jupiter.api.Assertions.assertNotNull;
23  import static org.junit.jupiter.api.Assertions.assertTrue;
24  
25  import com.fasterxml.jackson.databind.JsonNode;
26  import java.io.IOException;
27  import java.io.InputStream;
28  import javax.ws.rs.core.MediaType;
29  import javax.ws.rs.core.Response;
30  import org.apache.cxf.jaxrs.client.WebClient;
31  import org.apache.syncope.fit.AbstractITCase;
32  import org.junit.jupiter.api.Test;
33  
34  public class OpenAPIITCase extends AbstractITCase {
35  
36      @Test
37      public void openapi() throws IOException {
38          WebClient webClient = WebClient.create(ADDRESS + "/openapi.json").accept(MediaType.APPLICATION_JSON_TYPE);
39          Response response = webClient.get();
40          assertEquals(200, response.getStatus());
41  
42          JsonNode tree = JSON_MAPPER.readTree((InputStream) response.getEntity());
43          assertNotNull(tree);
44  
45          JsonNode info = tree.get("info");
46          assertEquals("Apache Syncope", info.get("title").asText());
47  
48          JsonNode paths = tree.get("paths");
49          assertNotNull(paths);
50          assertTrue(paths.isContainerNode());
51  
52          JsonNode components = tree.get("components");
53          assertNotNull(components);
54          assertTrue(components.isContainerNode());
55      }
56  }