Created
May 4, 2019 20:00
-
-
Save AlicanAkkus/b98b55799a48d3396eb544b9425d45c3 to your computer and use it in GitHub Desktop.
order create with exception
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
package io.happy.customer | |
import spock.lang.Specification | |
class OrderCreateFacadeTest extends Specification { | |
def orderCommissionCalculator = Mock(OrderCommissionCalculator) | |
def orderCreateFacade = new OrderCreateFacade(orderCommissionCalculator) | |
void "should not create order when price is zero"() { | |
given: | |
def userId = 998 | |
def paymentMethod = "CARD" | |
def price = 0 | |
and: | |
1 * orderCommissionCalculator.calculate("CARD", 0) >> { throw new Exception("price could not be zero") } | |
0 * _._ | |
when: | |
orderCreateFacade.create(userId, paymentMethod, price) | |
then: | |
def e = thrown(Exception) | |
e.message == "price could not be zero" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment