Skip to content

Commit

Permalink
enhancements(test): Improve UserResourceTest and add JSONB dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
zZHorizonZz committed Jul 18, 2023
1 parent 7cb004a commit 733a3e1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
4 changes: 4 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-mutiny</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
package dev.shiperist.user.resource;

import dev.shiperist.user.model.request.CreateUserRequest;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;

@QuarkusTest
public class UserResourceTest {

private Jsonb jsonb = JsonbBuilder.create();

@Test
void createUser() {
String userCreateRequest = """
{
"name": "test",
"email": "[email protected]",
"isEmailVerified": true,
"image": "test"
}
""";
public void testCreateUserEndpoint() {
CreateUserRequest request = new CreateUserRequest();
request.setName("Test User");
request.setEmail("[email protected]");
request.setIsEmailVerified(LocalDateTime.now());
request.setImage("http://example.com/image.jpg");

String requestBody = jsonb.toJson(request);

given()
.when()
.body(userCreateRequest)
.post("/user/create")
.body(requestBody)
.header("Content-Type", ContentType.JSON)
.when().post("/create")
.then()
.statusCode(200);
.statusCode(200)
.body("name", is(request.getName()))
.body("email", is(request.getEmail()));
}
}

0 comments on commit 733a3e1

Please sign in to comment.