Add next page navigation for RDAP entity searches

A couple methods were moved to new locations so they are accessible to all types of search queries, not just nameservers like they originally were.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179089014
This commit is contained in:
mountford 2017-12-14 13:40:02 -08:00 committed by Ben McIlwain
parent c8059d4d8a
commit e619ea1bff
12 changed files with 398 additions and 111 deletions

View file

@ -14,6 +14,8 @@
package google.registry.rdap;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import google.registry.config.RdapNoticeDescriptor;
@ -21,6 +23,8 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.annotation.Nullable;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
public class RdapTestHelper {
@ -245,4 +249,32 @@ public class RdapTestHelper {
.build());
return rdapJsonFormatter;
}
static String getLinkToNext(Object results) {
assertThat(results).isInstanceOf(JSONObject.class);
Object notices = ((JSONObject) results).get("notices");
assertThat(notices).isInstanceOf(JSONArray.class);
for (Object notice : (JSONArray) notices) {
assertThat(notice).isInstanceOf(JSONObject.class);
Object title = ((JSONObject) notice).get("title");
assertThat(title).isInstanceOf(String.class);
if (!title.equals("Navigation Links")) {
continue;
}
Object links = ((JSONObject) notice).get("links");
assertThat(links).isInstanceOf(JSONArray.class);
for (Object link : (JSONArray) links) {
assertThat(link).isInstanceOf(JSONObject.class);
Object rel = ((JSONObject) link).get("rel");
assertThat(rel).isInstanceOf(String.class);
if (!rel.equals("next")) {
continue;
}
Object href = ((JSONObject) link).get("href");
assertThat(href).isInstanceOf(String.class);
return (String) href;
}
}
return null;
}
}