Created
February 14, 2021 10:31
-
-
Save vigneshwaranr/723dfe9bce63a4a191ebafe20f30f463 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def send(message: Message): Future[Boolean] = { | |
if (isValid(message)) { | |
producer.send(message).recover({case _ => false}) | |
} else { | |
Future(false) // this is not good | |
} | |
} |
This file contains hidden or 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
class UnitTest extends mutable.Specification with Mockito { | |
"Module" should { | |
"return false if producer throw exception" in { | |
val producer = mock[Producer] | |
val module = new Module(producer) | |
producer.send(any) returns Future(new Exception("failed")) //not good | |
module.send(mock[Message]) must beEqualTo(false).await | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment