<commit_before>package com.mindcandy.waterfall.actor

import org.specs2.SpecificationLike
import akka.testkit.TestKit
import akka.actor.ActorSystem
import org.specs2.specification.After
import org.specs2.time.NoTimeConversions
import akka.testkit.TestProbe
import akka.actor.ActorRef
import scala.util.Success
import com.mindcandy.waterfall.actor.ScheduleManager.CheckJobs
import com.mindcandy.waterfall.actor.JobDatabaseManager.GetSchedule

class ScheduleManagerSpec extends TestKit(ActorSystem("ScheduleManagerSpec")) with SpecificationLike with After with NoTimeConversions {
  override def is = s2"""
     ScheduleManager should
       should contact job database on check jobs message $checkJob
  """

  override def after: Any = TestKit.shutdownActorSystem(system)

  def checkJob = {
    val dropUID = "test1"
    val probe: TestProbe = TestProbe()
    val databaseManager: TestProbe = TestProbe()
    val dropSupervisor: TestProbe = TestProbe()
    val actor: ActorRef = system.actorOf(ScheduleManager.props(databaseManager.ref, dropSupervisor.ref, TestWaterfallDropFactory))
    val request = CheckJobs()

    probe.send(actor, request)
    databaseManager.expectMsgClass(classOf[GetSchedule]) must_== GetSchedule()
  }
}<commit_msg>* adding unit test for cron schedule<commit_after>package com.mindcandy.waterfall.actor

import org.specs2.SpecificationLike
import akka.testkit.TestKit
import akka.actor.ActorSystem
import org.specs2.specification.After
import org.specs2.time.NoTimeConversions
import akka.testkit.TestProbe
import akka.actor.ActorRef
import scala.util.Success
import com.mindcandy.waterfall.actor.ScheduleManager.CheckJobs
import com.mindcandy.waterfall.actor.JobDatabaseManager.GetSchedule
import com.mindcandy.waterfall.actor.Protocol.DropJobList
import com.mindcandy.waterfall.actor.Protocol.DropJob
import com.github.nscala_time.time.Imports._
import scala.language.postfixOps
import com.mindcandy.waterfall.actor.DropSupervisor.StartJob
import scala.concurrent.duration._

class ScheduleManagerSpec extends TestKit(ActorSystem("ScheduleManagerSpec")) with SpecificationLike with After with NoTimeConversions {
  override def is = s2"""
    ScheduleManager should
      should contact job database on check jobs message $checkJobs
      should schedule one job if one is send from the databaseManager $scheduleOneJob
  """

  override def after: Any = TestKit.shutdownActorSystem(system)

  def checkJobs = {
    val probe: TestProbe = TestProbe()
    val databaseManager: TestProbe = TestProbe()
    val dropSupervisor: TestProbe = TestProbe()
    val actor: ActorRef = system.actorOf(ScheduleManager.props(databaseManager.ref, dropSupervisor.ref, TestWaterfallDropFactory))
    val request = CheckJobs()

    probe.send(actor, request)
    databaseManager.expectMsgClass(classOf[GetSchedule]) must_== GetSchedule()
  }

  def scheduleOneJob = {
    val probe: TestProbe = TestProbe()
    val databaseManager: TestProbe = TestProbe()
    val dropSupervisor: TestProbe = TestProbe()
    val actor: ActorRef = system.actorOf(ScheduleManager.props(databaseManager.ref, dropSupervisor.ref, TestWaterfallDropFactory))
    val currentTime = DateTime.now + Period.seconds(5)
    
    val dropJob = DropJob("EXRATE", "Exchange Rate", true, s"${currentTime.secondOfMinute.getAsString} ${currentTime.minuteOfHour.getAsString} ${currentTime.hourOfDay.getAsString} * * ?")
    val request = DropJobList(List(dropJob))

    probe.send(actor, request)
    println("start job: " + StartJob(dropJob))
    dropSupervisor.expectMsgClass(FiniteDuration(10, SECONDS), classOf[StartJob]) must_== StartJob(dropJob)
  }
}
{'fraction_non_alphanumeric': 0.08787878787878788, 'fraction_numerical': 0.003305785123966942, 'mean_word_length': 5.426548672566372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1218907', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1062, 'n_words': 239}