-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2592 [BE] job for deleting autotest contributors
- Loading branch information
Showing
7 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/epam/brn/job/AutoTestUsersDeletionJob.kt
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.epam.brn.job | ||
|
||
import com.epam.brn.service.UserAccountService | ||
import org.apache.logging.log4j.kotlin.logger | ||
import org.springframework.scheduling.annotation.Scheduled | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class AutoTestUsersDeletionJob(val userAccountService: UserAccountService) { | ||
private val log = logger() | ||
|
||
@Scheduled(cron = "\${autotest.users.deletion.cron}") | ||
fun deleteAutoTestUsers() { | ||
val usersCount = userAccountService.deleteAutoTestUsers() | ||
log.info("Deleted $usersCount autotest users") | ||
} | ||
} |
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
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
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
40 changes: 40 additions & 0 deletions
40
src/test/kotlin/com/epam/brn/job/AutoTestUsersDeletionJobTest.kt
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.epam.brn.job | ||
|
||
import com.epam.brn.repo.UserAccountRepository | ||
import com.epam.brn.service.impl.UserAccountServiceImpl | ||
import io.mockk.every | ||
import io.mockk.impl.annotations.InjectMockKs | ||
import io.mockk.impl.annotations.MockK | ||
import io.mockk.junit5.MockKExtension | ||
import io.mockk.verify | ||
import org.junit.jupiter.api.DisplayName | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.springframework.test.util.ReflectionTestUtils | ||
|
||
@DisplayName("AutoTestUsersDeletionJob test using MockK") | ||
@ExtendWith(MockKExtension::class) | ||
class AutoTestUsersDeletionJobTest { | ||
|
||
@InjectMockKs | ||
lateinit var autoTestUsersDeletionJob: AutoTestUsersDeletionJob | ||
|
||
@MockK | ||
lateinit var userAccountService: UserAccountServiceImpl | ||
|
||
@MockK | ||
lateinit var userAccountRepository: UserAccountRepository | ||
@Test | ||
fun deleteAutoTestUsers() { | ||
// GIVEN | ||
val prefix = "autotest" | ||
ReflectionTestUtils.setField(userAccountService, "prefix", prefix) | ||
every { userAccountService.deleteAutoTestUsers() } returns 2L | ||
|
||
// WHEN | ||
autoTestUsersDeletionJob.deleteAutoTestUsers() | ||
|
||
// THEN | ||
verify { userAccountService.deleteAutoTestUsers() } | ||
} | ||
} |
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
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