use of io.vertx.ext.web.validation.impl.parameter.ParameterProcessorImpl in project vertx-web by vert-x3.
the class ParameterProcessorUnitTest method testRequiredParam.
@Test
public void testRequiredParam() {
ParameterProcessor processor = new ParameterProcessorImpl("myParam", ParameterLocation.QUERY, false, mockedParser, mockedValidator);
when(mockedParser.parseParameter(any())).thenReturn(null);
assertThatCode(() -> processor.process(new HashMap<>())).isInstanceOf(ParameterProcessorException.class).hasFieldOrPropertyWithValue("errorType", ParameterProcessorException.ParameterProcessorErrorType.MISSING_PARAMETER_WHEN_REQUIRED_ERROR).hasFieldOrPropertyWithValue("location", ParameterLocation.QUERY).hasFieldOrPropertyWithValue("parameterName", "myParam").hasNoCause();
}
use of io.vertx.ext.web.validation.impl.parameter.ParameterProcessorImpl in project vertx-web by vert-x3.
the class ParameterProcessorUnitTest method testOptionalParamWithDefault.
@Test
public void testOptionalParamWithDefault(VertxTestContext testContext) {
ParameterProcessor processor = new ParameterProcessorImpl("myParam", ParameterLocation.QUERY, true, mockedParser, mockedValidator);
when(mockedParser.parseParameter(any())).thenReturn(null);
when(mockedValidator.getDefault()).thenReturn(Future.succeededFuture("bla"));
processor.process(new HashMap<>()).onComplete(testContext.succeeding(value -> {
testContext.verify(() -> assertThat(value.getString()).isEqualTo("bla"));
testContext.completeNow();
}));
}
Aggregations