i am trying to mock an object that has a function with multiple argument.
I would just try to set the expectation for it. That is, somehting of the form:
(item.addMetadata(,,,,,)).expects("","","","","","","")
I just don't know how to write it. The example, usually deal with one argument function: (item.addMetadata _).expects("")
How to deal with multiple argument ?
EDIT1
I change to Just for the sake of compiling:
(item.addMetadata _) expects (where {
(schema: String, element: String, qualifier: String, lang: String, value: String) => true
})
Now The problem apparently is that the method is overloaded ?
I get the following error:
Error:(21, 15) ambiguous reference to overloaded definition, both method addMetadata in class Item of type (x$1: String, x$2: String, x$3: String, x$4: String, x$5: String, x$6: String, x$7: Int)Unit and method addMetadata in class Item of type (x$1: String, x$2: String, x$3: String, x$4: String, x$5: String)Unit match expected type ? (item.addMetadata _) expects (where { ^
as a side not i should also added the fact that i am mocking a class and not an interface. This is class which is not under my control, has a private constructor and only a static create method. So i also get the following error:
Error:(18, 24) constructor Item in class Item cannot be accessed in <$anon: org.dspace.content.Item> val item = mock[Item] ^
See: http://scalamock.org/user-guide/advanced_topics/#example-5---repeated-parameters