-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor/remove-org.reflections.reflections-dependency
- Utilized JPA's Metamodel API to retrieve all managed entity classes. - Prefixed instance variables and methods with `this.` to enhance code clarity. - Rename `AbstractIntegrationTest` to `IntegrationTestUtil`, and make its methods public so it can be used without requiring class inheritance. - Move `createNewArticle` method from `ArticlesResourceIntegrationTest` to `IntegrationTestUtil`. Signed-off-by: Pedro Aguiar <[email protected]>
- Loading branch information
1 parent
1d17379
commit 366974b
Showing
8 changed files
with
349 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
src/test/java/org/example/realworldapi/DatabaseIntegrationTest.java
This file was deleted.
Oops, something went wrong.
270 changes: 170 additions & 100 deletions
270
src/test/java/org/example/realworldapi/integration/ArticlesResourceIntegrationTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,28 @@ | |
import static org.example.realworldapi.constants.TestConstants.*; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import io.quarkus.test.TestTransaction; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.core.MediaType; | ||
import org.apache.http.HttpStatus; | ||
import org.example.realworldapi.AbstractIntegrationTest; | ||
import org.example.realworldapi.util.IntegrationTestUtil; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@QuarkusTest | ||
public class ProfilesResourceIntegrationTest extends AbstractIntegrationTest { | ||
@TestTransaction | ||
public class ProfilesResourceIntegrationTest { | ||
|
||
@Inject IntegrationTestUtil integrationTestUtil; | ||
|
||
private final String PROFILES_PATH = API_PREFIX + "/profiles"; | ||
|
||
@Test | ||
public void | ||
givenExistentUser_whenExecuteGetProfileEndpointWithoutAuth_shouldReturnAUserProfile() { | ||
|
||
final var existentUser = createUserEntity("user1", "[email protected]", "bio", "image", "user123"); | ||
final var existentUser = | ||
integrationTestUtil.createUserEntity("user1", "[email protected]", "bio", "image", "user123"); | ||
|
||
given() | ||
.contentType(MediaType.APPLICATION_JSON) | ||
|
@@ -44,14 +50,18 @@ public class ProfilesResourceIntegrationTest extends AbstractIntegrationTest { | |
givenExistentUserWithFollows_whenExecuteGetProfileEndpointWithAuth_shouldReturnAUserProfileWithFollowingTrue() { | ||
|
||
final var loggedUser = | ||
createUserEntity("loggeduser", "[email protected]", "bio", "image", "user123"); | ||
final var user = createUserEntity("user", "[email protected]", "bio", "image", "user123"); | ||
integrationTestUtil.createUserEntity( | ||
"loggeduser", "[email protected]", "bio", "image", "user123"); | ||
final var user = | ||
integrationTestUtil.createUserEntity("user", "[email protected]", "bio", "image", "user123"); | ||
|
||
follow(loggedUser, user); | ||
integrationTestUtil.follow(loggedUser, user); | ||
|
||
given() | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.header(AUTHORIZATION_HEADER, AUTHORIZATION_HEADER_VALUE_PREFIX + token(loggedUser)) | ||
.header( | ||
AUTHORIZATION_HEADER, | ||
AUTHORIZATION_HEADER_VALUE_PREFIX + integrationTestUtil.token(loggedUser)) | ||
.get(PROFILES_PATH + "/" + user.getUsername()) | ||
.then() | ||
.statusCode(HttpStatus.SC_OK) | ||
|
@@ -73,12 +83,16 @@ public class ProfilesResourceIntegrationTest extends AbstractIntegrationTest { | |
givenExistentUserWithoutFollows_whenExecuteGetProfileEndpointWithAuth_shouldReturnAUserProfileWithFollowingFalse() { | ||
|
||
final var loggedUser = | ||
createUserEntity("loggeduser", "[email protected]", "bio", "image", "user123"); | ||
final var user = createUserEntity("user", "[email protected]", "bio", "image", "user123"); | ||
integrationTestUtil.createUserEntity( | ||
"loggeduser", "[email protected]", "bio", "image", "user123"); | ||
final var user = | ||
integrationTestUtil.createUserEntity("user", "[email protected]", "bio", "image", "user123"); | ||
|
||
given() | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.header(AUTHORIZATION_HEADER, AUTHORIZATION_HEADER_VALUE_PREFIX + token(loggedUser)) | ||
.header( | ||
AUTHORIZATION_HEADER, | ||
AUTHORIZATION_HEADER_VALUE_PREFIX + integrationTestUtil.token(loggedUser)) | ||
.get(PROFILES_PATH + "/" + user.getUsername()) | ||
.then() | ||
.statusCode(HttpStatus.SC_OK) | ||
|
@@ -99,13 +113,17 @@ public class ProfilesResourceIntegrationTest extends AbstractIntegrationTest { | |
public void | ||
givenExistentUsers_whenExecuteFollowEndpoint_shouldReturnProfileWithFollowingFieldTrue() { | ||
|
||
final var user = createUserEntity("user", "[email protected]", "bio", "image", "user123"); | ||
final var user = | ||
integrationTestUtil.createUserEntity("user", "[email protected]", "bio", "image", "user123"); | ||
final var loggedUser = | ||
createUserEntity("loggeduser", "[email protected]", "bio", "image", "user123"); | ||
integrationTestUtil.createUserEntity( | ||
"loggeduser", "[email protected]", "bio", "image", "user123"); | ||
|
||
given() | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.header(AUTHORIZATION_HEADER, AUTHORIZATION_HEADER_VALUE_PREFIX + token(loggedUser)) | ||
.header( | ||
AUTHORIZATION_HEADER, | ||
AUTHORIZATION_HEADER_VALUE_PREFIX + integrationTestUtil.token(loggedUser)) | ||
.post(PROFILES_PATH + "/" + user.getUsername() + "/follow") | ||
.then() | ||
.statusCode(HttpStatus.SC_OK) | ||
|
@@ -126,15 +144,19 @@ public class ProfilesResourceIntegrationTest extends AbstractIntegrationTest { | |
public void | ||
givenExistentUserWithFollower_whenExecuteUnfollowEndpoint_shouldReturnProfileWithFollowingFieldFalse() { | ||
|
||
final var user = createUserEntity("user", "[email protected]", "bio", "image", "user123"); | ||
final var user = | ||
integrationTestUtil.createUserEntity("user", "[email protected]", "bio", "image", "user123"); | ||
final var loggedUser = | ||
createUserEntity("loggeduser", "[email protected]", "bio", "image", "user123"); | ||
integrationTestUtil.createUserEntity( | ||
"loggeduser", "[email protected]", "bio", "image", "user123"); | ||
|
||
follow(loggedUser, user); | ||
integrationTestUtil.follow(loggedUser, user); | ||
|
||
given() | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.header(AUTHORIZATION_HEADER, AUTHORIZATION_HEADER_VALUE_PREFIX + token(loggedUser)) | ||
.header( | ||
AUTHORIZATION_HEADER, | ||
AUTHORIZATION_HEADER_VALUE_PREFIX + integrationTestUtil.token(loggedUser)) | ||
.delete(PROFILES_PATH + "/" + user.getUsername() + "/follow") | ||
.then() | ||
.statusCode(HttpStatus.SC_OK) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.