Skip to content

Commit

Permalink
#8 - configured group "collections", store collections in test context
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoltz committed Jun 28, 2018
1 parent 353ba77 commit e173093
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
11 changes: 10 additions & 1 deletion src/main/java/org/opengis/cite/wfs30/SuiteAttribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.net.URI;
import java.util.List;

import com.reprezen.kaizen.oasparser.model3.OpenApi3;
import com.sun.jersey.api.client.Client;
Expand All @@ -27,7 +28,15 @@ public enum SuiteAttribute {
*/
TEST_SUBJ_FILE( "testSubjectFile", File.class ),

API_MODEL( "apiModel", OpenApi3.class );
/**
* Parsed OpenApi3 document resource /api; Added during execution.
*/
API_MODEL( "apiModel", OpenApi3.class ),

/**
* Parsed collections from resource /collections; Added during execution.
*/
COLLECTIONS( "collections", List.class );

private final Class attrType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
import java.util.Map;

import org.opengis.cite.wfs30.CommonFixture;
import org.opengis.cite.wfs30.SuiteAttribute;
import org.opengis.cite.wfs30.openapi3.OpenApiUtils;
import org.opengis.cite.wfs30.openapi3.TestPoint;
import org.testng.ITestContext;
import org.testng.SkipException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -86,6 +88,15 @@ public void openApiDocument( ITestContext testContext ) {
this.apiModel = (OpenApi3) testContext.getSuite().getAttribute( API_MODEL.getName() );
}

@AfterClass
public void storeCollectionsInTestContext( ITestContext testContext ) {
List<Map<String, Object>> collections = new ArrayList<>();
for ( List<Map<String, Object>> testPointAndCollection : testPointAndCollections.values() ) {
collections.addAll( testPointAndCollection );
}
testContext.getSuite().setAttribute( SuiteAttribute.COLLECTIONS.getName(), collections );
}

/**
* A.4.4.4. Validate the Feature Collections Metadata Operation
*
Expand All @@ -104,7 +115,7 @@ public void openApiDocument( ITestContext testContext ) {
* @param testPoint
* the test point to test, never <code>null</code>
*/
@Test(description = "Implements A.4.4.4. Validate the Feature Collections Metadata Operation (Requirement 9, 10)", dataProvider = "collectionsUris", dependsOnGroups = "apidefinition")
@Test(description = "Implements A.4.4.4. Validate the Feature Collections Metadata Operation (Requirement 9, 10)", groups = "collections", dataProvider = "collectionsUris", dependsOnGroups = "apidefinition")
public void validateFeatureCollectionsMetadataOperation(TestPoint testPoint ) {
String testPointUri = testPoint.createUri();
Response response = init().baseUri( testPointUri ).accept( JSON ).when().request( GET );
Expand All @@ -131,7 +142,7 @@ public void validateFeatureCollectionsMetadataOperation(TestPoint testPoint ) {
* @param testPoint
* the test point to test, never <code>null</code>
*/
@Test(description = "Implements A.4.4.5. Validate the Feature Collections Metadata Operation Response (Requirement 11)", dataProvider = "collectionsUris", dependsOnMethods = "validateFeatureCollectionsMetadataOperation")
@Test(description = "Implements A.4.4.5. Validate the Feature Collections Metadata Operation Response (Requirement 11)", groups = "collections", dataProvider = "collectionsUris", dependsOnMethods = "validateFeatureCollectionsMetadataOperation")
public void validateFeatureCollectionsMetadataOperationResponse_Links( TestPoint testPoint ) {
Response response = testPointAndResponses.get( testPoint );
if ( response == null )
Expand Down Expand Up @@ -177,7 +188,7 @@ public void validateFeatureCollectionsMetadataOperationResponse_Links( TestPoint
* @param testPoint
* the test point to test, never <code>null</code>
*/
@Test(description = "Implements A.4.4.5. Validate the Feature Collections Metadata Operation Response (Requirement 12)", dataProvider = "collectionsUris", dependsOnMethods = "validateFeatureCollectionsMetadataOperation")
@Test(description = "Implements A.4.4.5. Validate the Feature Collections Metadata Operation Response (Requirement 12)", groups = "collections", dataProvider = "collectionsUris", dependsOnMethods = "validateFeatureCollectionsMetadataOperation")
public void validateFeatureCollectionsMetadataOperationResponse_Collections( TestPoint testPoint ) {
Response response = testPointAndResponses.get( testPoint );
if ( response == null )
Expand Down Expand Up @@ -215,7 +226,7 @@ public void validateFeatureCollectionsMetadataOperationResponse_Collections( Tes
* @param collection
* the collection to test, never <code>null</code>
*/
@Test(description = "Implements A.4.4.6. Validate a Collections Metadata document (Requirement 13)", dataProvider = "collections", dependsOnMethods = "validateFeatureCollectionsMetadataOperationResponse_Collections")
@Test(description = "Implements A.4.4.6. Validate a Collections Metadata document (Requirement 13)", groups = "collections", dataProvider = "collections", dependsOnMethods = "validateFeatureCollectionsMetadataOperationResponse_Collections")
public void validateCollectionsMetadataDocument_Links(TestPoint testPoint, Map<String, Object> collection ) {
String collectionName = (String) collection.get( "name" );
List<TestPoint> testPointsForNamedCollection = OpenApiUtils.retrieveTestPoints( apiModel, COLLECTIONS,
Expand Down Expand Up @@ -257,7 +268,7 @@ public void validateCollectionsMetadataDocument_Links(TestPoint testPoint, Map<S
* @param collection
* the collection to test, never <code>null</code>
*/
@Test(description = "Implements A.4.4.6. Validate a Collections Metadata document (Requirement 14)", dataProvider = "collections", dependsOnMethods = "validateFeatureCollectionsMetadataOperationResponse_Collections")
@Test(description = "Implements A.4.4.6. Validate a Collections Metadata document (Requirement 14)", groups = "collections", dataProvider = "collections", dependsOnMethods = "validateFeatureCollectionsMetadataOperationResponse_Collections")
public void validateCollectionsMetadataDocument_Extent(TestPoint testPoint, Map<String, Object> collection ) {
// TODO: validate the extent property
}
Expand All @@ -271,7 +282,7 @@ public void validateCollectionsMetadataDocument_Extent(TestPoint testPoint, Map<
* @param collection
* the collection to test, never <code>null</code>
*/
@Test(description = "Implements A.4.4.7. Validate the Feature Collection Metadata Operation (Requirement 15) and A.4.4.8. Validate the Feature Collection Metadata Operation Response (Requirement 16)", dataProvider = "collections", dependsOnMethods = "validateFeatureCollectionsMetadataOperationResponse_Collections")
@Test(description = "Implements A.4.4.7. Validate the Feature Collection Metadata Operation (Requirement 15) and A.4.4.8. Validate the Feature Collection Metadata Operation Response (Requirement 16)", groups = "collections", dataProvider = "collections", dependsOnMethods = "validateFeatureCollectionsMetadataOperationResponse_Collections")
public void validateTheFeatureCollectionMetadataOperationAndResponse(TestPoint testPoint, Map<String, Object> collection ) {
String collectionName = (String) collection.get( "name" );
List<TestPoint> testPointsForNamedCollection = OpenApiUtils.retrieveTestPoints( apiModel, COLLECTIONS,
Expand Down

0 comments on commit e173093

Please sign in to comment.