Search in sources :

Example 1 with Action

use of com.developmentontheedge.be5.model.Action in project be5 by DevelopmentOnTheEdge.

the class MenuTest method testGenerateSimpleMenu.

@Test
public void testGenerateSimpleMenu() {
    initUserWithRoles("User");
    Menu menu = (Menu) component;
    Menu.MenuResponse menuResponse = menu.generateSimpleMenu(injector, EntityType.TABLE);
    assertEquals("testtable", menuResponse.root.get(1).getTitle());
    assertEquals(new Action("call", "table/testtable/All records"), menuResponse.root.get(1).getAction());
    assertNull(menuResponse.root.get(1).getChildren());
}
Also used : Action(com.developmentontheedge.be5.model.Action) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Example 2 with Action

use of com.developmentontheedge.be5.model.Action in project be5 by DevelopmentOnTheEdge.

the class MenuTest method testGenerateSimpleMenuAdmin.

@Test
public void testGenerateSimpleMenuAdmin() {
    initUserWithRoles(RoleType.ROLE_ADMINISTRATOR, RoleType.ROLE_SYSTEM_DEVELOPER);
    Menu menu = (Menu) component;
    Menu.MenuResponse menuResponse = menu.generateSimpleMenu(injector, EntityType.TABLE);
    assertEquals("Добавить", menuResponse.root.get(1).getOperations().get(0).title);
    assertEquals(new Action("call", "form/dateTime/All records/Insert"), menuResponse.root.get(1).getOperations().get(0).action);
    initUserWithRoles(RoleType.ROLE_GUEST);
}
Also used : Action(com.developmentontheedge.be5.model.Action) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Example 3 with Action

use of com.developmentontheedge.be5.model.Action in project be5 by DevelopmentOnTheEdge.

the class MenuTest method testDefaultAction.

@Test
public void testDefaultAction() {
    Response response = mock(Response.class);
    component.generate(getMockRequest("defaultAction"), response, injector);
    verify(response).sendAsRawJson(eq(new Action("call", "table/testtable/All records")));
}
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 4 with Action

use of com.developmentontheedge.be5.model.Action in project be5 by DevelopmentOnTheEdge.

the class MenuTest method testDefaultActionUser.

@Test
public void testDefaultActionUser() {
    initUserWithRoles("User");
    Response response = mock(Response.class);
    component.generate(getMockRequest("defaultAction"), response, injector);
    verify(response).sendAsRawJson(eq(new Action("call", "table/testtUser/testtUser")));
    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 5 with Action

use of com.developmentontheedge.be5.model.Action in project be5 by DevelopmentOnTheEdge.

the class ResponseTest method sendAsRawJson.

// @Test
// public void sendErrorsAsJson() throws Exception {
// Action call = new Action("call", "test/path");
// response.sendErrorsAsJson(call);
// 
// verify(writer).append(doubleQuotes("{'value':{'arg':'test/path','name':'call'}}"));
// verify(writer).flush();
// }
@Test
public void sendAsRawJson() {
    Action call = new Action("call", "test/path");
    response.sendAsRawJson(call);
    verify(writer).append(doubleQuotes("{'arg':'test/path','name':'call'}"));
}
Also used : Action(com.developmentontheedge.be5.model.Action) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Aggregations

Action (com.developmentontheedge.be5.model.Action)10 Be5ProjectTest (com.developmentontheedge.be5.test.Be5ProjectTest)7 Test (org.junit.Test)7 Response (com.developmentontheedge.be5.api.Response)4 Operation (com.developmentontheedge.be5.metadata.model.Operation)2 Query (com.developmentontheedge.be5.metadata.model.Query)2 UserAwareMeta (com.developmentontheedge.be5.api.helpers.UserAwareMeta)1 TableOperationPresentation (com.developmentontheedge.be5.model.TableOperationPresentation)1 Operation (com.developmentontheedge.be5.operation.Operation)1 TransactionalOperation (com.developmentontheedge.be5.operation.TransactionalOperation)1 TableBuilder (com.developmentontheedge.be5.query.TableBuilder)1 ArrayList (java.util.ArrayList)1