org.opengis.cite.ogcapifeatures10.conformance.CommonDataFixture Maven / Gradle / Ivy
package org.opengis.cite.ogcapifeatures10.conformance;
import static org.opengis.cite.ogcapifeatures10.conformance.SuiteAttribute.API_MODEL;
import static org.opengis.cite.ogcapifeatures10.conformance.SuiteAttribute.NO_OF_COLLECTIONS;
import static org.opengis.cite.ogcapifeatures10.conformance.SuiteAttribute.REQUIREMENTCLASSES;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.reprezen.kaizen.oasparser.model3.OpenApi3;
import org.testng.ITestContext;
import org.testng.SkipException;
import org.testng.annotations.BeforeClass;
/**
*
* CommonDataFixture class.
*
*
* @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;
/**
*
* requirementClasses.
*
* @param testContext a {@link org.testng.ITestContext} object
*/
@BeforeClass
public void requirementClasses(ITestContext testContext) {
this.requirementClasses = (List) testContext.getSuite()
.getAttribute(REQUIREMENTCLASSES.getName());
}
/**
*
* noOfCollections.
*
* @param testContext a {@link org.testng.ITestContext} object
*/
@BeforeClass
public void noOfCollections(ITestContext testContext) {
Object noOfCollections = testContext.getSuite().getAttribute(NO_OF_COLLECTIONS.getName());
if (noOfCollections != null) {
this.noOfCollections = (Integer) noOfCollections;
}
}
/**
*
* retrieveApiModel.
*
* @param testContext a {@link org.testng.ITestContext} object
*/
@BeforeClass
public void retrieveApiModel(ITestContext testContext) {
this.apiModel = (OpenApi3) testContext.getSuite().getAttribute(API_MODEL.getName());
}
/**
*
* Getter for the field apiModel
.
*
* @return a {@link com.reprezen.kaizen.oasparser.model3.OpenApi3} object
*/
public OpenApi3 getApiModel() {
if (apiModel == null)
throw new SkipException("ApiModel is not available.");
return apiModel;
}
/**
*
* createListOfMediaTypesToSupportForOtherResources.
*
* @param linkToSelf a {@link java.util.Map} object
* @return a {@link java.util.List} object
*/
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;
}
/**
*
* createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures.
*
* @return a {@link java.util.List} object
*/
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;
}
/**
*
* createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures.
*
* @param linkToSelf a {@link java.util.Map} object
* @return a {@link java.util.List} object
*/
protected List createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures(
Map linkToSelf) {
List mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures();
if (linkToSelf != null)
mediaTypesToSupport.remove(linkToSelf.get("type"));
return mediaTypesToSupport;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy