Skip to content

Commit

Permalink
FINERACT-2081: Integration test clean up - Remove Google truth depend…
Browse files Browse the repository at this point in the history
…ency and Extract Fineract client out from IntegrationTest class
  • Loading branch information
adamsaghy committed Jan 31, 2025
1 parent de46208 commit 894b6cb
Show file tree
Hide file tree
Showing 53 changed files with 561 additions and 514 deletions.
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,6 @@ configure(project.fineractJavaProjects) {
'org.bouncycastle:bcpkix-jdk15to18',
'org.bouncycastle:bcprov-jdk15to18',
'org.awaitility:awaitility',
'com.google.truth:truth',
'com.google.truth.extensions:truth-java8-extension'
)

testCompileOnly 'org.projectlombok:lombok'
Expand Down Expand Up @@ -791,8 +789,6 @@ configure(project.fineractCustomProjects) {
'org.bouncycastle:bcpkix-jdk15to18',
'org.bouncycastle:bcprov-jdk15to18',
'org.awaitility:awaitility',
'com.google.truth:truth',
'com.google.truth.extensions:truth-java8-extension',
'io.github.classgraph:classgraph',
'io.cucumber:cucumber-core',
'io.cucumber:cucumber-java:7.20.1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ dependencyManagement {
dependency 'org.eclipse.persistence:org.eclipse.persistence.jpa:4.0.2'
dependency 'com.google.guava:guava:32.0.0-jre'
dependency 'com.google.code.gson:gson:2.11.0'
dependency 'com.google.truth:truth:1.4.4'
dependency 'com.google.truth.extensions:truth-java8-extension:1.4.4'
dependency 'com.google.googlejavaformat:google-java-format:1.24.0'
dependency 'org.apache.commons:commons-collections4:4.4'
dependency ('software.amazon.msk:aws-msk-iam-auth:2.2.0') {
Expand Down
2 changes: 2 additions & 0 deletions fineract-client/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ dependencies {
exclude group: 'org.apache.oltu.oauth2', module: 'org.apache.oltu.oauth2.common'
exclude group: 'org.slf4j'
}

testImplementation 'org.assertj:assertj-core'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
package org.apache.fineract.client.util;

import com.google.common.truth.Truth;
import com.google.common.truth.Truth8;
import static org.assertj.core.api.Assertions.assertThat;

import okhttp3.Headers;
import okhttp3.MediaType;
import org.junit.jupiter.api.Test;
Expand All @@ -29,32 +29,32 @@ public class PartsTest {

@Test
void validMediaType() {
Truth.assertThat(Parts.mediaType("test.jpg")).isEqualTo(MediaType.get("image/jpeg"));
assertThat(Parts.mediaType("test.jpg")).isEqualTo(MediaType.get("image/jpeg"));
}

@Test
void dotMediaType() {
Truth.assertThat(Parts.mediaType("test.")).isNull();
assertThat(Parts.mediaType("test.")).isNull();
}

@Test
void emptyMediaType() {
Truth.assertThat(Parts.mediaType("")).isNull();
assertThat(Parts.mediaType("")).isNull();
}

@Test
void nullMediaType() {
Truth.assertThat(Parts.mediaType(null)).isNull();
assertThat(Parts.mediaType(null)).isNull();
}

@Test
void fileName() {
Truth8.assertThat(Parts.fileName(Response.success(null, Headers.of("Content-Disposition", "attachment; filename=\"doc.pdf\""))))
assertThat(Parts.fileName(Response.success(null, Headers.of("Content-Disposition", "attachment; filename=\"doc.pdf\""))))
.hasValue("doc.pdf");
}

@Test
void fileNameWithoutContentDisposition() {
Truth8.assertThat(Parts.fileName(Response.success(null))).isEmpty();
assertThat(Parts.fileName(Response.success(null))).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package org.apache.fineract.batch.command.internal;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
Expand All @@ -35,6 +34,7 @@
import org.apache.fineract.infrastructure.core.api.MutableUriInfo;
import org.apache.fineract.infrastructure.dataqueries.api.DatatablesApiResource;
import org.apache.http.HttpStatus;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -91,7 +91,7 @@ public void testExecuteSuccessScenario(final String queryParameter, final int nu
verify(testContext.dataTableApiResource).getDatatableManyEntry(eq(datatableName), eq(loanId), eq(datatableId), eq(null),
eq(genericResultSet), testContext.uriInfoCaptor.capture());
MutableUriInfo mutableUriInfo = testContext.uriInfoCaptor.getValue();
assertThat(mutableUriInfo.getAdditionalQueryParameters()).hasSize(numberOfQueryParams);
Assertions.assertThat(mutableUriInfo.getAdditionalQueryParameters()).hasSize(numberOfQueryParams);
if (numberOfQueryParams > 0) {
List<String> param = mutableUriInfo.getAdditionalQueryParameters().get("genericResultSet");
assertEquals(param.get(0), "true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.fineract.batch.command.internal;

import static com.google.common.truth.Truth.assertThat;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.event.external.jobs;

import static com.google.common.truth.Truth.assertThat;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import org.apache.fineract.client.models.PutLoansLoanIdResponse;
import org.apache.fineract.client.util.CallFailedRuntimeException;
import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants;
import org.apache.fineract.integrationtests.client.IntegrationTest;
import org.apache.fineract.integrationtests.common.BatchHelper;
import org.apache.fineract.integrationtests.common.BusinessDateHelper;
import org.apache.fineract.integrationtests.common.ClientHelper;
Expand Down Expand Up @@ -113,7 +114,7 @@

@Slf4j
@ExtendWith(LoanTestLifecycleExtension.class)
public abstract class BaseLoanIntegrationTest {
public abstract class BaseLoanIntegrationTest extends IntegrationTest {

protected static final String DATETIME_PATTERN = "dd MMMM yyyy";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
package org.apache.fineract.integrationtests;

import static org.apache.fineract.integrationtests.client.IntegrationTest.assertThat;
import static org.apache.fineract.integrationtests.common.ClientHelper.DEFAULT_DATE;
import static org.apache.fineract.integrationtests.common.ClientHelper.LEGALFORM_ID_PERSON;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down Expand Up @@ -232,9 +232,9 @@ public void testClientAddressCreationWorks() {
List<GetClientClientIdAddressesResponse> clientAddresses = ClientHelper.getClientAddresses(requestSpec, responseSpec, clientId);
GetClientClientIdAddressesResponse addressResponse = clientAddresses.get(0);
assertThat(addressResponse.getCity()).isEqualTo(city);
assertThat(addressResponse.getCountryId()).isEqualTo(countryId);
assertThat(addressResponse.getStateProvinceId()).isEqualTo(stateId);
assertThat(addressResponse.getAddressTypeId()).isEqualTo(addressTypeId);
assertThat(addressResponse.getCountryId()).isEqualTo((long) countryId);
assertThat(addressResponse.getStateProvinceId()).isEqualTo((long) stateId);
assertThat(addressResponse.getAddressTypeId()).isEqualTo((long) addressTypeId);
assertThat(addressResponse.getIsActive()).isEqualTo(addressIsActive);
assertThat(addressResponse.getPostalCode()).isEqualTo(postalCode);
}
Expand Down Expand Up @@ -262,9 +262,9 @@ public void testClientAddressCreationWorksAfterClientIsCreated() {
List<GetClientClientIdAddressesResponse> clientAddresses = ClientHelper.getClientAddresses(requestSpec, responseSpec, clientId);
GetClientClientIdAddressesResponse addressResponse = clientAddresses.get(0);
assertThat(addressResponse.getCity()).isEqualTo(city);
assertThat(addressResponse.getCountryId()).isEqualTo(countryId);
assertThat(addressResponse.getStateProvinceId()).isEqualTo(stateId);
assertThat(addressResponse.getAddressTypeId()).isEqualTo(addressTypeId);
assertThat(addressResponse.getCountryId()).isEqualTo((long) countryId);
assertThat(addressResponse.getStateProvinceId()).isEqualTo((long) stateId);
assertThat(addressResponse.getAddressTypeId()).isEqualTo((long) addressTypeId);
assertThat(addressResponse.getIsActive()).isEqualTo(addressIsActive);
assertThat(addressResponse.getPostalCode()).isEqualTo(postalCode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType.BUSINESS_DATE;
import static org.apache.fineract.portfolio.delinquency.domain.DelinquencyAction.PAUSE;
import static org.apache.fineract.portfolio.delinquency.domain.DelinquencyAction.RESUME;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

import com.google.common.truth.Truth;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand Down Expand Up @@ -52,6 +51,7 @@
import org.apache.fineract.infrastructure.core.api.JsonQuery;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.integrationtests.client.IntegrationTest;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
Expand Down Expand Up @@ -82,7 +82,7 @@

@Slf4j
@SuppressWarnings({ "unused", "unchecked", "rawtypes", "static-access" })
public class FixedDepositTest {
public class FixedDepositTest extends IntegrationTest {

private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
Expand Down Expand Up @@ -1946,8 +1946,7 @@ public void testMaturityAmountForDailyCompoundingAndMonthlyPosting_With_360_Days
maturityAmount = new BigDecimal(maturityAmount).setScale(0, RoundingMode.FLOOR).floatValue();
log.info("{}", principal.toString());

Truth.assertWithMessage("Verifying Maturity amount for Fixed Deposit Account").that(maturityAmount).isAnyOf(principal,
principal - 1); // FINERACT-887
assertThat(maturityAmount).isIn(principal, principal - 1); // FINERACT-887
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.fineract.integrationtests;

import static org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType.BUSINESS_DATE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static java.lang.Boolean.TRUE;
import static org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType.BUSINESS_DATE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.fineract.integrationtests;

import static org.assertj.core.api.Assertions.assertThat;

import java.math.BigDecimal;
import java.util.List;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void submitSavingsAccountsApplication() {
request.submittedOnDate(formattedDate);
request.setExternalId(EXTERNAL_ID);

Response<PostSavingsAccountsResponse> response = okR(fineract().savingsAccounts.submitApplication2(request));
Response<PostSavingsAccountsResponse> response = okR(fineractClient().savingsAccounts.submitApplication2(request));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand All @@ -71,7 +71,7 @@ void updateSavingsAccountWithExternalId() {
PutSavingsAccountsAccountIdRequest request = new PutSavingsAccountsAccountIdRequest();
request.setLocale(locale);
request.setNominalAnnualInterestRate(5.999);
Response<PutSavingsAccountsAccountIdResponse> response = okR(fineract().savingsAccounts.update21(EXTERNAL_ID, request, ""));
Response<PutSavingsAccountsAccountIdResponse> response = okR(fineractClient().savingsAccounts.update21(EXTERNAL_ID, request, ""));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand All @@ -86,7 +86,7 @@ void approveSavingsAccount() {
request.setLocale(locale);
request.setApprovedOnDate(formattedDate);
Response<PostSavingsAccountsAccountIdResponse> response = okR(
fineract().savingsAccounts.handleCommands7(EXTERNAL_ID, request, "approve"));
fineractClient().savingsAccounts.handleCommands7(EXTERNAL_ID, request, "approve"));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand All @@ -100,7 +100,8 @@ void retrieveSavingsAccountWithExternalId() {
request.dateFormat(dateFormat);
request.setLocale(locale);
request.setActivatedOnDate(formattedDate);
Response<GetSavingsAccountsAccountIdResponse> response = okR(fineract().savingsAccounts.retrieveOne26(EXTERNAL_ID, false, "all"));
Response<GetSavingsAccountsAccountIdResponse> response = okR(
fineractClient().savingsAccounts.retrieveOne26(EXTERNAL_ID, false, "all"));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand All @@ -114,7 +115,7 @@ void undoApprovalSavingsAccountWithExternalId() {
LOG.info("------------------------------ UNDO APPROVAL SAVINGS ACCOUNT ---------------------------------------");
PostSavingsAccountsAccountIdRequest request = new PostSavingsAccountsAccountIdRequest();
Response<PostSavingsAccountsAccountIdResponse> response = okR(
fineract().savingsAccounts.handleCommands7(EXTERNAL_ID, request, "undoapproval"));
fineractClient().savingsAccounts.handleCommands7(EXTERNAL_ID, request, "undoapproval"));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand All @@ -128,7 +129,8 @@ void retrieveSavingsAccountWithExternalIdSecondTime() {
request.dateFormat(dateFormat);
request.setLocale(locale);
request.setActivatedOnDate(formattedDate);
Response<GetSavingsAccountsAccountIdResponse> response = okR(fineract().savingsAccounts.retrieveOne26(EXTERNAL_ID, false, "all"));
Response<GetSavingsAccountsAccountIdResponse> response = okR(
fineractClient().savingsAccounts.retrieveOne26(EXTERNAL_ID, false, "all"));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand All @@ -143,7 +145,7 @@ void deleteSavingsAccountWithExternalId() {
request.dateFormat(dateFormat);
request.setLocale(locale);
request.setActivatedOnDate(formattedDate);
Response<DeleteSavingsAccountsAccountIdResponse> response = okR(fineract().savingsAccounts.delete20(EXTERNAL_ID));
Response<DeleteSavingsAccountsAccountIdResponse> response = okR(fineractClient().savingsAccounts.delete20(EXTERNAL_ID));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand All @@ -158,7 +160,7 @@ void retrieveSavingsAccountWithExternalIdThirdTime() {
request.setLocale(locale);
request.setActivatedOnDate(formattedDate);
Response<GetSavingsAccountsAccountIdResponse> response = Calls
.executeU(fineract().savingsAccounts.retrieveOne26(EXTERNAL_ID, false, "all"));
.executeU(fineractClient().savingsAccounts.retrieveOne26(EXTERNAL_ID, false, "all"));

assertThat(response.raw().code()).isEqualTo(404);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void submitSavingsAccountsApplication() {
request.setDateFormat(dateFormat);
request.submittedOnDate(formattedDate);

Response<PostSavingsAccountsResponse> response = okR(fineract().savingsAccounts.submitApplication2(request));
Response<PostSavingsAccountsResponse> response = okR(fineractClient().savingsAccounts.submitApplication2(request));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand All @@ -73,7 +73,7 @@ void approveSavingsAccount() {
request.setLocale(locale);
request.setApprovedOnDate(formattedDate);
Response<PostSavingsAccountsAccountIdResponse> response = okR(
fineract().savingsAccounts.handleCommands6((long) savingId, request, "approve"));
fineractClient().savingsAccounts.handleCommands6((long) savingId, request, "approve"));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand All @@ -88,7 +88,7 @@ void activateSavingsAccount() {
request.setLocale(locale);
request.setActivatedOnDate(formattedDate);
Response<PostSavingsAccountsAccountIdResponse> response = okR(
fineract().savingsAccounts.handleCommands6((long) savingId, request, "activate"));
fineractClient().savingsAccounts.handleCommands6((long) savingId, request, "activate"));

assertThat(response.isSuccessful()).isTrue();
assertThat(response.body()).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.common.truth.Truth;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
Expand Down Expand Up @@ -60,6 +59,7 @@
import org.apache.fineract.client.models.PutJobsJobIDRequest;
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
import org.apache.fineract.infrastructure.configuration.api.GlobalConfigurationConstants;
import org.apache.fineract.integrationtests.client.IntegrationTest;
import org.apache.fineract.integrationtests.common.BusinessDateHelper;
import org.apache.fineract.integrationtests.common.BusinessStepHelper;
import org.apache.fineract.integrationtests.common.ClientHelper;
Expand Down Expand Up @@ -101,7 +101,7 @@
@TestMethodOrder(MethodName.class)
@ExtendWith(LoanTestLifecycleExtension.class)
@SuppressWarnings({ "unchecked", "rawtypes" })
public class SchedulerJobsTestResults {
public class SchedulerJobsTestResults extends IntegrationTest {

private static final String FROM_ACCOUNT_TYPE_SAVINGS = "2";
private static final String TO_ACCOUNT_TYPE_SAVINGS = "2";
Expand Down Expand Up @@ -212,8 +212,7 @@ public void testApplyAnnualFeeForSavingsJobOutcome() throws InterruptedException
annualFeeDueDateAsArrayList.get(2));
LocalDate expectedDueDate = LocalDate.of(2023, 1, 15);

Truth.assertWithMessage("Verifying that all due Annual Fees have been paid").that(nextDueDateForAnnualFee)
.isEquivalentAccordingToCompareTo(expectedDueDate);
assertThat(nextDueDateForAnnualFee).isEqualTo(expectedDueDate);
} finally {
savingsAccountHelper.closeSavingsAccountOnDate(savingsId, "true", "11 November 2022");
globalConfigurationHelper.updateGlobalConfiguration(GlobalConfigurationConstants.ENABLE_BUSINESS_DATE,
Expand Down
Loading

0 comments on commit 894b6cb

Please sign in to comment.