-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for API version segment in path
- Loading branch information
Showing
4 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...i-features/src/test/java/org/deegree/services/oaf/resource/OpenApiVersionSegmentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/*- | ||
* #%L | ||
* deegree-ogcapi-features - OGC API Features (OAF) implementation - Querying and modifying of geospatial data objects | ||
* %% | ||
* Copyright (C) 2019 - 2020 lat/lon GmbH, [email protected], www.lat-lon.de | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 2.1 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
* #L% | ||
*/ | ||
package org.deegree.services.oaf.resource; | ||
|
||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath; | ||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.isJson; | ||
import static org.hamcrest.CoreMatchers.endsWith; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
import org.deegree.services.oaf.OgcApiFeaturesMediaType; | ||
import org.deegree.services.oaf.filter.ApiVersionPathFilter; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.contrib.java.lang.system.ProvideSystemProperty; | ||
|
||
/** | ||
* Test OpenAPI resource with optional version segment enabled for path. | ||
*/ | ||
public class OpenApiVersionSegmentTest extends OpenApiTest { | ||
|
||
@Rule | ||
public final ProvideSystemProperty providesSystemPropertyRule = new ProvideSystemProperty(ApiVersionPathFilter.PARAMETER_ENABLE_VERSION_SEGMENT, "true"); | ||
|
||
/** | ||
* Test if API definition is also available on path with version segment. | ||
*/ | ||
@Test | ||
public void test_OpenApiDeclarationShouldBeAvailableWithVersionSegment() { | ||
int status = target("/datasets/oaf/v1/api").request( | ||
OgcApiFeaturesMediaType.APPLICATION_OPENAPI).get().getStatus(); | ||
assertThat(status, is(200)); | ||
} | ||
|
||
/** | ||
* Test that version segment is contained in server URL. | ||
*/ | ||
@Test | ||
public void test_OpenApi_serverUrl() { | ||
String json = target("/datasets/oaf/api").request(OgcApiFeaturesMediaType.APPLICATION_OPENAPI).get( | ||
String.class); | ||
|
||
assertThat(json, isJson()); | ||
assertThat(json, hasJsonPath("$.servers[0].url", endsWith("/v1"))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters