All Questions
172
questions
1
vote
0
answers
60
views
Mocking is not working with Pekko. Instead of fulfilling request from mocking, it's hitting actual database
When we were using Akka Actors, and while using it, our mocking and testing was working fine. Now we switched to Pekko Actors, and while using it, our mocking is not working because sending request ...
0
votes
0
answers
41
views
I'm creating a new trait but values are initialized to null
I have a trait that looks like this
private[name] trait HttpIssuer extends HttpIssuerImpl with JsonApi with Logging {
def credentials: ApiCredentials
def maxAllowedQuota: Int
def minHour: Option[...
0
votes
1
answer
157
views
Mocking a method inside a Scala class using Mockito
I am working with the following Scala class:
class names(lastName: String) {
def getFullName(lastName: String): String = get_private_name + lastName
def getPrivateName: String = "amit"
...
0
votes
1
answer
82
views
Scala: How to Unit Test a function I have which makes a call to internal non-exposed API but in same service mesh call using mock/stub?
i have a function which makes a call to an api which is not externally exposed, but is present in same service mesh as the function.
lets say something like below.
func internalApiCall(payload: String)...
0
votes
0
answers
129
views
Cannot invoke "java.lang.Integer.intValue()" specs2 mocking a method that returns int
I am using following configuration to run a test case using specs2 specification and specs2 mockito and mocked a method that is supposed to return int but it gives following error.
java.lang....
0
votes
2
answers
757
views
How to Mock LocalDate.now() in Scala
I have object
object func1{
def something(arg1: Int): String{
// var date = something2()
// Using date
}
def something2(): LocalDate{
LocalDate.now()
}
}
I want to ...
0
votes
1
answer
583
views
In Scala, how do I properly unit test a class method that calls other class methods?
I have a case class that represents a phone number, and provides some helper methods that are used elsewhere in the code. One of these methods calls other methods within the same class:
case class ...
0
votes
0
answers
248
views
Scala: mock Hadoop File System
I need to mock (with scalamock 4.4.0/scalatest 3.2.9) the behaviour of Hadoop file system. I found out, that I can't mock it directly, so I'm trying to get around this problem.
On the first, try I ...
0
votes
1
answer
184
views
Mock case class in scala
I have a trait
trait Writer[T <: Attribute] {
def read(boundingBox: BoundingBox): Future[List[T]]
}
and a case class
case class WriterImpl[T <: Attribute]()(implicit manifest: Manifest[T]) ...
2
votes
0
answers
444
views
Mock spark Dataframewriter for unit testing
I am writing unit testcase for a function using mockito that writes the df to a hivetable using insertinto.
def method():Unit={
val df=spark.sql("some query")
df.write.insertInto("...
1
vote
1
answer
199
views
Mocking Httpcalls always return NullPointerException
I'm trying to mock Http calls for unit test.
To do that I have done the following, I have created a RequestMock case class:
case class RequestMock() {
def sendRequest(httpRequest: HttpRequest)(...
0
votes
1
answer
252
views
How to mock nested classes in scala
I have a class that can be simplified as below
class my {
val b = new subClass()
def a () = "not mocked"
class subClass {
def ret () = "not mocked"
}
}
I need some ...
2
votes
1
answer
421
views
How to write Scala tests for component "Write data to HDFS directory"
I have a simple code which writes data to hdfs in csv and parquet format, How can I write scala tests here which can test the below component. I can't actually write the data to hdfs(in the tests) as ...
0
votes
0
answers
42
views
How to return java.util.Void from Scala [duplicate]
I am mocking an interface for testing that has a method that returns ApiFuture[Void] where ApiFuture is google.com.api.core.ApiFuture and void is the Java standard java.util.void. I am coding in Scala....
2
votes
0
answers
197
views
ScalaMock: Is it possible to mock a trait with an overloaded method expecting a curried function parameter?
My application is using Scala 2.13 and ScalaMock 5.1. Is it possible to mock the bar method in a trait like this one?
trait Foo {
def bar(f: Double): Double
def bar(i: Int)(f: => Double): ...