??ò??????????????
???????????? ???????[ 2013/6/17 10:36:25 ] ????????
????С????????????????????????
????????????????????汾??????????е???????????????????????????汾?? :D
?????????????template?汾?????????????????????SubTemplate1??SubTemplate2??template()??д?????????????AbstractTemplate??template()????SomeDependency??AnotherDependency?????????????????????У???????????Stub/Mock???????滻??????????????????????????????????????implementThis()???????return 1 ??return 2??
?????????????strategy?汾??????????????????UsingStrategy??д?????????Stub/Mock?滻Strategy??SomeDependency??AnotherDependency???????????Strategy1??Strategy2??д?????
?????????????strategy?汾???????????????????Щ??????????????????????????????????о???Template??????????Template??????????????????????????????
???????????????
??????Щ?????????????????????д??????羭??? service-dao????????????????????
@Transactional ??1??
@Override
public void cancel(String orderId) {
Order order = orderRepository.findBy(orderId); ??2??
order.cancel();
orderRepository.store(order); ??3??
}
@Transactional ??4??
@Override
public void acknowledge(String orderId) {
Order order = orderRepository.findBy(orderId); ??5??
order.acknowledge();
orderRepository.store(order); ??6??
}
??????δ?????????????????????????????????????????????????????Order??????????????????У?2??????5?? ?? ??3??????6??????????????????????????????????????????????????????ε????1??????4?????????д??????????????????????????????????????????????????????
@Test
public void orderIsCanceledAfterCancelling() throws Exception {
final Order order = new OrderFixture().build();
final String orderId = order.getId();
context.checking(new Expectations() {
{
allowing(orderRepository).findBy(orderId);
will(returnValue(order));
oneOf(orderRepository).store(order);
}
});
target.cancel(orderId);
assertTrue(order.isCanceled());
}
@Test
public void orderIsAcknowledgedAfterAcknowledging() throws Exception {
final Order order = new OrderFixture().build();
final String orderId = order.getId();
context.checking(new Expectations() {
{
allowing(orderRepository).findBy(orderId);
will(returnValue(order));
oneOf(orderRepository).store(order);
}
});
target.acknowledge(orderId);
assertTrue(order.isAcknowledged());
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11