mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 09:27:16 +02:00
Remove transition code for set of parameter refactoring
None of the logged warnings happened in the last week. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=204307010
This commit is contained in:
parent
badda1d407
commit
a00cb2237a
6 changed files with 62 additions and 59 deletions
|
@ -23,6 +23,7 @@ import static google.registry.request.RequestParameters.extractOptionalEnumParam
|
|||
import static google.registry.request.RequestParameters.extractOptionalParameter;
|
||||
import static google.registry.request.RequestParameters.extractRequiredDatetimeParameter;
|
||||
import static google.registry.request.RequestParameters.extractRequiredParameter;
|
||||
import static google.registry.request.RequestParameters.extractSetOfParameters;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -78,6 +79,43 @@ public class RequestParametersTest {
|
|||
assertThat(extractOptionalParameter(req, "spin")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractSetOfParameters_notPresent_returnsEmpty() {
|
||||
assertThat(extractSetOfParameters(req, "spin")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractSetOfParameters_empty_returnsEmpty() {
|
||||
when(req.getParameterValues("spin")).thenReturn(new String[]{""});
|
||||
assertThat(extractSetOfParameters(req, "spin")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractSetOfParameters_oneValue_returnsValue() {
|
||||
when(req.getParameterValues("spin")).thenReturn(new String[]{"bog"});
|
||||
assertThat(extractSetOfParameters(req, "spin")).containsExactly("bog");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractSetOfParameters_multipleValues_returnsAll() {
|
||||
when(req.getParameterValues("spin")).thenReturn(new String[]{"bog,gob"});
|
||||
assertThat(extractSetOfParameters(req, "spin")).containsExactly("bog", "gob");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractSetOfParameters_multipleValuesWithEmpty_removesEmpty() {
|
||||
when(req.getParameterValues("spin")).thenReturn(new String[]{",bog,,gob,"});
|
||||
assertThat(extractSetOfParameters(req, "spin")).containsExactly("bog", "gob");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractSetOfParameters_multipleParameters_error() {
|
||||
when(req.getParameterValues("spin")).thenReturn(new String[]{"bog", "gob"});
|
||||
BadRequestException thrown =
|
||||
assertThrows(BadRequestException.class, () -> extractSetOfParameters(req, "spin"));
|
||||
assertThat(thrown).hasMessageThat().contains("spin");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractBooleanParameter_notPresent_returnsFalse() {
|
||||
assertThat(extractBooleanParameter(req, "love")).isFalse();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue