Created
May 4, 2011 09:26
-
-
Save realbot/954990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Java library | |
public final class SomeObjectFactory { | |
public SomeObject getInstance(String someParam) { ... } | |
} | |
// Scala client | |
class SomeClientClass(sof: SomeObjectFactory) { | |
def foo(param: String) { | |
val someObj = sof.getInstance(param) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object SomeClientClass { | |
type SomeObjectFactory = { def getInstance(someParam: String): SomeObject } | |
} | |
class SomeClientClass(sof: SomeClientClass.SomeObjectFactory) { | |
def foo(param: String) { | |
val someObj = sof.getInstance(param) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait FakeSomeObjectFactory { | |
def getInstance(someParam: String): SomeObject | |
} | |
class TestSomeClientClass extends Specification with Mockito { | |
private val mockFactory = mock[FakeSomeObjectFactory] | |
mockFactory.getInstance("some param") returns ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment