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;
}
}
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);
}
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");
}
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();
}
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;
}
Aggregations