I'm new to Scala. I'm working on the following code where one API endpoint is caching value in the file(SomeJsonData.toString()) and the other endpoint is retrieving from that file(Json.parse()). When writing a test using when-thenReurn, getting an overloaded method error.
Where am I going wrong? Any help is appreciated, thanks!
Cache File contents:
{"time":92345845,"value":[{"name":"Jack","hobby":"paint"}]
CacheController.scala
def retrieveCache = {
File(filePath).createFile()
val source = Source.fromFile(filePath)
val content = try source.mkString
.....
}
CacheControllerTest.scala
it("test") {
val mockSuggestions = "[{\"name\":\"Jack\",\"hobby\":\"paint\"}]"
val jsonData =Json.obj("time" -> DateTime.now(), "value" -> mockSuggestions)
when(Source.fromFile(anyString())).thenReturn(jsonData.toString())
// error: cannot resolve overloaded method thenReturn
}
Aucun commentaire:
Enregistrer un commentaire