use of org.apache.commons.lang3.StringUtils.isNotBlank in project pulsar by yahoo.
the class NamespaceService method createLookupResult.
private CompletableFuture<LookupResult> createLookupResult(String candidateBroker) throws Exception {
CompletableFuture<LookupResult> lookupFuture = new CompletableFuture<>();
try {
checkArgument(StringUtils.isNotBlank(candidateBroker), "Lookup broker can't be null " + candidateBroker);
URI uri = new URI(candidateBroker);
String path = String.format("%s/%s:%s", SimpleLoadManagerImpl.LOADBALANCE_BROKERS_ROOT, uri.getHost(), uri.getPort());
pulsar.getLocalZkCache().getDataAsync(path, loadReportDeserializer).thenAccept(reportData -> {
if (reportData.isPresent()) {
LoadReport report = reportData.get();
lookupFuture.complete(new LookupResult(report.getWebServiceUrl(), report.getWebServiceUrlTls(), report.getPulsarServiceUrl(), report.getPulsarServieUrlTls()));
} else {
lookupFuture.completeExceptionally(new KeeperException.NoNodeException(path));
}
}).exceptionally(ex -> {
lookupFuture.completeExceptionally(ex);
return null;
});
} catch (Exception e) {
lookupFuture.completeExceptionally(e);
}
return lookupFuture;
}
use of org.apache.commons.lang3.StringUtils.isNotBlank in project Asqatasun by Asqatasun.
the class Rgaa30Rule110102 method check.
@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
/* If the page has no input form element, the test is not applicable */
if (inputFormMap.entrySet().isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
for (Map.Entry<Element, ElementHandler<Element>> entry : inputFormMap.entrySet()) {
/* The attribute Presence Checker */
ElementChecker attributePresenceChecker = new AttributePresenceChecker(ID_ATTR, new ImmutablePair(TestSolution.PASSED, ""), new ImmutablePair(TestSolution.FAILED, ID_MISSING_MSG));
attributePresenceChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
/* The attribute Emptiness Checker. Keep default value i.e failed
when attribute is empty
*/
ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(ID_ATTR), ID_MISSING_MSG, null);
attributeEmptinessChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
/* The id unicityChecker */
ElementChecker idUnicityChecker = new IdUnicityChecker(ID_NOT_UNIQUE_MSG);
idUnicityChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
}
for (Map.Entry<Element, ElementHandler<Element>> entry : labelFormMap.entrySet()) {
/* The attribute Presence Checker */
ElementChecker attributePresenceChecker = new AttributePresenceChecker(FOR_ATTR, new ImmutablePair(TestSolution.PASSED, ""), new ImmutablePair(TestSolution.FAILED, FOR_MISSING_MSG));
attributePresenceChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
/* The attribute Emptiness Checker. Keep default value i.e failed
when attribute is empty
*/
ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(FOR_ATTR), FOR_MISSING_MSG, null);
attributeEmptinessChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
}
for (Map.Entry<Element, ElementHandler<Element>> entry : inputFormMap.entrySet()) {
ElementHandler<Element> inputOnError = new ElementHandlerImpl();
/* Check if each input id attribute is linked to a for attribute*/
for (Element el : entry.getValue().get()) {
String id = el.id();
if (StringUtils.isNotBlank(id)) {
ElementHandler<Element> linkedLabelToInputHandler = new ElementHandlerImpl();
if (entry.getKey().select(LABEL_ELEMENT + " " + CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(INPUT_ELEMENT, ID_ATTR, id)).isEmpty()) {
linkedLabelToInputHandler.addAll(entry.getKey().select(CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(LABEL_ELEMENT, FOR_ATTR, id)));
if (linkedLabelToInputHandler.isEmpty()) {
inputOnError.add(el);
}
}
}
}
ElementChecker elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, INVALID_INPUT_MSG), new ImmutablePair(TestSolution.PASSED, ""));
elementPresenceChecker.check(sspHandler, inputOnError, testSolutionHandler);
}
for (Map.Entry<Element, ElementHandler<Element>> entry : labelFormMap.entrySet()) {
ElementHandler<Element> labelOnError = new ElementHandlerImpl();
/* Check if each label for attribute is associated to an input id attribute*/
for (Element el : entry.getValue().get()) {
String id = el.attr(FOR_ATTR);
if (StringUtils.isNotBlank(id)) {
ElementHandler<Element> linkedLabelToInputHandler = new ElementHandlerImpl();
linkedLabelToInputHandler.addAll(entry.getKey().select(CssLikeSelectorBuilder.buildSelectorFromId(id)));
if (linkedLabelToInputHandler.isEmpty()) {
labelOnError.add(el);
}
}
}
ElementChecker elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, INVALID_LABEL_MSG), new ImmutablePair(TestSolution.PASSED, ""));
elementPresenceChecker.check(sspHandler, labelOnError, testSolutionHandler);
}
}
use of org.apache.commons.lang3.StringUtils.isNotBlank in project Asqatasun by Asqatasun.
the class Rgaa32016Rule110102 method check.
@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
/* If the page has no input form element, the test is not applicable */
if (inputFormMap.entrySet().isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
for (Map.Entry<Element, ElementHandler<Element>> entry : inputFormMap.entrySet()) {
/* The attribute Presence Checker */
ElementChecker attributePresenceChecker = new AttributePresenceChecker(ID_ATTR, new ImmutablePair(TestSolution.PASSED, ""), new ImmutablePair(TestSolution.FAILED, ID_MISSING_MSG));
attributePresenceChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
/* The attribute Emptiness Checker. Keep default value i.e failed
when attribute is empty
*/
ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(ID_ATTR), ID_MISSING_MSG, null);
attributeEmptinessChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
/* The id unicityChecker */
ElementChecker idUnicityChecker = new IdUnicityChecker(ID_NOT_UNIQUE_MSG);
idUnicityChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
}
for (Map.Entry<Element, ElementHandler<Element>> entry : labelFormMap.entrySet()) {
/* The attribute Presence Checker */
ElementChecker attributePresenceChecker = new AttributePresenceChecker(FOR_ATTR, new ImmutablePair(TestSolution.PASSED, ""), new ImmutablePair(TestSolution.FAILED, FOR_MISSING_MSG));
attributePresenceChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
/* The attribute Emptiness Checker. Keep default value i.e failed
when attribute is empty
*/
ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(FOR_ATTR), FOR_MISSING_MSG, null);
attributeEmptinessChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
}
for (Map.Entry<Element, ElementHandler<Element>> entry : inputFormMap.entrySet()) {
ElementHandler<Element> inputOnError = new ElementHandlerImpl();
/* Check if each input id attribute is linked to a for attribute*/
for (Element el : entry.getValue().get()) {
String id = el.id();
if (StringUtils.isNotBlank(id)) {
ElementHandler<Element> linkedLabelToInputHandler = new ElementHandlerImpl();
if (entry.getKey().select(LABEL_ELEMENT + " " + CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(INPUT_ELEMENT, ID_ATTR, id)).isEmpty()) {
linkedLabelToInputHandler.addAll(entry.getKey().select(CssLikeSelectorBuilder.buildSelectorFromElementsAndAttributeValue(LABEL_ELEMENT, FOR_ATTR, id)));
if (linkedLabelToInputHandler.isEmpty()) {
inputOnError.add(el);
}
}
}
}
ElementChecker elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, INVALID_INPUT_MSG), new ImmutablePair(TestSolution.PASSED, ""));
elementPresenceChecker.check(sspHandler, inputOnError, testSolutionHandler);
}
for (Map.Entry<Element, ElementHandler<Element>> entry : labelFormMap.entrySet()) {
ElementHandler<Element> labelOnError = new ElementHandlerImpl();
/* Check if each label for attribute is associated to an input id attribute*/
for (Element el : entry.getValue().get()) {
String id = el.attr(FOR_ATTR);
if (StringUtils.isNotBlank(id)) {
ElementHandler<Element> linkedLabelToInputHandler = new ElementHandlerImpl();
linkedLabelToInputHandler.addAll(entry.getKey().select(CssLikeSelectorBuilder.buildSelectorFromId(id)));
if (linkedLabelToInputHandler.isEmpty()) {
labelOnError.add(el);
}
}
}
ElementChecker elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, INVALID_LABEL_MSG), new ImmutablePair(TestSolution.PASSED, ""));
elementPresenceChecker.check(sspHandler, labelOnError, testSolutionHandler);
}
}
Aggregations