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
class OrderService(val orderRepository: OrderRepository) { | |
fun cancelAllOrder(customer: Customer) { | |
val orders = orderRepository.findAllByCustomerAndOrderStatus(customer, OrderStatus.UNPAID) | |
//.. | |
} | |
} | |
class OrderServiceTest { | |
@Test | |
fun `Should cancel all order of a customer if the all orders are unpaid`() { |
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
@Test | |
fun `Should be cancelled if the order is unpaid`() { | |
//... | |
} |
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
@Test | |
fun `Should be cancelled if the order is unpaid`() { | |
//Arrange | |
val order = Order(OrderSpecification()) | |
order.makeUnpaid() | |
//Act | |
order.cancel() | |
//Assert |
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
class OrderSpecification { | |
fun isCancellable(orderStatus: OrderStatus): Boolean { | |
//…check order status | |
return true | |
} | |
} |
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
class OrderTest() { | |
//… | |
@Test | |
fun `Should be cancelled if the order is unpaid`() { | |
val order = Order(OrderSpecification()) | |
//…make the order unpaid… | |
order.cancel() | |
Assertions.assertTrue(order.isCancelled()) | |
} | |
} |
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
class OrderTest() { | |
//… | |
@Test | |
fun `Should be cancelled if the order is unpaid`() { | |
val orderSpecification = mockk<OrderSpecification>(relaxed = true) | |
val order = Order(orderSpecification) | |
//…make the order unpaid… | |
every { orderSpecification.isCancellable(order) } returns true | |
order.cancel() |
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
class InvalidOrderStateToCancel: RuntimeException() | |
class Order(val orderSpecification: OrderSpecification) { | |
fun cancel() { | |
if (!orderSpecification.isCancellable(this)) { | |
throw InvalidOrderStateToCancel() | |
} | |
//…cancel order | |
} |
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
from lxml import html | |
import requests | |
import json | |
def find_build_ids(test_case='max-emptydir-vol-per-pod'): | |
page = requests.get('https://gcsweb.k8s.io/gcs/kubernetes-jenkins/logs/ci-kubernetes-storage-scalability-{}/'.format(test_case)) | |
tree = html.fromstring(page.content) | |
raw_build_ids = tree.xpath('//li[@class="pure-g grid-row"]/div[@class="pure-u-2-5"]/a/text()') |