want to write test cases for the below program using TestActorRef . nested actor scenario but when i try to create context i m facing compilation errors . Please do help me with solution
Main Program : object TextCleaningScheduler extends App {
val system = ActorSystem("cleanText")
val projectsActor = system.actorOf( Props(classOf[DataByProjects]) )
projectsActor ! ProcessDataByConnections(1,1)
}
case class ProcessDataByConnections( accID : Int, projectID : Int )
class DataByProjects extends Actor { def receive = {
case ProcessDataByConnections( accID, projectID ) => {
val dbName = "some_example"
val connectionStr = "cassandra://IPaddress/" + dbName
val elasticsearchIp = "ipaddress"
val elasticsearchPort = "9200"
val dbObject = new DatabaseOperations(dbName,
connectionStr,
elasticsearchIp,
elasticsearchPort
)
val query = "{ \"query\" : { \"match\" : { \"project_info_mapping.project_id\" : " + projectID + " } } }"
val fetchedData = dbObject.queryData("project_instance",query,"project_instance","data")
var counter = 0
//for ( row <- fetchedData) {
val row = fetchedData(0)
println(row)
val conn = row("project_instance_id")
val textCleaningInfo = row("text_cleaning")
val tempConn = 3
val queueName = "RAWDATA_A" + accID + "_C" + tempConn
var accInfo : Map[String, Any] = Map( "accID" -> accID , "projectID" -> projectID, "conn" -> tempConn )
accInfo += ("textCleaning" -> textCleaningInfo, "wordsToRemove" -> row("remove_words"), "findAndReplace" -> row("find_and_replace") )
accInfo += ("dataVariable" -> row("data_variable_name"), "dataLabel" -> row("data_variable_label") )
val queueActor = context.actorOf(Props(classOf[GetAndPushQueue], accInfo ), "queue" + counter )
TestProgram : inside test class using flatspec scalatest framework
val actorRef = TestActorRef[DataByProjects]
actorRef ! ProcessDataByConnections(1, 1)
val accInfo =1
val counter = 0
val context = actorRef.underlyingActor
actorRef.forward("child" , context.context)
Aucun commentaire:
Enregistrer un commentaire