Search in sources :

Example 91 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project product-iots by wso2.

the class EnrollDevicePage method gotoConnectedCupDeviceTypeViewPage.

/**
 * Method to perform the navigation to Device type view page of the Connected cup.
 * @return : The corresponding Device type view page. Null, if the element is not visible.
 */
public ConnectedCupDeviceTypeViewPage gotoConnectedCupDeviceTypeViewPage() throws IOException {
    boolean check = UIUtils.isElementPresent(log, driver, By.xpath(uiElementMapper.getElement("iot.sample.connectedcup.xpath")));
    if (check) {
        WebElement deviceDiv = driver.findElement(By.xpath(uiElementMapper.getElement("iot.sample.connectedcup.xpath")));
        WebElement tryBtn = deviceDiv.findElement(By.tagName("button"));
        tryBtn.click();
        return new ConnectedCupDeviceTypeViewPage(driver);
    } else {
        log.error("Element not found!");
        return null;
    }
}
Also used : ConnectedCupDeviceTypeViewPage(org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceTypeViewPage) WebElement(org.openqa.selenium.WebElement)

Example 92 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project product-iots by wso2.

the class AndroidEnrollment method testEnrollment.

@Test(description = "Test an Android device enrollment.")
public void testEnrollment() throws Exception {
    String enrollmentData = PayloadGenerator.getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString();
    HttpResponse response = client.post(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT, enrollmentData);
    JsonParser jsonParser = new JsonParser();
    JsonElement element = jsonParser.parse(response.getData());
    JsonObject jsonObject = element.getAsJsonObject();
    JsonElement msg = jsonObject.get("responseMessage");
    deviceId = msg.getAsString().split("\'")[1].split("\'")[0];
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString(), response.getData(), true);
}
Also used : JsonElement(com.google.gson.JsonElement) HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser) Test(org.testng.annotations.Test)

Example 93 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project carbon-apimgt by wso2.

the class XMLAnalyzerTestCase method testAnalyzerDTDDisabled.

@Test(expectedExceptions = APIMThreatAnalyzerException.class)
public void testAnalyzerDTDDisabled() throws Exception {
    init();
    XMLAnalyzer analyzer = new XMLAnalyzer();
    analyzer.configure(xmlConfig);
    String xmlString = "<?xml version=\"1.0\"?>\n" + "<!DOCTYPE lolz [\n" + " <!ENTITY lol \"lol\">\n" + " <!ELEMENT lolz (#PCDATA)>\n" + " <!ENTITY lol1 \"&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;\">\n" + " <!ENTITY lol2 \"&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;\">\n" + " <!ENTITY lol3 \"&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;\">\n" + " <!ENTITY lol4 \"&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;\">\n" + " <!ENTITY lol5 \"&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;\">\n" + " <!ENTITY lol6 \"&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;\">\n" + " <!ENTITY lol7 \"&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;\">\n" + " <!ENTITY lol8 \"&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;\">\n" + " <!ENTITY lol9 \"&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;\">\n" + "]>\n" + "<lolz>&lol9;</lolz>";
    analyzer.analyze(xmlString, "/foo");
}
Also used : XMLAnalyzer(org.wso2.carbon.apimgt.ballerina.threatprotection.analyzer.XMLAnalyzer) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 94 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project siddhi by wso2.

the class Annotation method toString.

@Override
public String toString() {
    boolean isFirst = true;
    StringBuilder definitionBuilder = new StringBuilder("@").append(name).append("( ");
    if (elements != null && elements.size() > 0) {
        for (Element element : elements) {
            if (!isFirst) {
                definitionBuilder.append(", ");
            } else {
                isFirst = false;
            }
            definitionBuilder.append(element.toString());
        }
    }
    if (annotations != null && annotations.size() > 0) {
        for (Annotation annotation : annotations) {
            if (!isFirst) {
                definitionBuilder.append(", ");
            } else {
                isFirst = false;
            }
            definitionBuilder.append(annotation.toString());
        }
    }
    definitionBuilder.append(")");
    return definitionBuilder.toString();
}
Also used : SiddhiElement(org.wso2.siddhi.query.api.SiddhiElement)

Example 95 with Element

use of org.wso2.siddhi.query.api.annotation.Element in project siddhi by wso2.

the class Partition method addQuery.

public Partition addQuery(Query query) {
    if (query == null) {
        throw new SiddhiAppValidationException("Query should not be null");
    }
    String name = null;
    Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants.ANNOTATION_ELEMENT_NAME, query.getAnnotations());
    if (element != null) {
        name = element.getValue();
    }
    if (name != null && queryNameList.contains(name)) {
        throw new SiddhiAppValidationException("Cannot add Query as another Execution Element already uses " + "its name=" + name + " within the same Partition", element.getQueryContextStartIndex(), element.getQueryContextEndIndex());
    }
    queryNameList.add(name);
    this.queryList.add(query);
    return this;
}
Also used : Element(org.wso2.siddhi.query.api.annotation.Element) ExecutionElement(org.wso2.siddhi.query.api.execution.ExecutionElement) SiddhiElement(org.wso2.siddhi.query.api.SiddhiElement) SiddhiAppValidationException(org.wso2.siddhi.query.api.exception.SiddhiAppValidationException)

Aggregations

Test (org.testng.annotations.Test)87 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)82 Query (org.wso2.siddhi.query.api.execution.query.Query)81 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)79 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)79 SiddhiApp (org.wso2.siddhi.query.api.SiddhiApp)79 Event (org.wso2.siddhi.core.event.Event)77 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)76 QueryCallback (org.wso2.siddhi.core.query.output.callback.QueryCallback)73 Element (org.w3c.dom.Element)34 OMElement (org.apache.axiom.om.OMElement)25 QName (javax.xml.namespace.QName)15 SVGCoordinates (org.wso2.carbon.bpel.ui.bpel2svg.SVGCoordinates)14 ActivityInterface (org.wso2.carbon.bpel.ui.bpel2svg.ActivityInterface)13 NodeList (org.w3c.dom.NodeList)12 Element (org.wso2.siddhi.query.api.annotation.Element)12 Node (org.w3c.dom.Node)11 ArrayList (java.util.ArrayList)9 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)8 HashMap (java.util.HashMap)7