-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(kotlin): migration of the UpdateScheduled to Kotlin
- Loading branch information
1 parent
edb8fc9
commit 217d253
Showing
5 changed files
with
57 additions
and
60 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
28 changes: 0 additions & 28 deletions
28
backend/src/main/java/lan/dk/podcastserver/scheduled/UpdateScheduled.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
backend/src/main/kotlin/com/github/davinkevin/podcastserver/scheduled/UpdateScheduled.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,24 @@ | ||
package com.github.davinkevin.podcastserver.scheduled | ||
|
||
import lan.dk.podcastserver.business.update.UpdatePodcastBusiness | ||
import lan.dk.podcastserver.manager.ItemDownloadManager | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.scheduling.annotation.Scheduled | ||
import org.springframework.stereotype.Component | ||
|
||
/** | ||
* Created by kevin on 26/12/2013. | ||
*/ | ||
@Component | ||
class UpdateScheduled(val updatePodcastBusiness: UpdatePodcastBusiness, val idm: ItemDownloadManager) { | ||
|
||
private val log = LoggerFactory.getLogger(this.javaClass.name)!! | ||
|
||
@Scheduled(cron = "\${podcastserver.update-and-download.refresh.cron:0 0 * * * *}") | ||
fun updateAndDownloadPodcast() { | ||
log.info(">>> Beginning of the update <<<") | ||
updatePodcastBusiness.updatePodcast() | ||
idm.launchDownload() | ||
log.info(">>> End of the update <<<") | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
backend/src/test/java/lan/dk/podcastserver/scheduled/UpdateScheduledTest.java
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
backend/src/test/kotlin/com/github/davinkevin/podcastserver/scheduled/UpdateScheduledTest.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,32 @@ | ||
package com.github.davinkevin.podcastserver.scheduled | ||
|
||
import com.github.davinkevin.podcastserver.scheduled.UpdateScheduled | ||
import lan.dk.podcastserver.business.update.UpdatePodcastBusiness | ||
import lan.dk.podcastserver.manager.ItemDownloadManager | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.mockito.InjectMocks | ||
import org.mockito.Mock | ||
import org.mockito.Mockito.times | ||
import org.mockito.Mockito.verify | ||
import org.mockito.junit.jupiter.MockitoExtension | ||
|
||
/** | ||
* Created by kevin on 17/08/15 for Podcast Server | ||
*/ | ||
@ExtendWith(MockitoExtension::class) | ||
class UpdateScheduledTest { | ||
|
||
@Mock lateinit var updatePodcastBusiness: UpdatePodcastBusiness | ||
@Mock lateinit var IDM: ItemDownloadManager | ||
@InjectMocks lateinit var updateScheduled: UpdateScheduled | ||
|
||
@Test | ||
fun should_update_and_download() { | ||
/* When */ | ||
updateScheduled.updateAndDownloadPodcast() | ||
/* Then */ | ||
verify(updatePodcastBusiness, times(1)).updatePodcast() | ||
verify(IDM, times(1)).launchDownload() | ||
} | ||
} |