Search in sources :

Example 31 with Response

use of com.developmentontheedge.be5.api.Response in project be5 by DevelopmentOnTheEdge.

the class MenuTest method testDefaultActionAdmin.

@Test
public void testDefaultActionAdmin() {
    initUserWithRoles(RoleType.ROLE_ADMINISTRATOR, RoleType.ROLE_SYSTEM_DEVELOPER);
    Response response = mock(Response.class);
    component.generate(getMockRequest("defaultAction"), response, injector);
    verify(response).sendAsRawJson(eq(new Action("call", "table/testtableAdmin/All records")));
    initUserWithRoles(RoleType.ROLE_GUEST);
}
Also used : Response(com.developmentontheedge.be5.api.Response) Action(com.developmentontheedge.be5.model.Action) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Example 32 with Response

use of com.developmentontheedge.be5.api.Response in project be5 by DevelopmentOnTheEdge.

the class MenuTest method testUnknownAction.

@Test
public void testUnknownAction() {
    Response response = mock(Response.class);
    component.generate(getMockRequest("foo"), response, injector);
    verify(response).sendUnknownActionError();
}
Also used : Response(com.developmentontheedge.be5.api.Response) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Example 33 with Response

use of com.developmentontheedge.be5.api.Response in project be5 by DevelopmentOnTheEdge.

the class MenuTest method testDefaultActionTestUser2.

@Test
public void testDefaultActionTestUser2() {
    initUserWithRoles("TestUser2");
    Response response = mock(Response.class);
    component.generate(getMockRequest("defaultAction"), response, injector);
    verify(response).sendAsRawJson(eq(new Action("call", "table/atest/Test1")));
    initUserWithRoles(RoleType.ROLE_GUEST);
}
Also used : Response(com.developmentontheedge.be5.api.Response) Action(com.developmentontheedge.be5.model.Action) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Example 34 with Response

use of com.developmentontheedge.be5.api.Response in project be5 by DevelopmentOnTheEdge.

the class StaticPageComponentTest method generate.

@Test
public void generate() throws Exception {
    Response response = mock(Response.class);
    String page = "info.be";
    Request req = getSpyMockRequest(page, ImmutableMap.of(TIMESTAMP_PARAM, "123456789"));
    component.generate(req, response, injector);
    // todo         verify(response).sendAsJson(eq(new ResourceData(STATIC_ACTION,
    // new StaticPagePresentation("", "<h1>Info</h1><p>Test text.</p>"))),
    // eq(ImmutableMap.of(TIMESTAMP_PARAM, "123456789")),
    // eq(Collections.singletonMap(SELF_LINK, "static/" + page)));
    verify(response).sendAsJson(any(ResourceData.class), any(Map.class));
}
Also used : Response(com.developmentontheedge.be5.api.Response) ResourceData(com.developmentontheedge.be5.model.jsonapi.ResourceData) Request(com.developmentontheedge.be5.api.Request) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Aggregations

Response (com.developmentontheedge.be5.api.Response)23 Test (org.junit.Test)22 Be5ProjectTest (com.developmentontheedge.be5.test.Be5ProjectTest)20 Request (com.developmentontheedge.be5.api.Request)6 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)5 ErrorModel (com.developmentontheedge.be5.model.jsonapi.ErrorModel)5 ResourceData (com.developmentontheedge.be5.model.jsonapi.ResourceData)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 Action (com.developmentontheedge.be5.model.Action)4 JsonApiModel (com.developmentontheedge.be5.model.jsonapi.JsonApiModel)3 Map (java.util.Map)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 UserAwareMeta (com.developmentontheedge.be5.api.helpers.UserAwareMeta)2 UserHelper (com.developmentontheedge.be5.api.helpers.UserHelper)2 ResponseImpl (com.developmentontheedge.be5.api.impl.ResponseImpl)2 DocumentGenerator (com.developmentontheedge.be5.query.DocumentGenerator)2 SqlMockOperationTest (com.developmentontheedge.be5.test.SqlMockOperationTest)2 HashUrl (com.developmentontheedge.be5.util.HashUrl)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Date (java.util.Date)2