You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2013/09/11 16:16:34 UTC
svn commit: r1521863 -
/stanbol/trunk/entityhub/generic/test/src/main/java/org/apache/stanbol/entityhub/test/it/AssertEntityhubJson.java
Author: rwesten
Date: Wed Sep 11 14:16:33 2013
New Revision: 1521863
URL: http://svn.apache.org/r1521863
Log:
minor change related to STANBOL-1153: assertQueryResults now returns a List with the IDs of entities in the result list.
Modified:
stanbol/trunk/entityhub/generic/test/src/main/java/org/apache/stanbol/entityhub/test/it/AssertEntityhubJson.java
Modified: stanbol/trunk/entityhub/generic/test/src/main/java/org/apache/stanbol/entityhub/test/it/AssertEntityhubJson.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/generic/test/src/main/java/org/apache/stanbol/entityhub/test/it/AssertEntityhubJson.java?rev=1521863&r1=1521862&r2=1521863&view=diff
==============================================================================
--- stanbol/trunk/entityhub/generic/test/src/main/java/org/apache/stanbol/entityhub/test/it/AssertEntityhubJson.java (original)
+++ stanbol/trunk/entityhub/generic/test/src/main/java/org/apache/stanbol/entityhub/test/it/AssertEntityhubJson.java Wed Sep 11 14:16:33 2013
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertNot
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -61,15 +62,16 @@ public class AssertEntityhubJson {
* @throws JSONException in case the {@link RequestExecutor#getContent()} are
* no valid JSON. NOTE that the contents are only parsed if the
* {@link QueryTestCase#getExpectedStatus()} is a 2xx status code.
+ * @return in case of success the List of result Entity IDs
*/
- public static void assertQueryResults(RequestExecutor re, QueryTestCase test) throws JSONException{
+ public static List<String> assertQueryResults(RequestExecutor re, QueryTestCase test) throws JSONException{
if(log.isDebugEnabled()){
log.debug("Assert Query Results for test {}",test.getContent());
}
re.assertStatus(test.getExpectedStatus());
re.assertContentType("application/json"); //currently only application/json is supported
if(!test.expectsSuccess()){
- return; //no further checks for tests that expect failure
+ return null; //no further checks for tests that expect failure
}
JSONObject jso = new JSONObject(re.getContent());
if(log.isDebugEnabled()){
@@ -96,11 +98,13 @@ public class AssertEntityhubJson {
//General NOTE:
// use opt**(..) methods to avoid JSON Exception. We want to parse
// everything and than do asserts!
+ List<String> resultIds = new ArrayList<String>(results.length());
for(int i=0;i<results.length();i++){
JSONObject result = results.getJSONObject(i);
String id = result.optString("id", null);
log.info("({}) {}",i,id);
assertNotNull("ID missing for an Result", id);
+ resultIds.add(id);
if(expectedIds != null){
expectedIds.remove(id); //not all results must be in the list
}
@@ -114,6 +118,7 @@ public class AssertEntityhubJson {
assertTrue("The following expected results where missing in the Response: \n "+expectedIds,
expectedIds.isEmpty());
}
+ return resultIds;
}
/**