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());
}
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));
}
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));
}
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);
}
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));
}
Aggregations