Conform to RDAP Technical Implementation Guide

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=251864499
This commit is contained in:
guyben 2019-06-06 09:18:07 -07:00 committed by jianglai
parent 5e4199fae6
commit c3c3520e04
65 changed files with 869 additions and 709 deletions

View file

@ -43,30 +43,34 @@ public class RdapSearchActionTestCase<A extends RdapSearchActionBase>
public void initRdapSearchActionTestCase() {
action.parameterMap = ImmutableListMultimap.of();
action.cursorTokenParam = Optional.empty();
action.registrarParam = Optional.empty();
action.rdapResultSetMaxSize = 4;
action.requestUrl = "https://example.tld" + actionPath;
action.requestPath = actionPath;
}
void rememberWildcardType(String queryString) {
try {
RdapSearchPattern partialStringQuery = RdapSearchPattern.create(queryString, true);
if (!partialStringQuery.getHasWildcard()) {
metricWildcardType = WildcardType.NO_WILDCARD;
} else if (partialStringQuery.getSuffix() == null) {
metricWildcardType = WildcardType.PREFIX;
} else if (partialStringQuery.getInitialString().isEmpty()) {
metricWildcardType = WildcardType.SUFFIX;
} else {
metricWildcardType = WildcardType.PREFIX_AND_SUFFIX;
}
metricPrefixLength = partialStringQuery.getInitialString().length();
} catch (Exception e) {
metricWildcardType = WildcardType.INVALID;
metricPrefixLength = 0;
void rememberWildcardType(WildcardType wildcardType, int prefixLength) {
metricWildcardType = wildcardType;
metricPrefixLength = prefixLength;
}
void rememberWildcardType(String searchQuery) {
int wildcardLocation = searchQuery.indexOf('*');
if (wildcardLocation < 0) {
rememberWildcardType(WildcardType.NO_WILDCARD, searchQuery.length());
} else if (wildcardLocation == searchQuery.length() - 1) {
rememberWildcardType(WildcardType.PREFIX, wildcardLocation);
} else if (wildcardLocation == 0) {
rememberWildcardType(WildcardType.SUFFIX, wildcardLocation);
} else {
rememberWildcardType(WildcardType.PREFIX_AND_SUFFIX, wildcardLocation);
}
}
void rememberWildcardTypeInvalid() {
rememberWildcardType(WildcardType.INVALID, 0);
}
void verifyMetrics(
EndpointType endpointType,
Action.Method requestMethod,