org.opengis.cite.ogcapitiles10.CommonDataFixture Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ets-ogcapi-tiles10 Show documentation
Show all versions of ets-ogcapi-tiles10 Show documentation
Describe purpose of test suite.
package org.opengis.cite.ogcapitiles10;
import static org.opengis.cite.ogcapitiles10.SuiteAttribute.API_MODEL;
import static org.opengis.cite.ogcapitiles10.SuiteAttribute.NO_OF_COLLECTIONS;
import static org.opengis.cite.ogcapitiles10.SuiteAttribute.REQUIREMENTCLASSES;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.reprezen.kaizen.oasparser.model3.OpenApi3;
import org.opengis.cite.ogcapitiles10.conformance.RequirementClass;
import org.testng.ITestContext;
import org.testng.SkipException;
import org.testng.annotations.BeforeClass;
/**
* @author Lyn Goltz
*/
public class CommonDataFixture extends CommonFixture {
private static final int DEFAULT_NUMBER_OF_COLLECTIONS = 3;
private OpenApi3 apiModel;
private List requirementClasses;
protected int noOfCollections = DEFAULT_NUMBER_OF_COLLECTIONS;
@BeforeClass
public void requirementClasses(ITestContext testContext) {
this.requirementClasses = (List) testContext.getSuite()
.getAttribute(REQUIREMENTCLASSES.getName());
}
@BeforeClass
public void noOfCollections(ITestContext testContext) {
Object noOfCollections = testContext.getSuite().getAttribute(NO_OF_COLLECTIONS.getName());
if (noOfCollections != null) {
this.noOfCollections = (Integer) noOfCollections;
}
}
@BeforeClass
public void retrieveApiModel(ITestContext testContext) {
this.apiModel = (OpenApi3) testContext.getSuite().getAttribute(API_MODEL.getName());
}
public OpenApi3 getApiModel() {
if (apiModel == null)
throw new SkipException("ApiModel is not available.");
return apiModel;
}
protected List createListOfMediaTypesToSupportForOtherResources(Map linkToSelf) {
if (this.requirementClasses == null)
throw new SkipException("No requirement classes described in resource /conformance available");
List mediaTypesToSupport = new ArrayList<>();
for (RequirementClass requirementClass : this.requirementClasses)
if (requirementClass.hasMediaTypeForOtherResources())
mediaTypesToSupport.add(requirementClass.getMediaTypeOtherResources());
if (linkToSelf != null)
mediaTypesToSupport.remove(linkToSelf.get("type"));
return mediaTypesToSupport;
}
protected List createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures() {
if (this.requirementClasses == null)
throw new SkipException("No requirement classes described in resource /conformance available");
List mediaTypesToSupport = new ArrayList<>();
for (RequirementClass requirementClass : this.requirementClasses)
if (requirementClass.hasMediaTypeForFeaturesAndCollections())
mediaTypesToSupport.add(requirementClass.getMediaTypeFeaturesAndCollections());
return mediaTypesToSupport;
}
protected List createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures(
Map linkToSelf) {
List mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures();
if (linkToSelf != null)
mediaTypesToSupport.remove(linkToSelf.get("type"));
return mediaTypesToSupport;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy