File tree Expand file tree Collapse file tree 5 files changed +10
-6
lines changed
scala-design-patterns/src
main/scala/com/baeldung/scala
test/scala/com/baeldung/scala Expand file tree Collapse file tree 5 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -472,8 +472,9 @@ lazy val scala_strings = (project in file("scala-strings"))
472
472
lazy val scala_design_patterns = (project in file(" scala-design-patterns" ))
473
473
.settings(
474
474
name := " scala-design-patterns" ,
475
+ scalaVersion := scala3Version,
475
476
libraryDependencies ++= scalaTestDeps,
476
- libraryDependencies += scalaMock ,
477
+ libraryDependencies += " org.scalatestplus " %% " mockito-3-4 " % " 3.2.10.0 " % Test ,
477
478
libraryDependencies += " com.novocode" % " junit-interface" % " 0.11" % Test
478
479
)
479
480
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
package com .baeldung .scala .magnetpattern
2
2
3
+ import scala .language .implicitConversions
4
+
3
5
object MagnetPattern extends App {
4
6
5
7
/*
@@ -20,11 +22,11 @@ object MagnetPattern extends App {
20
22
21
23
def combineElements (magnet : CombineMagnet ): magnet.Result = magnet()
22
24
23
- implicit def intCombineMagnet (intList : List [Int ]) = new CombineMagnet {
25
+ implicit def intCombineMagnet (intList : List [Int ]): CombineMagnet { type Result = Int } = new CombineMagnet {
24
26
override type Result = Int
25
27
override def apply (): Result = intList.reduce((i, c) => i + c)
26
28
}
27
- implicit def strCombineMagnet (stringList : List [String ]) = new CombineMagnet {
29
+ implicit def strCombineMagnet (stringList : List [String ]): CombineMagnet { type Result = String } = new CombineMagnet {
28
30
override type Result = String
29
31
override def apply (): Result = stringList.reduce((s, c) => s.concat(c))
30
32
}
Original file line number Diff line number Diff line change 1
1
package com .baeldung .scala .cakepattern
2
2
3
3
import com .baeldung .scala .cakepattern .CakePattern .Test
4
- import org .scalamock . scalatest . MockFactory
4
+ import org .mockito . Mockito . when
5
5
import org .scalatest .flatspec .AnyFlatSpec
6
+ import org .scalatestplus .mockito .MockitoSugar
6
7
7
8
trait TestRegistry
8
9
extends CakePattern .TestExecutorComponent
9
10
with CakePattern .TestEnvironmentComponent
10
- with MockFactory {
11
+ with MockitoSugar {
11
12
override val env : TestEnvironment = mock[TestEnvironment ]
12
13
override val testExecutor : TestExecutor = new TestExecutor
13
14
}
14
15
15
16
class CakePatternUnitTest extends AnyFlatSpec with TestRegistry {
16
17
17
18
" A TestExecutor" should " execute tests using a given environment" in {
18
- (env.readEnvironmentProperties _).expects().returning (Map (" ENV" -> " true" ))
19
+ when (env.readEnvironmentProperties).thenReturn (Map (" ENV" -> " true" ))
19
20
val test = Test (
20
21
" test-1" ,
21
22
{ environment =>
File renamed without changes.
You can’t perform that action at this time.
0 commit comments