Skip to content

Commit

Permalink
#30 - removed assert from test validateFeatureCollectionsMetadataOper…
Browse files Browse the repository at this point in the history
…ationResponse_Collections as it collects the collections
  • Loading branch information
lgoltz committed Aug 13, 2018
1 parent b2ef930 commit 99f1565
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public class FeatureCollectionsMetadataOperation extends CommonFixture {

private final Map<TestPoint, List<Map<String, Object>>> testPointAndCollections = new HashMap<>();

private final List<String> collectionNamesFromLandingPage = new ArrayList<>();

private OpenApi3 apiModel;

private Object[][] testPointsData;
Expand Down Expand Up @@ -75,19 +73,6 @@ public Object[][] collections( ITestContext testContext ) {
return objects;
}

@BeforeClass
public void parseRequiredMetadata( ITestContext testContext ) {
Response request = init().baseUri( rootUri.toString() ).accept( JSON ).when().request( GET, "/" );
JsonPath jsonPath = request.jsonPath();

List<Object> collections = jsonPath.getList( "collections" );
for ( Object collectionObject : collections ) {
Map<String, Object> collection = (Map<String, Object>) collectionObject;
String collectionName = (String) collection.get( "name" );
this.collectionNamesFromLandingPage.add( collectionName );
}
}

@BeforeClass
public void openApiDocument( ITestContext testContext ) {
this.apiModel = (OpenApi3) testContext.getSuite().getAttribute( API_MODEL.getName() );
Expand Down Expand Up @@ -201,10 +186,8 @@ public void validateFeatureCollectionsMetadataOperationResponse_Collections( Tes
JsonPath jsonPath = response.jsonPath();
List<Object> collections = jsonPath.getList( "collections" );

List<String> missingCollectionNames = findMissingCollectionNames( collections );
assertTrue( missingCollectionNames.isEmpty(),
"Feature Collection Metadata document must include a collections property for each collection in the dataset. Missing collection properties "
+ missingCollectionNames );
// Test method cannot be verified as the provided collections are not known.

this.testPointAndCollections.put( testPoint, createCollectionsMap( collections ) );
}

Expand Down Expand Up @@ -356,26 +339,6 @@ private void validateFeatureCollectionMetadataOperationResponse( Response respon
assertEquals( collection, jsonPath.get() );
}

private List<String> findMissingCollectionNames( List<Object> collections ) {
List<String> missingCollectionNames = new ArrayList<>();
for ( String collectionNameFromLandingPage : this.collectionNamesFromLandingPage ) {
Map<String, Object> collection = findCollectionByName( collectionNameFromLandingPage, collections );
if ( collection == null )
missingCollectionNames.add( collectionNameFromLandingPage );
}
return missingCollectionNames;
}

private Map<String, Object> findCollectionByName( String collectionNameFromLandingPage, List<Object> collections ) {
for ( Object collectionObject : collections ) {
Map<String, Object> collection = (Map<String, Object>) collectionObject;
Object collectionName = collection.get( "name" );
if ( collectionNameFromLandingPage.equals( collectionName ) )
return collection;
}
return null;
}

private List<Map<String, Object>> createCollectionsMap( List<Object> collections ) {
List<Map<String, Object>> collectionsMap = new ArrayList<>();
for ( Object collection : collections )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public static void initTestFixture()
public void testValidateFeatureCollectionsMetadataOperationResponse() {
FeatureCollectionsMetadataOperation featureCollectionsMetadataOperation = new FeatureCollectionsMetadataOperation();
featureCollectionsMetadataOperation.initCommonFixture( testContext );
featureCollectionsMetadataOperation.parseRequiredMetadata( testContext );
featureCollectionsMetadataOperation.openApiDocument( testContext );
UriTemplate conformanceUri = new UriTemplate( "https://www.ldproxy.nrw.de/kataster/collections" );
TestPoint testPoint = new TestPoint( conformanceUri, mediaTypes() );
Expand Down

0 comments on commit 99f1565

Please sign in to comment.