From 579baa2bca9c9ddcd0d199934d7f49e6b8161719 Mon Sep 17 00:00:00 2001 From: javanna Date: Fri, 24 Jun 2016 13:29:15 +0200 Subject: [PATCH] [TEST] make JsonPath independent of data format, rename to ObjectPath The internal representation of the object that JsonPath gives access to is a map. That is independent of the initial input format, which is json but could also be yaml etc. This commit renames JsonPath to ObjectPath and adds a static method to create an ObjectPath from an XContent Original commit: elastic/x-pack-elasticsearch@bc84c68161dbb1310eb798448cc2be72888082ba --- .../rest/action/RestAuthenticateActionTests.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java index ad979915726..1d9e5a7eabb 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/xpack/security/rest/action/RestAuthenticateActionTests.java @@ -16,7 +16,7 @@ import org.elasticsearch.xpack.security.authz.InternalAuthorizationService; import org.elasticsearch.xpack.security.user.AnonymousUser; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; -import org.elasticsearch.test.rest.json.JsonPath; +import org.elasticsearch.test.rest.ObjectPath; import org.junit.BeforeClass; import java.util.Collections; @@ -56,10 +56,10 @@ public class RestAuthenticateActionTests extends SecurityIntegTestCase { new BasicHeader("Authorization", basicAuthHeaderValue(SecuritySettingsSource.DEFAULT_USER_NAME, new SecuredString(SecuritySettingsSource.DEFAULT_PASSWORD.toCharArray()))))) { assertThat(response.getStatusLine().getStatusCode(), is(200)); - JsonPath jsonPath = new JsonPath(EntityUtils.toString(response.getEntity())); - assertThat(jsonPath.evaluate("username").toString(), equalTo(SecuritySettingsSource.DEFAULT_USER_NAME)); + ObjectPath objectPath = ObjectPath.createFromXContent(EntityUtils.toString(response.getEntity())); + assertThat(objectPath.evaluate("username").toString(), equalTo(SecuritySettingsSource.DEFAULT_USER_NAME)); @SuppressWarnings("unchecked") - List roles = (List) jsonPath.evaluate("roles"); + List roles = (List) objectPath.evaluate("roles"); assertThat(roles.size(), is(1)); assertThat(roles, contains(SecuritySettingsSource.DEFAULT_ROLE)); } @@ -70,10 +70,10 @@ public class RestAuthenticateActionTests extends SecurityIntegTestCase { Collections.emptyMap(), null)) { if (anonymousEnabled) { assertThat(response.getStatusLine().getStatusCode(), is(200)); - JsonPath jsonPath = new JsonPath(EntityUtils.toString(response.getEntity())); - assertThat(jsonPath.evaluate("username").toString(), equalTo("anon")); + ObjectPath objectPath = ObjectPath.createFromXContent(EntityUtils.toString(response.getEntity())); + assertThat(objectPath.evaluate("username").toString(), equalTo("anon")); @SuppressWarnings("unchecked") - List roles = (List) jsonPath.evaluate("roles"); + List roles = (List) objectPath.evaluate("roles"); assertThat(roles.size(), is(2)); assertThat(roles, contains(SecuritySettingsSource.DEFAULT_ROLE, "foo")); } else {