Search in sources :

Example 36 with Injector

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

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

Example 38 with Injector

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

the class Be5InjectorCyclicDependenciesWithAnnotatedTest method injectWithAnnotatedBServiceFirst.

@Test
public void injectWithAnnotatedBServiceFirst() throws Exception {
    Injector sqlMockInjector2 = Be5.createInjector(Stage.DEVELOPMENT, new SqlMockBinder());
    sqlMockInjector2.get(BService.class).bMethodUseAService();
    verify(SqlServiceMock.mock).update("aMethod sql");
    sqlMockInjector2.get(AService.class).aMethodUseBService();
    verify(SqlServiceMock.mock).update("bMethod sql");
}
Also used : Injector(com.developmentontheedge.be5.env.Injector) BService(com.developmentontheedge.be5.env.impl.testServices.BService) AService(com.developmentontheedge.be5.env.impl.testServices.AService) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Example 39 with Injector

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

the class TestUtils method initInjector.

static Injector initInjector(Binder binder) {
    Injector injector = Be5.createInjector(Stage.TEST, binder);
    Project project = injector.getProject();
    initProfile(project);
    injector.get(UserHelper.class).initGuest(null);
    return injector;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) UserHelper(com.developmentontheedge.be5.api.helpers.UserHelper) Injector(com.developmentontheedge.be5.env.Injector)

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