Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.ibanity.apis.client.models.IsabelCollection;
import com.ibanity.apis.client.products.isabel_connect.models.PaymentNotification;
import com.ibanity.apis.client.products.isabel_connect.models.delete.PaymentNotificationDeleteQuery;
import com.ibanity.apis.client.products.isabel_connect.models.read.PaymentNotificationsReadQuery;

public interface PaymentNotificationService {
IsabelCollection<PaymentNotification> list(PaymentNotificationsReadQuery query);
void delete(PaymentNotificationDeleteQuery query);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.ibanity.apis.client.models.IbanityProduct;
import com.ibanity.apis.client.models.IsabelCollection;
import com.ibanity.apis.client.products.isabel_connect.models.PaymentNotification;
import com.ibanity.apis.client.products.isabel_connect.models.delete.PaymentNotificationDeleteQuery;
import com.ibanity.apis.client.products.isabel_connect.models.read.PaymentNotificationsReadQuery;
import com.ibanity.apis.client.products.isabel_connect.services.PaymentNotificationService;
import com.ibanity.apis.client.services.ApiUrlProvider;
Expand Down Expand Up @@ -39,12 +38,6 @@ public IsabelCollection<PaymentNotification> list(PaymentNotificationsReadQuery
});
}

@Override
public void delete(PaymentNotificationDeleteQuery query) {
URI uri = buildUri(getNotificationUrl(query.getPaymentNotificationId()));
ibanityHttpClient.delete(uri, query.getAdditionalHeaders(), query.getAccessToken());
}

private String extractPaymentId(DataApiModel data) {
return Optional.ofNullable(data.getRelationships())
.map(relationships -> relationships.get("payment"))
Expand All @@ -59,11 +52,4 @@ private String getNotificationsUrl() {
.replace("{bulkPaymentInitiationRequestId}", "notifications");
return StringUtils.removeEnd(url, "/");
}

private String getNotificationUrl(String paymentNotificationId) {
String url = apiUrlProvider
.find(IbanityProduct.IsabelConnect, "bulkPaymentInitiationRequests")
.replace("{bulkPaymentInitiationRequestId}", "notifications/" + paymentNotificationId);
return StringUtils.removeEnd(url, "/");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.ibanity.apis.client.models.IbanityProduct;
import com.ibanity.apis.client.models.IsabelCollection;
import com.ibanity.apis.client.products.isabel_connect.models.PaymentNotification;
import com.ibanity.apis.client.products.isabel_connect.models.delete.PaymentNotificationDeleteQuery;
import com.ibanity.apis.client.products.isabel_connect.models.read.PaymentNotificationsReadQuery;
import com.ibanity.apis.client.services.ApiUrlProvider;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -20,10 +19,8 @@
import java.time.Instant;
import java.util.Collections;

import static com.ibanity.apis.client.helpers.IbanityTestHelper.createHttpResponse;
import static com.ibanity.apis.client.helpers.IbanityTestHelper.loadHttpResponse;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
Expand All @@ -33,7 +30,6 @@ public class PaymentNotificationServiceImplTest {
private static final String BPIR_ENDPOINT = "https://api.ibanity.localhost/isabel-connect/bulk-payment-initiation-requests/{bulkPaymentInitiationRequestId}";
private static final String LIST_ENDPOINT = "https://api.ibanity.localhost/isabel-connect/bulk-payment-initiation-requests/notifications?size=20";
private static final String NOTIFICATION_ID = "14e2bff5-e365-4bc7-bf48-76b7bcd464e9";
private static final String DELETE_ENDPOINT = "https://api.ibanity.localhost/isabel-connect/bulk-payment-initiation-requests/notifications/" + NOTIFICATION_ID;

@InjectMocks
private PaymentNotificationServiceImpl service;
Expand Down Expand Up @@ -70,16 +66,4 @@ public void list() throws Exception {
assertThat(notification.getPaymentId()).isEqualTo("90000036388319");
}

@Test
public void delete() throws Exception {
when(ibanityHttpClient.delete(new URI(DELETE_ENDPOINT), Collections.emptyMap(), ACCESS_TOKEN))
.thenReturn(createHttpResponse(""));

service.delete(PaymentNotificationDeleteQuery.builder()
.accessToken(ACCESS_TOKEN)
.paymentNotificationId(NOTIFICATION_ID)
.build());

verify(ibanityHttpClient).delete(new URI(DELETE_ENDPOINT), Collections.emptyMap(), ACCESS_TOKEN);
}
}
Loading