Search in sources :

Example 6 with Parameter

use of com.reprezen.kaizen.oasparser.model3.Parameter in project ets-ogcapi-features10 by opengeospatial.

the class FeaturesBBox method boundingBoxParameterDefinition.

/**
 * <pre>
 * Abstract Test 14: /ats/core/fc-bbox-definition
 * Test Purpose: Validate that the bounding box query parameters are constructed correctly.
 * Requirement: /req/core/fc-bbox-definition
 *
 * Test Method: Verify that the bbox query parameter complies with the following definition (using an OpenAPI Specification 3.0 fragment):
 *
 * name: bbox
 * in: query
 * required: false
 * schema:
 *   type: array
 *   minItems: 4
 *   maxItems: 6
 *   items:
 *     type: number
 * style: form
 * explode: false
 *
 * Use a bounding box with four numbers in all requests:
 *  * Lower left corner, WGS 84 longitude
 *  * Lower left corner, WGS 84 latitude
 *  * Upper right corner, WGS 84 longitude
 *  * Upper right corner, WGS 84 latitude
 * </pre>
 *
 * @param testPoint
 *            the testPoint under test, never <code>null</code>
 */
@Test(description = "A.2.7. Features {root}/collections/{collectionId}/items - BoundingBox, Abstract Test 14: (Requirement /req/core/fc-bbox-definition)", dataProvider = "collectionPaths", dependsOnGroups = "featuresBase", alwaysRun = true)
public void boundingBoxParameterDefinition(TestPoint testPoint) {
    Parameter bbox = retrieveParameterByName(testPoint.getPath(), getApiModel(), "bbox");
    assertNotNull(bbox, "Required bbox parameter for collections path '" + testPoint.getPath() + "'  in OpenAPI document is missing");
    String msg = "Expected property '%s' with value '%s' for collections path '" + testPoint.getPath() + "' but was '%s'.";
    assertEquals(bbox.getName(), "bbox", String.format(msg, "name", "bbox", bbox.getName()));
    assertEquals(bbox.getIn(), "query", String.format(msg, "in", "query", bbox.getIn()));
    assertFalse(isRequired(bbox), String.format(msg, "required", "false", bbox.getRequired()));
    assertEquals(bbox.getStyle(), "form", String.format(msg, "style", "form", bbox.getStyle()));
    assertFalse(isExplode(bbox), String.format(msg, "explode", "false", bbox.getExplode()));
    Schema schema = bbox.getSchema();
    assertNotNull(schema, "Expected schema for bbox parameter for collections path '" + testPoint.getPath());
    assertEquals(schema.getType(), "array", String.format(msg, "schema -> type", "array", schema.getType()));
    assertNotNull(schema.getMinItems(), String.format(msg, "schema -> minItems", "null", schema.getMinItems()));
    assertEquals(schema.getMinItems().intValue(), 4, String.format(msg, "schema -> minItems", "4", schema.getMinItems()));
    assertNotNull(schema.getMaxItems(), String.format(msg, "schema -> maxItems", "null", schema.getMaxItems()));
    assertEquals(schema.getMaxItems().intValue(), 6, String.format(msg, "schema -> maxItems", "6", schema.getMaxItems()));
    String itemsType = schema.getItemsSchema().getType();
    assertEquals(itemsType, "number", String.format(msg, "schema -> items -> type", "number", itemsType));
}
Also used : Schema(com.reprezen.kaizen.oasparser.model3.Schema) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Test(org.testng.annotations.Test)

Example 7 with Parameter

use of com.reprezen.kaizen.oasparser.model3.Parameter in project ets-ogcapi-features10 by opengeospatial.

the class FeaturesLimit method limitParameterDefinition.

/**
 * <pre>
 * Abstract Test 16: /ats/core/fc-limit-definition
 * Test Purpose: Validate that the bounding box query parameters are constructed corrrectly.
 * Requirement: /req/core/fc-limit-definition
 *
 * Test Method: Verify that the limit query parameter complies with the following definition (using an OpenAPI Specification 3.0 fragment):
 *
 * name: limit
 * in: query
 * required: false
 * schema:
 *   type: integer
 * style: form
 * explode: false
 *
 * Note that the API can define values for "minimum", "maximum" and "default".
 * </pre>
 *
 * @param testPoint
 *            the testPoint under test, never <code>null</code>
 */
@Test(description = "A.2.7. Features {root}/collections/{collectionId}/items - Limit, Abstract Test 16: (Requirement /req/core/fc-limit-definition)", dataProvider = "collectionPaths", dependsOnGroups = "featuresBase", alwaysRun = true)
public void limitParameterDefinition(TestPoint testPoint) {
    Parameter limit = retrieveParameterByName(testPoint.getPath(), getApiModel(), "limit");
    assertNotNull(limit, "Required limit parameter for collections path '" + testPoint.getPath() + "'  in OpenAPI document is missing");
    String msg = "Expected property '%s' with value '%s' but was '%s'";
    assertEquals(limit.getName(), "limit", String.format(msg, "name", "limit", limit.getName()));
    assertEquals(limit.getIn(), "query", String.format(msg, "in", "query", limit.getIn()));
    assertFalse(isRequired(limit), String.format(msg, "required", "false", limit.getRequired()));
    assertEquals(limit.getStyle(), "form", String.format(msg, "style", "form", limit.getStyle()));
    assertFalse(isExplode(limit), String.format(msg, "explode", "false", limit.getExplode()));
    Schema schema = limit.getSchema();
    assertEquals(schema.getType(), "integer", String.format(msg, "schema -> type", "integer", schema.getType()));
    assertIntegerGreaterZero(schema.getMinimum(), "schema -> minimum");
    assertIntegerGreaterZero(schema.getDefault(), "schema -> default");
}
Also used : Schema(com.reprezen.kaizen.oasparser.model3.Schema) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Test(org.testng.annotations.Test)

Example 8 with Parameter

use of com.reprezen.kaizen.oasparser.model3.Parameter in project osate2 by osate.

the class AadlBaTypeChecker method subprogramParameterListCheck.

// This method checks the given parameter labels and matches them against the
// subprogram parameters. It resolves target/value expression semantic
// ambiguities. On error, reports error and returns false.
// Event if the subprogram call action doesn't have any parameter labels,
// the subprogram type may have and vice versa : subprogramParameterListCheck
// / is also design for these cases.
/**
 * Document: AADL Behavior Annex draft
 * Version : 0.94
 * Type : Legality rule
 * Section : D.6 Behavior Action Language
 * Object : Check legality rule D.6.(L5)
 * Keys : parameter list match signature subprogram call
 */
private boolean subprogramParameterListCheck(CommAction comAct, EList<ParameterLabel> callParams, Classifier subprogType) {
    // Fetches sorted subprogram feature list.
    List<Feature> tmp = Aadl2Utils.orderFeatures(subprogType);
    List<Feature> subprogFeat = new ArrayList<Feature>(tmp.size());
    for (Feature feat : tmp) {
        if (feat instanceof DataAccess || feat instanceof Parameter) {
            subprogFeat.add(feat);
        }
    }
    // Preliminary checking : on error, reports error and exit early.
    if (callParams.size() != subprogFeat.size()) {
        String subprogramName = null;
        if (comAct.getReference() != null) {
            subprogramName = unparseReference(comAct.getReference());
        } else {
            subprogramName = unparseQualifiedNamedElement(comAct.getQualifiedName());
        }
        reportError(comAct, "Invalid number of argument(s) for the subprogram " + subprogramName);
        return false;
    }
    boolean isconsistent = true;
    boolean hasCheckingPassed = true;
    Enum<?> currentDirRight;
    ValueExpression valueExp;
    ListIterator<ParameterLabel> it = callParams.listIterator();
    Value v;
    Target tar;
    TypeHolder t1, t2;
    ValueAndTypeHolder vth;
    List<TypeHolder> typesFound = new ArrayList<TypeHolder>(callParams.size());
    List<Enum<?>> dirRightsFound = new ArrayList<Enum<?>>(callParams.size());
    List<TypeHolder> expectedTypes = new ArrayList<TypeHolder>(subprogFeat.size());
    List<Enum<?>> expectedDirRight = new ArrayList<Enum<?>>(subprogFeat.size());
    // driven by the subprogram signature.
    for (Feature feat : subprogFeat) {
        if (feat instanceof Parameter) {
            Parameter param = (Parameter) feat;
            currentDirRight = param.getDirection();
            expectedDirRight.add(currentDirRight);
        } else // DataAccess case.
        {
            DataAccess data = (DataAccess) feat;
            currentDirRight = Aadl2Utils.getDataAccessRight(data);
            expectedDirRight.add(currentDirRight);
        }
        valueExp = (ValueExpression) it.next();
        Classifier klass = AadlBaUtils.getClassifier(feat, _baParentContainer);
        // ValueExpression case.
        if (currentDirRight == DirectionType.IN || currentDirRight == Aadl2Utils.DataAccessRight.read_only) {
            vth = valueExpressionCheck(valueExp);
            if (vth != null) {
                try {
                    t1 = AadlBaUtils.getTypeHolder(klass);
                } catch (DimensionException de) {
                    reportDimensionException(de);
                    return false;
                }
                t2 = vth.typeHolder;
                expectedTypes.add(t1);
                typesFound.add(t2);
                dirRightsFound.add(DirectionType.IN);
                if (!_dataChecker.conformsTo(t1, t2, true)) {
                    isconsistent = false;
                }
            } else // Value expression checking error case.
            {
                // Error reporting has already been done.
                hasCheckingPassed = false;
            }
        } else if (currentDirRight != Aadl2Utils.DataAccessRight.unknown) {
            v = AadlBaUtils.isOnlyOneValue(valueExp);
            boolean isOnlyOneReference = false;
            if (v instanceof Reference) {
                Reference r = (Reference) v;
                if (r.getIds().size() == 1) {
                    isOnlyOneReference = true;
                }
            }
            if (// Target but not reference case.
            v instanceof Target && isOnlyOneReference) {
                TypeCheckRule stopOnThisRule = TypeCheckRule.DATA_ACCESS;
                tar = targetCheck((Target) v, stopOnThisRule);
                if (tar != null) {
                    try {
                        t1 = AadlBaUtils.getTypeHolder(klass);
                        t2 = AadlBaUtils.getTypeHolder(tar, _baParentContainer);
                    } catch (DimensionException de) {
                        reportDimensionException(de);
                        return false;
                    }
                    expectedTypes.add(t1);
                    typesFound.add(t2);
                    Enum<?> dirRightFound = AadlBaUtils.getDirectionType(tar);
                    if (dirRightFound == null) {
                        dirRightFound = AadlBaUtils.getDataAccessRight(tar);
                    }
                    dirRightsFound.add(dirRightFound);
                    if (!_dataChecker.conformsTo(t1, t2, true)) {
                        isconsistent = false;
                    } else {
                        // As checking passed and ambiguity between
                        // ValueExpression and Target has been resolved, it replaces
                        // the value expression by the target as parameter label.
                        it.set(tar);
                    }
                } else // Target checking error case.
                {
                    // Error reporting has already been done.
                    hasCheckingPassed = false;
                }
            } else // Value expression taken as a target -> warning arithmetic pointer operation.
            {
                // Due to target/value expression semantic ambiguity, the parsing
                // phase may have introduced a semantic errors :
                // If v == null :
                // The parameter label has
                // to be a value expression with a single value when the expected
                // subprogram parameter is IN_OUT or OUT.
                // If v is not instanceof Target but ValueExpression or Value
                // like :
                // _ IntegerConstant or ValueConstant
                // _ PortFreshValue
                // _ PortCountValue
                // _ PortDequeueValue
                // It resolves the type in order to format the warning message:
                vth = valueExpressionCheck(valueExp);
                if (vth != null) {
                    try {
                        t1 = AadlBaUtils.getTypeHolder(klass);
                    } catch (DimensionException de) {
                        reportDimensionException(de);
                        return false;
                    }
                    t2 = vth.typeHolder;
                    expectedTypes.add(t1);
                    typesFound.add(t2);
                    boolean inconsistentDir = false;
                    if (v instanceof Reference) {
                        Reference ref = (Reference) v;
                        ArrayableIdentifier refRootId = ref.getIds().get(0);
                        Enum<?> dirRightFound = null;
                        if (refRootId.getOsateRef() != null) {
                            dirRightFound = AadlBaUtils.getDirectionType(refRootId.getOsateRef());
                        }
                        if (dirRightFound == null && refRootId.getOsateRef() instanceof DataAccess) {
                            dirRightFound = Aadl2Utils.getDataAccessRight((DataAccess) refRootId.getOsateRef());
                        }
                        if (dirRightFound == DirectionType.IN || dirRightFound == Aadl2Utils.DataAccessRight.read_only) {
                            inconsistentDir = true;
                        }
                    } else {
                        inconsistentDir = true;
                        dirRightsFound.add(DirectionType.IN);
                    }
                    if (inconsistentDir) {
                        StringBuilder msg = new StringBuilder();
                        msg.append('\'');
                        msg.append(unparseNameElement(valueExp));
                        msg.append("\': is a read only value and it is used as a writable value");
                        // Reports a warning.
                        reportWarning(valueExp, msg.toString());
                    }
                } else {
                    // Error reporting has already been done.
                    hasCheckingPassed = false;
                }
            }
        } else {
            reportError(valueExp, "can't fetch data access right. Set the default " + "right in memory_properties.aadl");
        }
    }
    // Reports consistency error.
    if (!isconsistent && hasCheckingPassed) {
        String subprogramName = null;
        if (comAct.getReference() != null) {
            subprogramName = unparseReference(comAct.getReference());
        } else {
            subprogramName = unparseQualifiedNamedElement(comAct.getQualifiedName());
        }
        reportSubprogParamMatchingError(comAct, subprogramName, expectedTypes, expectedDirRight, typesFound, dirRightsFound);
    }
    return isconsistent && hasCheckingPassed;
}
Also used : LocationReference(org.osate.aadl2.parsesupport.LocationReference) Reference(org.osate.ba.declarative.Reference) DeclarativePropertyReference(org.osate.ba.declarative.DeclarativePropertyReference) ArrayList(java.util.ArrayList) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) Feature(org.osate.aadl2.Feature) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier) DataAccess(org.osate.aadl2.DataAccess) NamedValue(org.osate.ba.declarative.NamedValue) NumberValue(org.osate.aadl2.NumberValue) ClassifierValue(org.osate.aadl2.ClassifierValue) Parameter(org.osate.aadl2.Parameter) DimensionException(org.osate.ba.utils.DimensionException)

Example 9 with Parameter

use of com.reprezen.kaizen.oasparser.model3.Parameter in project osate2 by osate.

the class FeatureGroupTypeImpl method createOwnedParameter.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Parameter createOwnedParameter() {
    Parameter newOwnedParameter = (Parameter) create(Aadl2Package.eINSTANCE.getParameter());
    getOwnedParameters().add(newOwnedParameter);
    return newOwnedParameter;
}
Also used : Parameter(org.osate.aadl2.Parameter)

Example 10 with Parameter

use of com.reprezen.kaizen.oasparser.model3.Parameter in project webtools.servertools by eclipse.

the class XmlTestCase method testServerInstance32.

/**
 * Test behavior of ServerInstance with Tomcat 3.2 default server.xml.
 */
public void testServerInstance32() {
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.Server server = getXml32Server("default.serverxml.32");
    assertNotNull(server);
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.ServerInstance si = new org.eclipse.jst.server.tomcat.core.internal.xml.server32.ServerInstance(server);
    assertNotNull(si.getContextManager());
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.Connector[] connectors = si.getConnectors();
    assertNotNull(connectors);
    assertEquals(2, connectors.length);
    Parameter parameter = connectors[0].getParameter(0);
    assertEquals("handler", parameter.getName());
    assertEquals("org.apache.tomcat.service.http.HttpConnectionHandler", parameter.getValue());
    parameter = connectors[0].getParameter(1);
    assertEquals("port", parameter.getName());
    assertEquals("8080", parameter.getValue());
    parameter = connectors[1].getParameter(0);
    assertEquals("handler", parameter.getName());
    assertEquals("org.apache.tomcat.service.connector.Ajp12ConnectionHandler", parameter.getValue());
    parameter = connectors[1].getParameter(1);
    assertEquals("port", parameter.getName());
    assertEquals("8007", parameter.getValue());
    parameter = si.getConnector(0).getParameter(0);
    assertEquals("handler", parameter.getName());
    assertEquals("org.apache.tomcat.service.http.HttpConnectionHandler", parameter.getValue());
    parameter = si.getConnector(0).getParameter(1);
    assertEquals("port", parameter.getName());
    assertEquals("8080", parameter.getValue());
    parameter = si.getConnector(1).getParameter(0);
    assertEquals("handler", parameter.getName());
    assertEquals("org.apache.tomcat.service.connector.Ajp12ConnectionHandler", parameter.getValue());
    parameter = si.getConnector(1).getParameter(1);
    assertEquals("port", parameter.getName());
    assertEquals("8007", parameter.getValue());
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context[] contexts = si.getContexts();
    assertNotNull(contexts);
    assertEquals(2, contexts.length);
    assertEquals("/examples", contexts[0].getPath());
    assertEquals("/admin", contexts[1].getPath());
    assertEquals("/examples", si.getContext(0).getPath());
    assertEquals("/admin", si.getContext(1).getPath());
    assertEquals("/examples", si.getContext("examples").getPath());
    assertEquals("/admin", si.getContext("/admin").getPath());
    org.eclipse.jst.server.tomcat.core.internal.xml.server32.Context context = si.createContext(2);
    context.setPath("/WebApp1");
    contexts = si.getContexts();
    assertNotNull(contexts);
    assertEquals(3, contexts.length);
    assertEquals("/examples", contexts[0].getPath());
    assertEquals("/admin", contexts[1].getPath());
    assertEquals("/WebApp1", contexts[2].getPath());
    assertEquals(new Path("/Base/work/localhost_8080%2Fexamples"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("examples")));
    assertEquals(new Path("/Base/work/localhost_8080%2Fadmin"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("admin")));
    assertEquals(new Path("/Base/work/localhost_8080%2FWebApp1"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("WebApp1")));
    assertTrue(si.removeContext(2));
    contexts = si.getContexts();
    assertNotNull(contexts);
    assertEquals(2, contexts.length);
    assertEquals("/examples", contexts[0].getPath());
    assertEquals("/admin", contexts[1].getPath());
    context = si.createContext(2);
    context.setPath("");
    context = si.getContext("");
    assertNotNull(context);
    assertEquals("", context.getPath());
    assertEquals(new Path("/Base/work/localhost_8080"), si.getContextWorkDirectory(new Path("/Base"), si.getContext("")));
    assertEquals(si.getServerWorkDirectory(new Path("/Base")), new Path("/Base/work"));
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) Path(org.eclipse.core.runtime.Path) Connector(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector) Parameter(org.eclipse.jst.server.tomcat.core.internal.xml.server32.Parameter) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)

Aggregations

Parameter (com.reprezen.kaizen.oasparser.model3.Parameter)26 Path (com.reprezen.kaizen.oasparser.model3.Path)17 Operation (com.reprezen.kaizen.oasparser.model3.Operation)13 Schema (com.reprezen.kaizen.oasparser.model3.Schema)7 Parameter (org.osate.aadl2.Parameter)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 DataAccess (org.osate.aadl2.DataAccess)4 FeatureGroup (org.osate.aadl2.FeatureGroup)3 Test (org.testng.annotations.Test)3 Map (java.util.Map)2 Parameter (org.eclipse.jst.server.tomcat.core.internal.xml.server32.Parameter)2 TestPoint (org.opengis.cite.ogcapifeatures10.openapi3.TestPoint)2 AbstractFeature (org.osate.aadl2.AbstractFeature)2 ClassifierValue (org.osate.aadl2.ClassifierValue)2 DataSubcomponent (org.osate.aadl2.DataSubcomponent)2 Port (org.osate.aadl2.Port)2 SubprogramSubcomponent (org.osate.aadl2.SubprogramSubcomponent)2 CobiGenRuntimeException (com.devonfw.cobigen.api.exception.CobiGenRuntimeException)1 ParameterDef (com.devonfw.cobigen.openapiplugin.model.ParameterDef)1