/** * getResult * @return response's body as a play framework Result * @throws Exception */ @JsonIgnore public Result getResult () throws Exception { if (this.getType() == ResponseType.JSON) { return Results.ok((String)this.getContent() ); } else if (this.getType() == ResponseType.FILE) { return Results.ok(new FileInputStream((String)this.getContent() ) ); } else if (this.getType() == ResponseType.HTML) { return Results.ok((Content)this.getContent() ); } throw new CodeException( 151, 12, "Unhandled ResponseBody Type [" + this.getType().toString() + "]", ExceptionClass.TYPE); }
/** * Illustrates how to render a template for testing. */ @Test public void renderTemplate() { Content html = views.html.index.render("Welcome to the home page."); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("home page"); }
@Test public void renderTemplate() { Content html = views.html.index.render(Collections.<Resource>emptyList(), Form.form(Resource.class)); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains(Messages.get("header")); }
/** * Illustrates how to render a template for testing. */ @Test public void renderTemplate() { Content html = views.html.Index.render("Welcome to the home page."); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("home page"); }
@Test public void renderTemplate() { Content html = views.html.index.render("Your new application is ready."); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("Your new application is ready."); }
@Test public void renderIndex() { Content html = views.html.index.render(Observation.all(),Country.all(),Indicator.all()); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("ObservaTerra"); }
@Test public void renderIndex() { Content html = views.html.index2.render(); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("ObservaTerra"); }
@Test public void renderLogin() { Content html = views.html.index2.render(); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("ObservaTerra"); }
@Test public void renderObservationsList() { Content html = views.html.login.loginform.render(loginForm); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("ObservaTerra"); }
@Test public void renderProfile() { Content html = views.html.profile.render("admin");//Just a test, you should be logged in... assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("div"); }
@Test public void renderSignUp() { Content html = views.html.signup.form.render(signupForm); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("Sign"); }
@Test public void renderSummary(){ Content html = views.html.signup.summary.render(new User());//empty user => empty summary, but it renders... assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains("ObservaTerra"); }
@Test public void renderTemplate() { Content html = views.html.index.render(Messages.get("application.name")); assertThat(contentType(html)).isEqualTo("text/html"); assertThat(contentAsString(html)).contains(Messages.get("application.name")); }
/** * setHtmlContent * alternative to overriding the method below * setHtmlContent (Object... args) * this method can be directly called instead * @param htmlContent * @throws Exception */ @JsonIgnore final public void setHtmlContent (Content htmlContent) throws Exception { this.content = htmlContent; }