Search in sources :

Example 1 with Injector

use of com.developmentontheedge.be5.env.Injector in project be5 by DevelopmentOnTheEdge.

the class DocumentTest method generate.

@Test
public void generate() {
    Response response = mock(Response.class);
    component.generate(getSpyMockRequest("", ImmutableMap.of(RestApiConstants.ENTITY, "testtable", RestApiConstants.TIMESTAMP_PARAM, "" + new Date().getTime(), RestApiConstants.QUERY, "All records")), response, injector);
    verify(response).sendAsJson(any(JsonApiModel.class));
}
Also used : Response(com.developmentontheedge.be5.api.Response) JsonApiModel(com.developmentontheedge.be5.model.jsonapi.JsonApiModel) Date(java.util.Date) Test(org.junit.Test) SqlMockOperationTest(com.developmentontheedge.be5.test.SqlMockOperationTest)

Example 2 with Injector

use of com.developmentontheedge.be5.env.Injector in project be5 by DevelopmentOnTheEdge.

the class DownloadComponentTest method test.

@Test
@Ignore
public void test() {
    Response response = mock(Response.class);
    Request req = getSpyMockRequest("", ImmutableMap.<String, String>builder().put("_t_", "attachments").put("_typeColumn_", "mimeType").put("_charsetColumn_", "mimeCharset").put("_filenameColumn_", "name").put("_dataColumn_", "data").put("_download_", "no").put("ID", "7326").build());
    component.generate(req, response, injector);
}
Also used : Response(com.developmentontheedge.be5.api.Response) Request(com.developmentontheedge.be5.api.Request) Ignore(org.junit.Ignore) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Example 3 with Injector

use of com.developmentontheedge.be5.env.Injector in project be5 by DevelopmentOnTheEdge.

the class MenuTest method test.

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

Example 4 with Injector

use of com.developmentontheedge.be5.env.Injector 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 5 with Injector

use of com.developmentontheedge.be5.env.Injector 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)

Aggregations

Test (org.junit.Test)23 Be5ProjectTest (com.developmentontheedge.be5.test.Be5ProjectTest)21 Response (com.developmentontheedge.be5.api.Response)20 ResourceData (com.developmentontheedge.be5.model.jsonapi.ResourceData)7 Action (com.developmentontheedge.be5.model.Action)6 ErrorModel (com.developmentontheedge.be5.model.jsonapi.ErrorModel)5 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)4 UserAwareMeta (com.developmentontheedge.be5.api.helpers.UserAwareMeta)4 StaticPagePresentation (com.developmentontheedge.be5.model.StaticPagePresentation)4 JsonApiModel (com.developmentontheedge.be5.model.jsonapi.JsonApiModel)4 Request (com.developmentontheedge.be5.api.Request)3 DocumentGenerator (com.developmentontheedge.be5.query.DocumentGenerator)3 Map (java.util.Map)3 UserHelper (com.developmentontheedge.be5.api.helpers.UserHelper)2 Injector (com.developmentontheedge.be5.env.Injector)2 Project (com.developmentontheedge.be5.metadata.model.Project)2 Query (com.developmentontheedge.be5.metadata.model.Query)2 TableModel (com.developmentontheedge.be5.query.impl.model.TableModel)2 SqlMockOperationTest (com.developmentontheedge.be5.test.SqlMockOperationTest)2 HashUrl (com.developmentontheedge.be5.util.HashUrl)2