OrderModificationRequestConverter implements Converter<PaymentService, OrderNotificationMessage> { @Override public OrderNotificationMessage convert(final PaymentService source) throws ConversionException { return convert(source, new OrderNotificationMessage()); }  @Override OrderNotificationMessage convert(final PaymentService source); @Override OrderNotificationMessage convert(final PaymentService source, final OrderNotificationMessage target); @Required void setServiceResponseTransformerHelper(final ServiceResponseTransformerHelper serviceResponseTransformerHelper);  }
@Test public void convertShouldConvertXMLMessageIntoOrderModificationMessage() { when(responseTransformerHelperMock.buildPaymentReply(paymentMock)).thenReturn(paymentReplyMock); when(responseTransformerHelperMock.buildJournalReply(journalMock)).thenReturn(journalReplyMock); when(orderStatusEventMock.getPayment()).thenReturn(paymentMock); when(orderStatusEventMock.getJournal()).thenReturn(journalMock); when(orderStatusEventMock.getOrderCode()).thenReturn(ORDER_CODE); when(paymentServiceMock.getMerchantCode()).thenReturn(MERCHANT_CODE); when(orderStatusEventMock.getToken()).thenReturn(tokenMock); when(responseTransformerHelperMock.buildTokenReply(tokenMock)).thenReturn(tokenReplyMock); final OrderNotificationMessage result = testObj.convert(paymentServiceMock); assertEquals(ORDER_CODE, result.getOrderCode()); assertEquals(MERCHANT_CODE, result.getMerchantCode()); assertSame(paymentReplyMock, result.getPaymentReply()); assertSame(journalReplyMock, result.getJournalReply()); assertSame(tokenReplyMock, result.getTokenReply()); }
@Test public void convertShouldConvertXMLMessageIntoOrderModificationMessageWithoutToken() { when(responseTransformerHelperMock.buildPaymentReply(paymentMock)).thenReturn(paymentReplyMock); when(responseTransformerHelperMock.buildJournalReply(journalMock)).thenReturn(journalReplyMock); when(orderStatusEventMock.getPayment()).thenReturn(paymentMock); when(orderStatusEventMock.getJournal()).thenReturn(journalMock); when(orderStatusEventMock.getOrderCode()).thenReturn(ORDER_CODE); when(paymentServiceMock.getMerchantCode()).thenReturn(MERCHANT_CODE); when(orderStatusEventMock.getToken()).thenReturn(null); final OrderNotificationMessage result = testObj.convert(paymentServiceMock); assertEquals(ORDER_CODE, result.getOrderCode()); assertEquals(MERCHANT_CODE, result.getMerchantCode()); assertSame(paymentReplyMock, result.getPaymentReply()); assertSame(journalReplyMock, result.getJournalReply()); assertNull(result.getTokenReply()); }
@Test public void shouldSetShopperWebformReply() { when(orderStatusEventMock.getShopperWebformRefundDetails()).thenReturn(shopperWebformRefundDetailsMock); when(responseTransformerHelperMock.buildWebformRefundReply(shopperWebformRefundDetailsMock)).thenReturn(webformRefundReplyMock); final OrderNotificationMessage result = testObj.convert(paymentServiceMock); assertEquals(webformRefundReplyMock, result.getWebformRefundReply()); }
@Test public void shouldNotSetShopperWebformReplyWhenNull() { when(orderStatusEventMock.getShopperWebformRefundDetails()).thenReturn(null); final OrderNotificationMessage result = testObj.convert(paymentServiceMock); assertNull(result.getWebformRefundReply()); verify(responseTransformerHelperMock, never()).buildWebformRefundReply(any()); }