mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Remove unused request parameter extractor
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130672143
This commit is contained in:
parent
f10a7d8fb0
commit
5ff8b9377c
2 changed files with 0 additions and 34 deletions
|
@ -58,19 +58,6 @@ public final class RequestParameters {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns first GET or POST parameter associated with {@code name}.
|
|
||||||
*
|
|
||||||
* @throws BadRequestException if request parameter is absent (but not if empty)
|
|
||||||
*/
|
|
||||||
public static String extractRequiredMaybeEmptyParameter(HttpServletRequest req, String name) {
|
|
||||||
String result = req.getParameter(name);
|
|
||||||
if (result == null) {
|
|
||||||
throw new BadRequestException("Missing parameter: " + name);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the first GET or POST parameter associated with {@code name}. */
|
/** Returns the first GET or POST parameter associated with {@code name}. */
|
||||||
public static Optional<String> extractOptionalParameter(HttpServletRequest req, String name) {
|
public static Optional<String> extractOptionalParameter(HttpServletRequest req, String name) {
|
||||||
return Optional.fromNullable(emptyToNull(req.getParameter(name)));
|
return Optional.fromNullable(emptyToNull(req.getParameter(name)));
|
||||||
|
|
|
@ -20,7 +20,6 @@ import static google.registry.request.RequestParameters.extractEnumParameter;
|
||||||
import static google.registry.request.RequestParameters.extractOptionalDatetimeParameter;
|
import static google.registry.request.RequestParameters.extractOptionalDatetimeParameter;
|
||||||
import static google.registry.request.RequestParameters.extractOptionalParameter;
|
import static google.registry.request.RequestParameters.extractOptionalParameter;
|
||||||
import static google.registry.request.RequestParameters.extractRequiredDatetimeParameter;
|
import static google.registry.request.RequestParameters.extractRequiredDatetimeParameter;
|
||||||
import static google.registry.request.RequestParameters.extractRequiredMaybeEmptyParameter;
|
|
||||||
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -64,26 +63,6 @@ public class RequestParametersTest {
|
||||||
extractRequiredParameter(req, "spin");
|
extractRequiredParameter(req, "spin");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExtractRequiredMaybeEmptyParameter_valuePresent_returnsValue() throws Exception {
|
|
||||||
when(req.getParameter("spin")).thenReturn("bog");
|
|
||||||
assertThat(extractRequiredMaybeEmptyParameter(req, "spin")).isEqualTo("bog");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExtractRequiredMaybeEmptyParameter_notPresent_throwsBadRequest()
|
|
||||||
throws Exception {
|
|
||||||
thrown.expect(BadRequestException.class, "spin");
|
|
||||||
extractRequiredMaybeEmptyParameter(req, "spin");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExtractRequiredMaybeEmptyParameter_empty_returnsValue()
|
|
||||||
throws Exception {
|
|
||||||
when(req.getParameter("spin")).thenReturn("");
|
|
||||||
assertThat(extractRequiredMaybeEmptyParameter(req, "spin")).isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtractOptionalParameter_valuePresent_returnsValue() throws Exception {
|
public void testExtractOptionalParameter_valuePresent_returnsValue() throws Exception {
|
||||||
when(req.getParameter("spin")).thenReturn("bog");
|
when(req.getParameter("spin")).thenReturn("bog");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue