SEARCH-1989 Allow checking values returned in a column. (#1)

This commit is contained in:
Tom Page
2019-11-29 14:50:05 +00:00
committed by GitHub
parent 98bc091adc
commit 7da7544c37

View File

@@ -1,5 +1,7 @@
package org.alfresco.cmis.dsl; package org.alfresco.cmis.dsl;
import static java.util.stream.Collectors.toSet;
import static org.alfresco.utility.Utility.checkObjectIsInitialized; import static org.alfresco.utility.Utility.checkObjectIsInitialized;
import static org.alfresco.utility.report.log.Step.STEP; import static org.alfresco.utility.report.log.Step.STEP;
@@ -7,8 +9,11 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.collect.Streams;
import org.alfresco.cmis.CmisWrapper; import org.alfresco.cmis.CmisWrapper;
import org.alfresco.utility.LogFactory; import org.alfresco.utility.LogFactory;
import org.alfresco.utility.data.provider.XMLTestData; import org.alfresco.utility.data.provider.XMLTestData;
@@ -60,6 +65,12 @@ public class QueryExecutor
return new QueryResultAssertion(); return new QueryResultAssertion();
} }
public QueryResultAssertion assertValues()
{
results = executeQuery(currentQuery);
return new QueryResultAssertion();
}
private ItemIterable<QueryResult> executeQuery(String query) private ItemIterable<QueryResult> executeQuery(String query)
{ {
Session session = cmisWrapper.getSession(); Session session = cmisWrapper.getSession();
@@ -215,7 +226,15 @@ public class QueryExecutor
}); });
return this; 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() private String showErrorMessage()