-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
023bb8b
commit 388cd68
Showing
1 changed file
with
15 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,26 +33,20 @@ class AuthorizationRegistrationServiceIT { | |
|
||
private static final String EMAIL_WUNDERLAND = "[email protected]"; | ||
|
||
private final User userWithNoOkrChampionInfo = User.Builder.builder() // | ||
.withFirstname("Alice") // | ||
.withLastname("Wunderland") // | ||
.withEmail(EMAIL_WUNDERLAND) // user.champion.emails from application-integration-test.properties | ||
.build(); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
TenantContext.setCurrentTenant(tenant); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() { | ||
resetOkrChampionStatus(userWithNoOkrChampionInfo.getEmail()); | ||
resetOkrChampionStatus(); | ||
clearCache(); | ||
TenantContext.setCurrentTenant(null); | ||
} | ||
|
||
private void resetOkrChampionStatus(String email) { | ||
Optional<User> userFromDb = userPersistenceService.findByEmail(email); | ||
private void resetOkrChampionStatus() { | ||
Optional<User> userFromDb = userPersistenceService.findByEmail(EMAIL_WUNDERLAND); | ||
assertTrue(userFromDb.isPresent()); | ||
|
||
userFromDb.get().setOkrChampion(false); | ||
|
@@ -116,23 +110,27 @@ void registerAuthorizationUser_shouldSetOkrChampionsToFalse() { | |
|
||
/* | ||
* Special test setup. <pre> - the user [email protected] is an existing user in the H2 db (created via | ||
* X_TestData.sql) - the user [email protected] is also defined in application-integration-test.properties as | ||
* user champion - with this combination we can test, that the user in the db (which has initial isOkrChampion == | ||
* false) is after calling updateOrAddAuthorizationUser() a user champion. - because the user [email protected] | ||
* exists before the test, we make no clean in db (we don't remove it) </pre> | ||
* V100_0_0__TestData.sql) - the user [email protected] is also defined in | ||
* application-integration-test.properties as user champion - with this combination we can test, that the user in | ||
* the db (which has initial isOkrChampion == false) is after calling updateOrAddAuthorizationUser() a user | ||
* champion. - the OkrChampion status must manually be reset (in the tearDown method) </pre> | ||
*/ | ||
@Test | ||
@DisplayName("registerAuthorizationUser for a user with an email defined in the application-integration-test.properties should set OkrChampions to true") | ||
void registerAuthorizationUserShouldSetOkrChampionsToTrue() { | ||
// arrange | ||
assertOkrChampionStatusInDb(userWithNoOkrChampionInfo.getEmail(), false); // pre-condition | ||
assertOkrChampionStatusInDb(EMAIL_WUNDERLAND, false); // pre-condition | ||
|
||
// act | ||
// load user from db (by email) and set OkrChampion status based on property | ||
// "okr.tenants.pitc.user.champion.emails" | ||
// from application-integration-test.properties file | ||
// "okr.tenants.pitc.user.champion.emails" from application-integration-test.properties file | ||
AuthorizationUser processedUser = authorizationRegistrationService | ||
.updateOrAddAuthorizationUser(userWithNoOkrChampionInfo); | ||
.updateOrAddAuthorizationUser(User.Builder.builder() // | ||
.withFirstname("Alice") // | ||
.withLastname("Wunderland") // | ||
.withEmail(EMAIL_WUNDERLAND) // user.champion.emails from | ||
// application-integration-test.properties | ||
.build()); | ||
|
||
// assert | ||
assertTrue(processedUser.user().isOkrChampion()); | ||
|