Search in sources :

Example 1 with Viewable

use of com.sun.jersey.api.view.Viewable in project activityinfo by bedatadriven.

the class ConfirmInviteControllerTest method emptyPasswordShouldNotBeAccepted.

@Test
public void emptyPasswordShouldNotBeAccepted() throws Exception {
    Response response = resource.confirm(RestMockUtils.mockUriInfo("http://www.activityinfo.org/confirm"), VALID_KEY, "fr", null, "Alex Bertram", false);
    Viewable viewable = (Viewable) response.getEntity();
    assertThat(viewable.getModel(), instanceOf(ConfirmInvitePageModel.class));
    ConfirmInvitePageModel model = (ConfirmInvitePageModel) viewable.getModel();
    assertTrue("error message set", model.isFormIncomplete());
}
Also used : Response(javax.ws.rs.core.Response) ConfirmInvitePageModel(org.activityinfo.server.login.model.ConfirmInvitePageModel) Viewable(com.sun.jersey.api.view.Viewable) Test(org.junit.Test)

Example 2 with Viewable

use of com.sun.jersey.api.view.Viewable in project activityinfo by bedatadriven.

the class ConfirmInviteControllerTest method requestWithValidKeyShouldGetView.

@Test
public void requestWithValidKeyShouldGetView() throws Exception {
    Viewable response = resource.getPage(RestMockUtils.mockUriInfo("http://www.activityinfo.org/confirm?xyz123"));
    assertThat(response.getModel(), instanceOf(ConfirmInvitePageModel.class));
}
Also used : ConfirmInvitePageModel(org.activityinfo.server.login.model.ConfirmInvitePageModel) Viewable(com.sun.jersey.api.view.Viewable) Test(org.junit.Test)

Example 3 with Viewable

use of com.sun.jersey.api.view.Viewable in project activityinfo by bedatadriven.

the class ConfirmInviteControllerTest method badKeyShouldGetProblemPage.

@Test
public void badKeyShouldGetProblemPage() throws Exception {
    Viewable response = resource.getPage(RestMockUtils.mockUriInfo("http://www.activityinfo.org/confirm?badkey"));
    assertThat(response.getModel(), instanceOf(InvalidInvitePageModel.class));
}
Also used : Viewable(com.sun.jersey.api.view.Viewable) InvalidInvitePageModel(org.activityinfo.server.login.model.InvalidInvitePageModel) Test(org.junit.Test)

Example 4 with Viewable

use of com.sun.jersey.api.view.Viewable in project activityinfo by bedatadriven.

the class BrandingConfigResource method getPage.

@GET
@Produces(MediaType.TEXT_HTML)
@Path("{host}")
public Viewable getPage(@InjectParam EntityManager em, @PathParam("host") String host) {
    Domain domain = em.find(Domain.class, host);
    if (domain == null) {
        domain = new Domain();
        domain.setHost(host);
    }
    Map<String, Object> model = Maps.newHashMap();
    model.put("customDomain", domain);
    return new Viewable("/page/BrandingConfig.ftl", model);
}
Also used : Viewable(com.sun.jersey.api.view.Viewable) Domain(org.activityinfo.server.database.hibernate.entity.Domain)

Example 5 with Viewable

use of com.sun.jersey.api.view.Viewable in project activityinfo by bedatadriven.

the class HostControllerTest method verifyThatRequestWithValidAuthTokensReceiveTheView.

@Test
public void verifyThatRequestWithValidAuthTokensReceiveTheView() throws Exception {
    authProvider.set(new AuthenticatedUser(VALID_TOKEN, 3, "akbertram@gmail.com"));
    HttpServletRequest req = createMock(HttpServletRequest.class);
    expect(req.getServerName()).andReturn("www.activityinfo.org");
    expect(req.getHeader("User-Agent")).andReturn(CHROME_USER_AGENT);
    replay(req);
    Response response = resource.getHostPage(RestMockUtils.mockUriInfo("http://www.activityinfo.org"), req, false, "oldui", null, null, null);
    assertThat(response.getEntity(), instanceOf(Viewable.class));
    assertThat(((Viewable) response.getEntity()).getModel(), instanceOf(HostPageModel.class));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Response(javax.ws.rs.core.Response) HostPageModel(org.activityinfo.server.login.model.HostPageModel) Viewable(com.sun.jersey.api.view.Viewable) AuthenticatedUser(org.activityinfo.legacy.shared.AuthenticatedUser) Test(org.junit.Test)

Aggregations

Viewable (com.sun.jersey.api.view.Viewable)5 Test (org.junit.Test)4 Response (javax.ws.rs.core.Response)2 ConfirmInvitePageModel (org.activityinfo.server.login.model.ConfirmInvitePageModel)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 AuthenticatedUser (org.activityinfo.legacy.shared.AuthenticatedUser)1 Domain (org.activityinfo.server.database.hibernate.entity.Domain)1 HostPageModel (org.activityinfo.server.login.model.HostPageModel)1 InvalidInvitePageModel (org.activityinfo.server.login.model.InvalidInvitePageModel)1