Search in sources :

Example 6 with MiraklErrorResponseBean

use of com.mirakl.client.core.error.MiraklErrorResponseBean in project mirakl-hyperwallet-connector by paypal.

the class MiraklCreditNotesExtractServiceImplTest method getAccountingDocuments_whenMiraklExceptionIsThrown_shouldSendEmailNotification.

@Test
void getAccountingDocuments_whenMiraklExceptionIsThrown_shouldSendEmailNotification() {
    final LocalDateTime now = LocalDateTime.now();
    TimeMachine.useFixedClockAt(now);
    final Date nowAsDate = DateUtil.convertToDate(now, ZoneId.systemDefault());
    final CreditNoteModel creditNoteOne = CreditNoteModel.builder().shopId(SHOP_ID_ONE).destinationToken(TOKEN_1).hyperwalletProgram(HYPERWALLET_PROGRAM).build();
    final List<CreditNoteModel> creditNoteList = List.of(creditNoteOne);
    doReturn(creditNoteList).when(testObj).getAccountingDocuments(nowAsDate);
    final MiraklApiException miraklApiException = new MiraklApiException(new MiraklErrorResponseBean(1, "Something went wrong"));
    doThrow(miraklApiException).when(miraklMarketplacePlatformOperatorApiClientMock).getShops(any(MiraklGetShopsRequest.class));
    testObj.extractAccountingDocument(nowAsDate);
    verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected getting shops in Mirakl", String.format("Something went wrong getting information of " + "shops" + " [2000]%n%s", MiraklLoggingErrorsUtil.stringify(miraklApiException)));
}
Also used : LocalDateTime(java.time.LocalDateTime) MiraklErrorResponseBean(com.mirakl.client.core.error.MiraklErrorResponseBean) MiraklApiException(com.mirakl.client.core.exception.MiraklApiException) MiraklGetShopsRequest(com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest) CreditNoteModel(com.paypal.invoices.invoicesextract.model.CreditNoteModel) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 7 with MiraklErrorResponseBean

use of com.mirakl.client.core.error.MiraklErrorResponseBean in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderExtractServiceImplTest method updateUserToken_shouldSendEmailNotification_whenMiraklExceptionIsThrown.

@Test
void updateUserToken_shouldSendEmailNotification_whenMiraklExceptionIsThrown() {
    when(sellerModelMock.getClientUserId()).thenReturn("12345");
    when(sellerModelMock.getBusinessStakeHolderDetails()).thenReturn(List.of(businessStakeHolderModelMock));
    final MiraklApiException miraklApiException = new MiraklApiException(new MiraklErrorResponseBean(1, "Something went wrong"));
    doThrow(miraklApiException).when(miraklMarketplacePlatformOperatorApiClientMock).updateShops(any(MiraklUpdateShopsRequest.class));
    testObj.updateBusinessStakeholderToken(sellerModelMock.getClientUserId(), sellerModelMock.getBusinessStakeHolderDetails());
    verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected getting shop information in Mirakl", String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting information of shop [12345]%n%s", MiraklLoggingErrorsUtil.stringify(miraklApiException)));
}
Also used : MiraklErrorResponseBean(com.mirakl.client.core.error.MiraklErrorResponseBean) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklApiException(com.mirakl.client.core.exception.MiraklApiException) Test(org.junit.jupiter.api.Test)

Example 8 with MiraklErrorResponseBean

use of com.mirakl.client.core.error.MiraklErrorResponseBean in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellersExtractServiceImplTest method extractSellers_shouldSendEmailNotification_whenMiraklExceptionIsThrown.

@Test
void extractSellers_shouldSendEmailNotification_whenMiraklExceptionIsThrown() {
    final MiraklApiException miraklApiException = new MiraklApiException(new MiraklErrorResponseBean(1, "Something went wrong"));
    doThrow(miraklApiException).when(miraklMarketplacePlatformOperatorApiClientMock).getShops(any(MiraklGetShopsRequest.class));
    testObj.extractSellers(dateMock);
    verify(mailNotificationUtilMock).sendPlainTextEmail("Issue detected getting shop information in Mirakl", String.format(ERROR_MESSAGE_PREFIX + "Something went wrong getting shop information since [dateMock]%n%s", MiraklLoggingErrorsUtil.stringify(miraklApiException)));
}
Also used : MiraklErrorResponseBean(com.mirakl.client.core.error.MiraklErrorResponseBean) MiraklApiException(com.mirakl.client.core.exception.MiraklApiException) MiraklGetShopsRequest(com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest) Test(org.junit.jupiter.api.Test)

Aggregations

MiraklErrorResponseBean (com.mirakl.client.core.error.MiraklErrorResponseBean)8 MiraklApiException (com.mirakl.client.core.exception.MiraklApiException)8 Test (org.junit.jupiter.api.Test)8 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)4 MiraklGetShopsRequest (com.mirakl.client.mmp.request.shop.MiraklGetShopsRequest)4 LocalDateTime (java.time.LocalDateTime)2 Date (java.util.Date)2 CreditNoteModel (com.paypal.invoices.invoicesextract.model.CreditNoteModel)1 InvoiceModel (com.paypal.invoices.invoicesextract.model.InvoiceModel)1 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)1