use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class DOMHandlerImpl method checkAttributeValueIsEmpty.
/**
* @deprecated Kept for backward compatibility.
* @param attributeName
* the name of the attribute to check
* @return
*/
@Override
@Deprecated
public TestSolution checkAttributeValueIsEmpty(String attributeName) {
Collection<TestSolution> resultSet = new ArrayList<TestSolution>();
for (Node workingElement : selectedElementList) {
TestSolution result = TestSolution.PASSED;
Node attribute = workingElement.getAttributes().getNamedItem(attributeName);
if (attribute != null) {
if (attribute.getNodeValue().length() != 0) {
result = TestSolution.FAILED;
addSourceCodeRemark(result, workingElement, "ValueNotEmpty", attributeName);
}
} else {
result = TestSolution.NOT_APPLICABLE;
}
resultSet.add(result);
}
return RuleHelper.synthesizeTestSolutionCollection(resultSet);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class DOMHandlerImpl method checkContentNotEmpty.
/**
* @deprecated Kept for backward compatibility.
* @return
*/
@Override
@Deprecated
public TestSolution checkContentNotEmpty() {
Collection<TestSolution> resultSet = new ArrayList<TestSolution>();
for (Node workingElement : selectedElementList) {
TestSolution result = TestSolution.PASSED;
if (workingElement.getTextContent().trim().isEmpty() && (workingElement.getChildNodes().getLength() == 0 || (workingElement.getChildNodes().getLength() == 1 && workingElement.getChildNodes().item(0).getNodeName().equalsIgnoreCase("#text")))) {
result = TestSolution.FAILED;
addSourceCodeRemark(result, workingElement, "ValueEmpty", workingElement.getNodeName());
}
resultSet.add(result);
}
return RuleHelper.synthesizeTestSolutionCollection(resultSet);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class DOMHandlerImpl method checkAttributeValueLengthLower.
/**
* @deprecated Kept for backward compatibility.
* @param attributeName
* the name of the attribute to check
* @param length
* the length of the attribute value to check
* @param defaultFailResult
* the default return value if the check processing fails
* @return
*/
@Override
@Deprecated
public TestSolution checkAttributeValueLengthLower(String attributeName, int length, TestSolution defaultFailResult) {
Collection<TestSolution> resultSet = new ArrayList<TestSolution>();
for (Node workingElement : selectedElementList) {
TestSolution result = TestSolution.PASSED;
String textContent = workingElement.getTextContent();
if (textContent.length() > length) {
result = defaultFailResult;
addSourceCodeRemark(result, workingElement, "LengthTooLong", textContent);
}
resultSet.add(result);
}
return RuleHelper.synthesizeTestSolutionCollection(resultSet);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class DOMHandlerImpl method checkTextContentValue.
@Override
public TestSolution checkTextContentValue(Collection<String> blacklist, Collection<String> whitelist) {
if (whitelist == null) {
whitelist = new ArrayList<String>();
}
if (blacklist == null) {
blacklist = new ArrayList<String>();
}
Collection<TestSolution> resultSet = new ArrayList<TestSolution>();
for (Node workingElement : selectedElementList) {
TestSolution result = TestSolution.NEED_MORE_INFO;
boolean isInBlackList = false;
boolean isInWhiteList = false;
String textContent = workingElement.getTextContent();
for (String text : blacklist) {
if (textContent.toLowerCase().equals(text.toLowerCase())) {
isInBlackList = true;
break;
}
}
for (String text : whitelist) {
if (textContent.toLowerCase().equals(text.toLowerCase())) {
isInWhiteList = true;
break;
}
}
if (isInBlackList && isInWhiteList) {
throw new RuntimeException(new IncoherentValueDomainsException());
}
if (isInBlackList) {
result = TestSolution.FAILED;
addSourceCodeRemark(result, workingElement, "BlackListedValue", textContent);
}
if (isInWhiteList) {
result = TestSolution.PASSED;
}
if (result.equals(TestSolution.NEED_MORE_INFO)) {
addSourceCodeRemark(result, workingElement, "VerifyValue", textContent);
}
resultSet.add(result);
}
return RuleHelper.synthesizeTestSolutionCollection(resultSet);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class DOMHandlerImpl method checkAttributeExists.
@Override
public TestSolution checkAttributeExists(String attributeName) {
if (messageCode == null) {
messageCode = ATTRIBUTE_MISSING_MSG_CODE;
}
Collection<TestSolution> resultSet = new ArrayList<TestSolution>();
for (Node workingElement : selectedElementList) {
TestSolution processResult = TestSolution.PASSED;
Node attribute = workingElement.getAttributes().getNamedItem(attributeName);
if (attribute == null) {
processResult = TestSolution.FAILED;
addSourceCodeRemark(processResult, workingElement, messageCode, attributeName);
}
resultSet.add(processResult);
}
return RuleHelper.synthesizeTestSolutionCollection(resultSet);
}
Aggregations