mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
SEARCH-1989 Allow checking values returned in a column. (#1)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package org.alfresco.cmis.dsl;
|
||||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import static org.alfresco.utility.Utility.checkObjectIsInitialized;
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
@@ -7,8 +9,11 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Streams;
|
||||
|
||||
import org.alfresco.cmis.CmisWrapper;
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.data.provider.XMLTestData;
|
||||
@@ -60,6 +65,12 @@ public class QueryExecutor
|
||||
return new QueryResultAssertion();
|
||||
}
|
||||
|
||||
public QueryResultAssertion assertValues()
|
||||
{
|
||||
results = executeQuery(currentQuery);
|
||||
return new QueryResultAssertion();
|
||||
}
|
||||
|
||||
private ItemIterable<QueryResult> executeQuery(String query)
|
||||
{
|
||||
Session session = cmisWrapper.getSession();
|
||||
@@ -177,7 +188,7 @@ public class QueryExecutor
|
||||
{
|
||||
STEP(String.format("Verify that query: '%s' is returning ascending ordered values for column %s", currentQuery, queryName));
|
||||
List<Object> columnValues = new ArrayList<>();
|
||||
results.forEach((r)->{
|
||||
results.forEach((r) -> {
|
||||
columnValues.add(r.getPropertyValueByQueryName(queryName));
|
||||
});
|
||||
List<Object> orderedColumnValues = columnValues.stream().sorted().collect(Collectors.toList());
|
||||
@@ -192,7 +203,7 @@ public class QueryExecutor
|
||||
{
|
||||
STEP(String.format("Verify that query: '%s' is returning descending ordered values for column %s", currentQuery, queryName));
|
||||
List<Object> columnValues = new ArrayList<>();
|
||||
results.forEach((r)->{
|
||||
results.forEach((r) -> {
|
||||
columnValues.add(r.getPropertyValueByQueryName(queryName));
|
||||
});
|
||||
List<Object> reverseOrderedColumnValues = columnValues.stream().sorted(Collections.reverseOrder()).collect(Collectors.toList());
|
||||
@@ -206,7 +217,7 @@ public class QueryExecutor
|
||||
public QueryResultAssertion isReturningValuesInRange(String queryName, BigDecimal minValue, BigDecimal maxValue)
|
||||
{
|
||||
STEP(String.format("Verify that query: '%s' is returning values for column %s in range from %.4f to %.4f", currentQuery, queryName, minValue, maxValue));
|
||||
results.forEach((r)->{
|
||||
results.forEach((r) -> {
|
||||
BigDecimal value = (BigDecimal) r.getPropertyValueByQueryName(queryName);
|
||||
if (value.compareTo(minValue) < 0 || value.compareTo(maxValue) > 0)
|
||||
{
|
||||
@@ -215,7 +226,15 @@ public class QueryExecutor
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public <T> QueryResultAssertion isReturningValues(String queryName, Set<T> values)
|
||||
{
|
||||
STEP(String.format("Verify that query: '%s' returns the values from %s for column %s", currentQuery, values, queryName));
|
||||
Set<T> resultSet = Streams.stream(results).map(r -> (T) r.getPropertyValueByQueryName(queryName)).collect(toSet());
|
||||
Assert.assertEquals(resultSet, values, "Values did not match");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private String showErrorMessage()
|
||||
|
Reference in New Issue
Block a user