-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
279 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...src/test/java/org/apache/fineract/integrationtests/organization/teller/CashierHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.integrationtests.organization.teller; | ||
|
||
import com.google.gson.Gson; | ||
import io.restassured.specification.RequestSpecification; | ||
import io.restassured.specification.ResponseSpecification; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.apache.fineract.integrationtests.common.Utils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public final class CashierHelper { | ||
|
||
private CashierHelper() { | ||
|
||
} | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(CashierHelper.class); | ||
|
||
private static final String CREATE_CASHIER_URL = "/fineract-provider/api/v1/tellers/1/cashiers"; | ||
|
||
public static Integer createCashier(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { | ||
return (Integer) createTellerWithJson(requestSpec, responseSpec, createTellerAsJSON()).get("resourceId"); | ||
} | ||
|
||
public static Map<String, Object> createTellerWithJson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, | ||
final String json) { | ||
final String url = CREATE_CASHIER_URL + "?" + Utils.TENANT_IDENTIFIER; | ||
return Utils.performServerPost(requestSpec, responseSpec, url, json, ""); | ||
} | ||
|
||
public static String createTellerAsJSON() { | ||
|
||
final Map<String, Object> map = getMapWithDates(); | ||
|
||
map.put("staffId", 1); | ||
map.put("description", Utils.uniqueRandomStringGenerator("test__", 4)); | ||
LOG.info("map : {}", map); | ||
return new Gson().toJson(map); | ||
} | ||
|
||
public static Map<String, Object> getMapWithDates() { | ||
HashMap<String, Object> map = new HashMap<>(); | ||
|
||
map.put("locale", "en"); | ||
map.put("dateFormat", "dd MMMM yyyy"); | ||
map.put("startDate", "01 January 2023"); | ||
map.put("endDate", "31 December 2023"); | ||
map.put("isFullDay", true); | ||
|
||
return map; | ||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
...ache/fineract/integrationtests/organization/teller/CashierSummaryAndTransactionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.integrationtests.organization.teller; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import io.restassured.builder.RequestSpecBuilder; | ||
import io.restassured.builder.ResponseSpecBuilder; | ||
import io.restassured.http.ContentType; | ||
import io.restassured.specification.RequestSpecification; | ||
import io.restassured.specification.ResponseSpecification; | ||
import org.apache.fineract.client.models.GetTellersTellerIdCashiersCashiersIdTransactionsResponse; | ||
import org.apache.fineract.integrationtests.common.Utils; | ||
import org.apache.fineract.integrationtests.common.organisation.StaffHelper; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class CashierSummaryAndTransactionsTest { | ||
|
||
private CashierTransactionsHelper cashierTransactionsHelper; | ||
|
||
private ResponseSpecification responseSpecification; | ||
private RequestSpecification requestSpecification; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
Utils.initializeRESTAssured(); | ||
|
||
requestSpecification = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); | ||
requestSpecification.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); | ||
responseSpecification = new ResponseSpecBuilder().expectStatusCode(200).build(); | ||
cashierTransactionsHelper = new CashierTransactionsHelper(requestSpecification, responseSpecification); | ||
StaffHelper.createStaff(requestSpecification, responseSpecification); | ||
TellerHelper.createTeller(requestSpecification, responseSpecification); | ||
CashierHelper.createCashier(requestSpecification, responseSpecification); | ||
|
||
} | ||
|
||
@Test | ||
public void testGetCashierTransactions() { | ||
Long tellerId = 1L; | ||
Long cashierId = 1L; | ||
|
||
final GetTellersTellerIdCashiersCashiersIdTransactionsResponse result = cashierTransactionsHelper | ||
.getTellersTellerIdCashiersCashiersIdTransactionsResponse(tellerId, cashierId, "UGX", 0, 0, null, null); | ||
assertNotNull(result); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...a/org/apache/fineract/integrationtests/organization/teller/CashierTransactionsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.integrationtests.organization.teller; | ||
|
||
import io.restassured.specification.RequestSpecification; | ||
import io.restassured.specification.ResponseSpecification; | ||
import org.apache.fineract.client.models.GetTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse; | ||
import org.apache.fineract.client.models.GetTellersTellerIdCashiersCashiersIdTransactionsResponse; | ||
import org.apache.fineract.integrationtests.client.IntegrationTest; | ||
|
||
public class CashierTransactionsHelper extends IntegrationTest { | ||
|
||
private final ResponseSpecification responseSpecification; | ||
private final RequestSpecification requestSpecification; | ||
|
||
public CashierTransactionsHelper(final RequestSpecification requestSpecification, final ResponseSpecification responseSpecification) { | ||
this.requestSpecification = requestSpecification; | ||
this.responseSpecification = responseSpecification; | ||
} | ||
|
||
public GetTellersTellerIdCashiersCashiersIdTransactionsResponse getTellersTellerIdCashiersCashiersIdTransactionsResponse(Long tellerId, | ||
Long cashierId, String currencyCode, int offset, int limit, String orderBy, String sortOrder) { | ||
return ok(fineract().tellers.getTransactionsForCashier(tellerId, cashierId, currencyCode, offset, limit, orderBy, sortOrder)); | ||
} | ||
|
||
public GetTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse getTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse( | ||
Long tellerId, Long cashierId, String currencyCode, int offset, int limit, String orderBy, String sortOrder) { | ||
return ok(fineract().tellers.getTransactionsWithSummaryForCashier(tellerId, cashierId, currencyCode, offset, limit, orderBy, | ||
sortOrder)); | ||
} | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
.../src/test/java/org/apache/fineract/integrationtests/organization/teller/TellerHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.fineract.integrationtests.organization.teller; | ||
|
||
import com.google.gson.Gson; | ||
import io.restassured.specification.RequestSpecification; | ||
import io.restassured.specification.ResponseSpecification; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.apache.fineract.integrationtests.common.Utils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public final class TellerHelper { | ||
|
||
private TellerHelper() { | ||
|
||
} | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(TellerHelper.class); | ||
|
||
private static final String CREATE_TELLER_URL = "/fineract-provider/api/v1/tellers"; | ||
|
||
public static Integer createTeller(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) { | ||
return (Integer) createTellerWithJson(requestSpec, responseSpec, createTellerAsJSON()).get("resourceId"); | ||
} | ||
|
||
public static Map<String, Object> createTellerWithJson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, | ||
final String json) { | ||
final String url = CREATE_TELLER_URL + "?" + Utils.TENANT_IDENTIFIER; | ||
return Utils.performServerPost(requestSpec, responseSpec, url, json, ""); | ||
} | ||
|
||
public static String createTellerAsJSON() { | ||
|
||
final Map<String, Object> map = getMapWithStartDate(); | ||
|
||
map.put("officeId", 1); | ||
map.put("name", Utils.uniqueRandomStringGenerator("Teller 1", 5)); | ||
map.put("description", Utils.uniqueRandomStringGenerator("Teller For Testing", 4)); | ||
map.put("status", 300); | ||
|
||
LOG.info("map : {}", map); | ||
return new Gson().toJson(map); | ||
} | ||
|
||
public static Map<String, Object> getMapWithStartDate() { | ||
HashMap<String, Object> map = new HashMap<>(); | ||
|
||
map.put("locale", "en"); | ||
map.put("dateFormat", "dd MMMM yyyy"); | ||
map.put("startDate", "20 September 2011"); | ||
|
||
return map; | ||
} | ||
|
||
} |