This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new cc8f5e2 Idiomatic Mustache test new 123a3b5 Merge pull request #1204 from ppalaga/200509-idiomatic-mustache-tests cc8f5e2 is described below commit cc8f5e2d63d60ce22d82db90dbbee74a481c63c0 Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Sat May 9 10:11:39 2020 +0200 Idiomatic Mustache test --- .../component/mustache/it/MustacheResource.java | 36 +++++------ .../component/mustache/it/MustacheTest.java | 72 +++++++++++++--------- 2 files changed, 61 insertions(+), 47 deletions(-) diff --git a/integration-tests/mustache/src/main/java/org/apache/camel/quarkus/component/mustache/it/MustacheResource.java b/integration-tests/mustache/src/main/java/org/apache/camel/quarkus/component/mustache/it/MustacheResource.java index d827943..71cdd26 100644 --- a/integration-tests/mustache/src/main/java/org/apache/camel/quarkus/component/mustache/it/MustacheResource.java +++ b/integration-tests/mustache/src/main/java/org/apache/camel/quarkus/component/mustache/it/MustacheResource.java @@ -38,59 +38,59 @@ public class MustacheResource { @Inject ProducerTemplate template; - @Path("/applyMustacheTemplateFromClassPathResource") + @Path("/templateFromClassPathResource") @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) - public String applyMustacheTemplateFromClassPathResource(String message) { - LOG.infof("Calling applyMustacheTemplateFromClassPathResource with %s", message); + public String templateFromClassPathResource(String message) { + LOG.infof("Calling templateFromClassPathResource with %s", message); return template.requestBodyAndHeader("mustache://template/simple.mustache", message, "header", "value", String.class); } - @Path("/applyMustacheTemplateFromHeader") + @Path("/templateFromHeader") @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) - public String applyMustacheTemplateFromHeader(String message) { - LOG.infof("Calling applyMustacheTemplateFromHeader with %s", message); + public String templateFromHeader(String message) { + LOG.infof("Calling templateFromHeader with %s", message); return template.requestBodyAndHeader("mustache://template/simple.mustache", message, MustacheConstants.MUSTACHE_TEMPLATE, "Body='{{body}}'", String.class); } - @Path("/applyMustacheTemplateUriFromHeader") + @Path("/templateUriFromHeader") @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) - public String applyMustacheTemplateUriFromHeader(String message) { - LOG.infof("Calling applyMustacheTemplateUriFromHeader with %s", message); + public String templateUriFromHeader(String message) { + LOG.infof("Calling templateUriFromHeader with %s", message); return template.requestBodyAndHeader("mustache://template/simple.mustache", message, MustacheConstants.MUSTACHE_RESOURCE_URI, "/template/another.mustache", String.class); } - @Path("/applyMustacheTemplateWithInheritance") + @Path("/templateWithInheritance") @GET @Produces(MediaType.TEXT_PLAIN) - public String applyMustacheTemplateWithInheritance() { - LOG.infof("Calling applyMustacheTemplateWithInheritance"); + public String templateWithInheritance() { + LOG.infof("Calling templateWithInheritance"); return template.requestBody("mustache://template/child.mustache", null, String.class); } - @Path("/applyMustacheTemplateWithPartials") + @Path("/templateWithPartials") @GET @Produces(MediaType.TEXT_PLAIN) - public String applyMustacheTemplateWithPartials() { - LOG.infof("Calling applyMustacheTemplateWithPartials"); + public String templateWithPartials() { + LOG.infof("Calling templateWithPartials"); return template.requestBody("mustache://template/includer.mustache", null, String.class); } - @Path("/applyMustacheTemplateFromRegistry") + @Path("/templateFromRegistry") @POST @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) - public String applyMustacheTemplateFromRegistry(String message) { - LOG.infof("Calling applyMustacheTemplateFromRegistry with %s", message); + public String templateFromRegistry(String message) { + LOG.infof("Calling templateFromRegistry with %s", message); return template.requestBody("mustache://ref:templateFromRegistry", message, String.class); } } diff --git a/integration-tests/mustache/src/test/java/org/apache/camel/quarkus/component/mustache/it/MustacheTest.java b/integration-tests/mustache/src/test/java/org/apache/camel/quarkus/component/mustache/it/MustacheTest.java index 0431234..b3fb48c 100644 --- a/integration-tests/mustache/src/test/java/org/apache/camel/quarkus/component/mustache/it/MustacheTest.java +++ b/integration-tests/mustache/src/test/java/org/apache/camel/quarkus/component/mustache/it/MustacheTest.java @@ -21,54 +21,68 @@ import io.restassured.RestAssured; import io.restassured.http.ContentType; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.Matchers.is; @QuarkusTest class MustacheTest { @Test - void applyMustacheTemplateFromClassPathResourceShouldSucceed() { - String response = RestAssured.given().contentType(ContentType.TEXT).body("FromClassPath") - .post("/mustache/applyMustacheTemplateFromClassPathResource").then().statusCode(200) - .extract().asString(); - assertEquals("\nMessage with body 'FromClassPath' and some header 'value'", response); + void templateFromClassPathResource() { + RestAssured.given() + .contentType(ContentType.TEXT) + .body("FromClassPath") + .post("/mustache/templateFromClassPathResource") + .then() + .statusCode(200) + .body(is("\nMessage with body 'FromClassPath' and some header 'value'")); } @Test - void applyMustacheTemplateFromHeaderShouldSucceed() { - String response = RestAssured.given().contentType(ContentType.TEXT).body("FromHeader") - .post("/mustache/applyMustacheTemplateFromHeader").then().statusCode(200).extract() - .asString(); - assertEquals("Body='FromHeader'", response); + void templateFromHeader() { + RestAssured.given() + .contentType(ContentType.TEXT) + .body("FromHeader") + .post("/mustache/templateFromHeader") + .then() + .statusCode(200) + .body(is("Body='FromHeader'")); } @Test - void applyMustacheTemplateUriFromHeaderShouldSucceed() { - String response = RestAssured.given().contentType(ContentType.TEXT).body("UriFromHeader") - .post("/mustache/applyMustacheTemplateUriFromHeader").then().statusCode(200).extract() - .asString(); - assertEquals("\nAnother body 'UriFromHeader'!", response); + void templateUriFromHeader() { + RestAssured.given() + .contentType(ContentType.TEXT) + .body("UriFromHeader") + .post("/mustache/templateUriFromHeader") + .then() + .statusCode(200) + .body(is("\nAnother body 'UriFromHeader'!")); } @Test - void applyMustacheTemplateWithInheritanceShouldSucceed() { - String response = RestAssured.get("/mustache/applyMustacheTemplateWithInheritance").then().statusCode(200).extract() - .asString(); - assertEquals("\n\nStart ContentFrom(Child) End", response); + void templateWithInheritance() { + RestAssured.get("/mustache/templateWithInheritance") + .then() + .statusCode(200) + .body(is("\n\nStart ContentFrom(Child) End")); } @Test - void applyMustacheTemplateWithPartialsShouldSucceed() { - String response = RestAssured.get("/mustache/applyMustacheTemplateWithPartials").then().statusCode(200).extract() - .asString(); - assertEquals("\nStart-\nIncluded-End", response); + void templateWithPartials() { + RestAssured.get("/mustache/templateWithPartials") + .then() + .statusCode(200) + .body(is("\nStart-\nIncluded-End")); } @Test - void applyMustacheTemplateFromRegistryShouldSucceed() { - String response = RestAssured.given().contentType(ContentType.TEXT).body("Entry") - .post("/mustache/applyMustacheTemplateFromRegistry").then().statusCode(200).extract() - .asString(); - assertEquals("Begin-FromRegistry-Entry-End", response); + void templateFromRegistry() { + RestAssured.given() + .contentType(ContentType.TEXT) + .body("Entry") + .post("/mustache/templateFromRegistry") + .then() + .statusCode(200) + .body(is("Begin-FromRegistry-Entry-End")); } }