Skip to content

Commit

Permalink
refactor(kotlin): migration of the UpdateScheduled to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
davinkevin committed Oct 30, 2018
1 parent edb8fc9 commit 217d253
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

@Configuration
@EnableScheduling
@ComponentScan(basePackages = {"lan.dk.podcastserver.scheduled", "com.github.davinkevin.podcastserver.scheduled"})
@ComponentScan(basePackages = {"com.github.davinkevin.podcastserver.scheduled"})
public class SchedulerConfig {}

This file was deleted.

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 <<<")
}
}

This file was deleted.

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()
}
}

0 comments on commit 217d253

Please sign in to comment.