Search in sources :

Example 1 with RequestURIDecorator

use of com.tvd12.ezyhttp.server.core.handler.RequestURIDecorator in project ezyhttp by youngmonkeys.

the class RequestHandlersImplementerTest method implementOneWithURIDecorator.

@Test
public void implementOneWithURIDecorator() {
    // given
    RequestHandlersImplementer sut = new RequestHandlersImplementer();
    Controller controller = new Controller();
    RequestHandlerManager manager = new RequestHandlerManager();
    manager.setAllowOverrideURI(true);
    RequestURIDecorator requestURIDecorator = mock(RequestURIDecorator.class);
    when(requestURIDecorator.decorate(any(), any())).thenReturn("hello-world");
    sut.setRequestURIDecorator(requestURIDecorator);
    // when
    manager.addHandlers(sut.implement(Collections.singletonList(controller)));
    // then
    RequestURI uri = new RequestURI(HttpMethod.GET, "/hello-world", false);
    Asserts.assertThat(manager.getHandlerListByURI().get(uri).size()).isEqualsTo(2);
}
Also used : RequestHandlersImplementer(com.tvd12.ezyhttp.server.core.asm.RequestHandlersImplementer) RequestHandlerManager(com.tvd12.ezyhttp.server.core.manager.RequestHandlerManager) RequestURI(com.tvd12.ezyhttp.server.core.request.RequestURI) RequestURIDecorator(com.tvd12.ezyhttp.server.core.handler.RequestURIDecorator) Test(org.testng.annotations.Test)

Aggregations

RequestHandlersImplementer (com.tvd12.ezyhttp.server.core.asm.RequestHandlersImplementer)1 RequestURIDecorator (com.tvd12.ezyhttp.server.core.handler.RequestURIDecorator)1 RequestHandlerManager (com.tvd12.ezyhttp.server.core.manager.RequestHandlerManager)1 RequestURI (com.tvd12.ezyhttp.server.core.request.RequestURI)1 Test (org.testng.annotations.Test)1