Skip to content

Commit 5d2a260

Browse files
FINERACT-2571: Preserve request headers in NotificationHelper
1 parent 20520a2 commit 5d2a260

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

integration-tests/src/test/java/org/apache/fineract/integrationtests/common/NotificationHelper.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
119
package org.apache.fineract.integrationtests.common;
220

321
import static org.awaitility.Awaitility.await;
422

23+
import io.restassured.specification.FilterableRequestSpecification;
524
import io.restassured.specification.RequestSpecification;
625
import io.restassured.specification.ResponseSpecification;
726
import java.time.Duration;
27+
import java.util.HashMap;
28+
import java.util.Map;
829
import lombok.extern.slf4j.Slf4j;
930
import org.apache.fineract.client.models.GetNotificationsResponse;
1031
import org.apache.fineract.client.util.Calls;
@@ -19,26 +40,32 @@ private NotificationHelper() {}
1940
// org.apache.fineract.client.models.PostLoansLoanIdRequest)
2041
@Deprecated(forRemoval = true)
2142
public static GetNotificationsResponse getNotifications(final RequestSpecification requestSpec,
22-
final ResponseSpecification responseSpec) {
43+
final ResponseSpecification responseSpec) {
2344
log.info("-----------------------------GET NOTIFICATIONS-----------------------------------");
24-
return Calls.ok(FineractClientHelper.getFineractClient().notifications.getAllNotifications(null, null, null, null, null));
45+
46+
FilterableRequestSpecification filterableRequestSpec = (FilterableRequestSpecification) requestSpec;
47+
48+
Map<String, String> headers = new HashMap<>();
49+
headers.put("Authorization", filterableRequestSpec.getHeaders().getValue("Authorization"));
50+
headers.put("Fineract-Platform-TenantId", filterableRequestSpec.getHeaders().getValue("Fineract-Platform-TenantId"));
51+
52+
return Calls.ok(FineractClientHelper.getFineractClient().notifications.getAllNotifications(null, 1, 0, null, null, headers));
2553
}
2654

2755
// TODO: Rewrite to use fineract-client instead!
2856
// Example: org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper.disburseLoan(java.lang.Long,
2957
// org.apache.fineract.client.models.PostLoansLoanIdRequest)
3058
@Deprecated(forRemoval = true)
31-
public static boolean areNotificationsAvailable(final RequestSpecification requestSpec,
32-
final ResponseSpecification responseSpec) {
59+
public static boolean areNotificationsAvailable(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
3360
return getNotifications(requestSpec, responseSpec).getPageItems().size() > 0;
3461
}
3562

3663
// Waiting for notifications to be available is needed due to the asynchronous event processing
3764
public static void waitUntilNotificationsAreAvailable(final RequestSpecification requestSpec,
38-
final ResponseSpecification responseSpec) {
65+
final ResponseSpecification responseSpec) {
3966
await().atMost(Duration.ofSeconds(30)) //
4067
.pollInterval(Duration.ofSeconds(5)) //
4168
.pollDelay(Duration.ofSeconds(5)) //
4269
.until(() -> NotificationHelper.areNotificationsAvailable(requestSpec, responseSpec));
4370
}
44-
}
71+
}

0 commit comments

Comments
 (0)