Search in sources :

Example 1 with ValidationImpl

use of ninja.validation.ValidationImpl in project ninja by ninjaframework.

the class BodyParserEnginePostTest method setUp.

@Before
public void setUp() {
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            bind(NinjaProperties.class).toInstance(new NinjaPropertiesImpl(NinjaMode.test));
            Multibinder<ParamParser> parsersBinder = Multibinder.newSetBinder(binder(), ParamParser.class);
            parsersBinder.addBinding().to(NeedingInjectionParamParser.class);
        }
    });
    validation = new ValidationImpl();
    Mockito.when(this.context.getValidation()).thenReturn(this.validation);
    bodyParserEnginePost = injector.getInstance(BodyParserEnginePost.class);
}
Also used : NinjaPropertiesImpl(ninja.utils.NinjaPropertiesImpl) ParamParser(ninja.params.ParamParser) NeedingInjectionParamParser(ninja.params.ControllerMethodInvokerTest.NeedingInjectionParamParser) Multibinder(com.google.inject.multibindings.Multibinder) Injector(com.google.inject.Injector) NeedingInjectionParamParser(ninja.params.ControllerMethodInvokerTest.NeedingInjectionParamParser) AbstractModule(com.google.inject.AbstractModule) ValidationImpl(ninja.validation.ValidationImpl) Before(org.junit.Before)

Example 2 with ValidationImpl

use of ninja.validation.ValidationImpl in project ninja by ninjaframework.

the class RouterImplTest method routeForSpecificInstanceMethodReferenceWithAnnotations.

@Test
public void routeForSpecificInstanceMethodReferenceWithAnnotations() {
    Context context = mock(Context.class);
    when(context.getParameter("status")).thenReturn("207");
    when(context.getValidation()).thenReturn(new ValidationImpl());
    Route route = router.getRouteFor("GET", "/specific_instance_method_ref_annotations");
    Result result = route.getFilterChain().next(context);
    // message set on specific instance
    assertThat(result.getStatusCode(), is(207));
    assertThat(result.getRenderable(), is("Hi!"));
}
Also used : ValidationImpl(ninja.validation.ValidationImpl) Test(org.junit.Test)

Example 3 with ValidationImpl

use of ninja.validation.ValidationImpl in project ninja by ninjaframework.

the class RouterImplTest method routeForAnonymoumsClassInstanceWithAnnotations.

@Test
public void routeForAnonymoumsClassInstanceWithAnnotations() {
    Context context = mock(Context.class);
    when(context.getParameter("status")).thenReturn("205");
    when(context.getValidation()).thenReturn(new ValidationImpl());
    Route route = router.getRouteFor("GET", "/anonymous_class_annotations");
    Result result = route.getFilterChain().next(context);
    assertThat(result.getStatusCode(), is(205));
}
Also used : ValidationImpl(ninja.validation.ValidationImpl) Test(org.junit.Test)

Aggregations

ValidationImpl (ninja.validation.ValidationImpl)3 Test (org.junit.Test)2 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 Multibinder (com.google.inject.multibindings.Multibinder)1 NeedingInjectionParamParser (ninja.params.ControllerMethodInvokerTest.NeedingInjectionParamParser)1 ParamParser (ninja.params.ParamParser)1 NinjaPropertiesImpl (ninja.utils.NinjaPropertiesImpl)1 Before (org.junit.Before)1