From 031cd2b9b69e2bded1101ed1cf221860dc33e294 Mon Sep 17 00:00:00 2001 From: Meenal Bhave Date: Tue, 15 May 2018 12:19:12 +0100 Subject: [PATCH] Search-741 Added tests to ensure metadata is not included when not specified as true --- .../rest/search/sql/SearchSQLAPITest.java | 61 ++++++++++++++++++- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java index bd0c9e0a0..c680541e9 100644 --- a/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java +++ b/e2e-test/java/org/alfresco/rest/search/sql/SearchSQLAPITest.java @@ -128,7 +128,7 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - + sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); sqlRequest.setLocales(locales); @@ -139,7 +139,7 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); - + sqlRequest = new SearchSqlRequest(); sqlRequest.setSql(sql); sqlRequest.setLocales(locales); @@ -287,4 +287,61 @@ public class SearchSQLAPITest extends AbstractSearchTest restClient.onResponse().assertThat().body("list.entries.entry[0][2].label", Matchers.equalToIgnoringCase("fields")); restClient.onResponse().assertThat().body("list.entries.entry[0][2].value", Matchers.equalToIgnoringCase("[\"SITE\",\"cm_owner\"]")); } + + @Test(groups = { TestGroup.SEARCH, TestGroup.REST_API, TestGroup.INSIGHT_10 }, priority = 05) + public void testIncludeMetadataFalse() throws Exception + { + SearchSqlRequest sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat("solr"); //Format solr + sqlRequest.setIncludeMetadata(false); + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue()); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setIncludeMetadata(false); + sqlRequest.setFormat("json"); // Format json + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.not("aliases")); + + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setIncludeMetadata(false); //Format not set + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.nullValue()); + restClient.onResponse().assertThat().body("list.entries", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("list.entries.entry[0][0].label", Matchers.not("aliases")); + + sqlRequest = new SearchSqlRequest(); + sqlRequest.setSql(sql); + sqlRequest.setFormat(solrFormat); // IncludeMetadata = false when not specified + + restClient.authenticateUser(userModel).withSearchSqlAPI().searchSql(sqlRequest); + restClient.assertStatusCodeIs(HttpStatus.OK); + + restClient.onResponse().assertThat().body("result-set", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs", Matchers.notNullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].aliases", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].isMetadata", Matchers.nullValue()); + restClient.onResponse().assertThat().body("result-set.docs[0].fields", Matchers.nullValue()); + } } \ No newline at end of file