Skip to content

Instantly share code, notes, and snippets.

@eliasnogueira
Created March 20, 2021 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliasnogueira/df0ca2cff0380b51a947a7e0c35aa85c to your computer and use it in GitHub Desktop.
Save eliasnogueira/df0ca2cff0380b51a947a7e0c35aa85c to your computer and use it in GitHub Desktop.
Example of an object being used in a post request as a String
class PostTest {
@Test
void postUsingStringConcatenation() {
String user = "{\"name\":\"Elias\",\"job\":\"Principal Engineer\"}";
given().
contentType(ContentType.JSON).
body(user).
when().
post("/users").
then().
statusCode(HttpStatus.SC_CREATED).
body(
"name", is("Elias"),
"job", is("Principal Engineer"),
"id", notNullValue(),
"createdAt", notNullValue()
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment