|
|
|
|
@ -25,6 +25,8 @@ import org.mockito.ArgumentCaptor;
|
|
|
|
|
import org.mockito.InjectMocks;
|
|
|
|
|
import org.mockito.Mock;
|
|
|
|
|
import org.mockito.junit.jupiter.MockitoExtension;
|
|
|
|
|
import org.springframework.transaction.support.TransactionCallback;
|
|
|
|
|
import org.springframework.transaction.support.TransactionTemplate;
|
|
|
|
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
|
|
class BorrowReturnReminderServiceImplTest
|
|
|
|
|
@ -38,6 +40,9 @@ class BorrowReturnReminderServiceImplTest
|
|
|
|
|
@Mock
|
|
|
|
|
private ISysNoticeReceiverService noticeReceiverService;
|
|
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
private TransactionTemplate transactionTemplate;
|
|
|
|
|
|
|
|
|
|
@InjectMocks
|
|
|
|
|
private BorrowReturnReminderServiceImpl service;
|
|
|
|
|
|
|
|
|
|
@ -45,6 +50,7 @@ class BorrowReturnReminderServiceImplTest
|
|
|
|
|
@Test
|
|
|
|
|
void remindShouldCreateDirectedNoticeForDueCandidate()
|
|
|
|
|
{
|
|
|
|
|
mockTransactionTemplate();
|
|
|
|
|
AmsBorrowOrder order = buildOrder();
|
|
|
|
|
when(amsBorrowOrderMapper.selectOverdueBorrowReturnReminderCandidates(
|
|
|
|
|
BorrowOrderStatus.BORROWING, BorrowOrderStatus.BORROWING))
|
|
|
|
|
@ -95,6 +101,7 @@ class BorrowReturnReminderServiceImplTest
|
|
|
|
|
@Test
|
|
|
|
|
void remindShouldFailFastWhenReceiverInsertFails()
|
|
|
|
|
{
|
|
|
|
|
mockTransactionTemplate();
|
|
|
|
|
AmsBorrowOrder order = buildOrder();
|
|
|
|
|
when(amsBorrowOrderMapper.selectOverdueBorrowReturnReminderCandidates(
|
|
|
|
|
BorrowOrderStatus.BORROWING, BorrowOrderStatus.BORROWING))
|
|
|
|
|
@ -113,6 +120,14 @@ class BorrowReturnReminderServiceImplTest
|
|
|
|
|
assertTrue(exception.getMessage().contains("接收人写入异常"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mockTransactionTemplate()
|
|
|
|
|
{
|
|
|
|
|
when(transactionTemplate.execute(any())).thenAnswer(invocation -> {
|
|
|
|
|
TransactionCallback<?> callback = invocation.getArgument(0);
|
|
|
|
|
return callback.doInTransaction(null);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private AmsBorrowOrder buildOrder()
|
|
|
|
|
{
|
|
|
|
|
AmsBorrowOrder order = new AmsBorrowOrder();
|
|
|
|
|
|