From fb520fc8177d59270ebf1f749a7aa0e20842cd86 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Wed, 7 Feb 2024 12:14:10 +0530 Subject: [PATCH] test: better size assertions in tests (#30937) Instead of a failure showing up like this: ``` org.opentest4j.AssertionFailedError: expected: 2 but was: 0 Expected :2 Actual :0 ``` We get something like this: ``` java.lang.AssertionError: Expected size: 2 but was: 0 in: {} ``` Which is a better insight into the test failure. --- .../exports/internal/ExportServiceTests.java | 10 ++-- .../appsmith/server/git/GitExecutorTest.java | 6 +- .../FeatureFlagMigrationHelperTest.java | 14 ++--- .../server/helpers/TextUtilsTest.java | 2 +- .../imports/internal/ImportServiceTests.java | 60 +++++++++---------- .../ce/RefactoringServiceCETest.java | 2 +- .../CustomUserDataRepositoryTest.java | 6 +- ...mActionCollectionRepositoryCEImplTest.java | 10 ++-- .../CustomNewActionRepositoryCEImplTest.java | 14 ++--- .../ce/CustomNewPageRepositoryTest.java | 10 ++-- .../services/ActionCollectionServiceTest.java | 6 +- .../services/ApplicationPageServiceTest.java | 4 +- .../ApplicationSnapshotServiceTest.java | 4 +- .../ApplicationTemplateServiceUnitTest.java | 4 +- .../services/CurlImporterServiceTest.java | 22 +++---- .../services/DatasourceServiceTest.java | 4 +- .../services/LayoutActionServiceTest.java | 14 ++--- .../server/services/LayoutServiceTest.java | 2 +- .../server/services/PageServiceTest.java | 8 +-- .../server/services/ThemeServiceTest.java | 4 +- .../server/services/UserDataServiceTest.java | 31 ++++------ .../UserWorkspaceServiceUnitTest.java | 9 ++- .../server/services/WorkspaceServiceTest.java | 4 +- .../services/ce/ActionServiceCE_Test.java | 8 +-- .../services/ce/ApplicationServiceCETest.java | 22 +++---- .../services/ce/FeatureFlagServiceCETest.java | 2 +- .../server/services/ce/GitServiceCETest.java | 10 ++-- .../services/ce/NewActionServiceTest.java | 2 +- .../services/ce/TenantServiceCETest.java | 7 +-- .../solutions/ApplicationFetcherTest.java | 7 +-- .../solutions/ApplicationFetcherUnitTest.java | 20 +++---- .../ApplicationForkingServiceTests.java | 2 +- .../DatasourceStructureSolutionTest.java | 12 ++-- .../ImportApplicationServiceTests.java | 60 +++++++++---------- .../solutions/PartialExportServiceTest.java | 10 ++-- .../solutions/PartialImportServiceTest.java | 20 +++---- 36 files changed, 205 insertions(+), 227 deletions(-) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/exports/internal/ExportServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/exports/internal/ExportServiceTests.java index 3bed3522e7..d4425413b8 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/exports/internal/ExportServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/exports/internal/ExportServiceTests.java @@ -1820,7 +1820,7 @@ public class ExportServiceTests { StepVerifier.create(resultMono) .assertNext(applicationJson -> { List pages = applicationJson.getPageList(); - assertThat(pages.size()).isEqualTo(2); + assertThat(pages).hasSize(2); assertThat(pages.get(1).getUnpublishedPage().getName()).isEqualTo("page_" + randomId); assertThat(pages.get(1).getUnpublishedPage().getIcon()).isEqualTo("flight"); }) @@ -1990,18 +1990,18 @@ public class ExportServiceTests { assertThat(updatedActionCollectionNames).isNotNull(); // only the first page should be present in the updated resources - assertThat(updatedPageNames.size()).isEqualTo(1); + assertThat(updatedPageNames).hasSize(1); assertThat(updatedPageNames).contains(renamedPageName); // only actions from first page should be present in the updated resources // 1 query + 1 method from action collection - assertThat(updatedActionNames.size()).isEqualTo(2); + assertThat(updatedActionNames).hasSize(2); assertThat(updatedActionNames).contains("first_page_action" + NAME_SEPARATOR + renamedPageName); assertThat(updatedActionNames) .contains("TestJsObject.testMethod" + NAME_SEPARATOR + renamedPageName); // only action collections from first page should be present in the updated resources - assertThat(updatedActionCollectionNames.size()).isEqualTo(1); + assertThat(updatedActionCollectionNames).hasSize(1); assertThat(updatedActionCollectionNames) .contains("TestJsObject" + NAME_SEPARATOR + renamedPageName); }) @@ -2089,7 +2089,7 @@ public class ExportServiceTests { assertThat(updatedActionNames).isNotNull(); // action should be present in the updated resources although action not updated but datasource is - assertThat(updatedActionNames.size()).isEqualTo(1); + assertThat(updatedActionNames).hasSize(1); updatedActionNames.forEach(actionName -> { assertThat(actionName).contains("MyAction"); }); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/GitExecutorTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/GitExecutorTest.java index e0fedd0dc5..fc4b5658b2 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/git/GitExecutorTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/git/GitExecutorTest.java @@ -406,7 +406,7 @@ public class GitExecutorTest { StepVerifier.create(mergeStatusDTOMono) .assertNext(mergeStatusDTO -> { assertThat(mergeStatusDTO.isMergeAble()).isEqualTo(Boolean.FALSE); - assertThat(mergeStatusDTO.getConflictingFiles().size()).isEqualTo(1); + assertThat(mergeStatusDTO.getConflictingFiles()).hasSize(1); assertThat(mergeStatusDTO.getConflictingFiles().get(0)).isEqualTo("TestFIle4"); }) .verifyComplete(); @@ -429,7 +429,7 @@ public class GitExecutorTest { StepVerifier.create(status) .assertNext(gitLogDTOS -> { - assertThat(gitLogDTOS.size()).isEqualTo(1); + assertThat(gitLogDTOS).hasSize(1); assertThat(gitLogDTOS.get(0).getCommitMessage()).isEqualTo("Test commit"); assertThat(gitLogDTOS.get(0).getAuthorName()).isEqualTo("test"); assertThat(gitLogDTOS.get(0).getAuthorEmail()).isEqualTo("test@test.com"); @@ -501,7 +501,7 @@ public class GitExecutorTest { assertThat(gitStatusDTO.getIsClean()).isEqualTo(Boolean.FALSE); assertThat(gitStatusDTO.getAheadCount()).isEqualTo(0); assertThat(gitStatusDTO.getBehindCount()).isEqualTo(0); - assertThat(gitStatusDTO.getModified().size()).isEqualTo(1); + assertThat(gitStatusDTO.getModified()).hasSize(1); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/FeatureFlagMigrationHelperTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/FeatureFlagMigrationHelperTest.java index c1ca84100e..55779d78c9 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/FeatureFlagMigrationHelperTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/FeatureFlagMigrationHelperTest.java @@ -74,7 +74,7 @@ class FeatureFlagMigrationHelperTest { StepVerifier.create(getUpdatedFlagsWithPendingMigration) .assertNext(featureFlagEnumFeatureMigrationTypeMap -> { assertThat(featureFlagEnumFeatureMigrationTypeMap).isNotEmpty(); - assertThat(featureFlagEnumFeatureMigrationTypeMap.size()).isEqualTo(1); + assertThat(featureFlagEnumFeatureMigrationTypeMap).hasSize(1); assertThat(featureFlagEnumFeatureMigrationTypeMap.get(TENANT_TEST_FEATURE)) .isEqualTo(DISABLE); }) @@ -112,7 +112,7 @@ class FeatureFlagMigrationHelperTest { StepVerifier.create(getUpdatedFlagsWithPendingMigration) .assertNext(featureFlagEnumFeatureMigrationTypeMap -> { assertThat(featureFlagEnumFeatureMigrationTypeMap).isNotEmpty(); - assertThat(featureFlagEnumFeatureMigrationTypeMap.size()).isEqualTo(1); + assertThat(featureFlagEnumFeatureMigrationTypeMap).hasSize(1); assertThat(featureFlagEnumFeatureMigrationTypeMap.get(TENANT_TEST_FEATURE)) .isEqualTo(ENABLE); }) @@ -144,7 +144,7 @@ class FeatureFlagMigrationHelperTest { .assertNext(featureFlagEnumFeatureMigrationTypeMap -> { assertThat(featureFlagEnumFeatureMigrationTypeMap).isNotNull(); assertThat(featureFlagEnumFeatureMigrationTypeMap).isEmpty(); - assertThat(featureFlagEnumFeatureMigrationTypeMap.size()).isEqualTo(0); + assertThat(featureFlagEnumFeatureMigrationTypeMap).hasSize(0); }) .verifyComplete(); } @@ -182,7 +182,7 @@ class FeatureFlagMigrationHelperTest { .assertNext(featureFlagEnumFeatureMigrationTypeMap -> { assertThat(featureFlagEnumFeatureMigrationTypeMap).isNotNull(); assertThat(featureFlagEnumFeatureMigrationTypeMap).isEmpty(); - assertThat(featureFlagEnumFeatureMigrationTypeMap.size()).isEqualTo(0); + assertThat(featureFlagEnumFeatureMigrationTypeMap).hasSize(0); }) .verifyComplete(); } @@ -218,10 +218,8 @@ class FeatureFlagMigrationHelperTest { StepVerifier.create(resultMono) .assertNext(result -> { assertThat(result).isTrue(); - assertThat(tenantConfiguration - .getFeaturesWithPendingMigration() - .size()) - .isEqualTo(1); + assertThat(tenantConfiguration.getFeaturesWithPendingMigration()) + .hasSize(1); assertThat(tenantConfiguration.getMigrationStatus()).isEqualTo(PENDING); }) .verifyComplete(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/TextUtilsTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/TextUtilsTest.java index 602fd65a6b..57db7a3be3 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/TextUtilsTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/TextUtilsTest.java @@ -32,7 +32,7 @@ public class TextUtilsTest { private void checkFromCsv(String inputString, int expectedSize, String... parts) { Set s1 = TextUtils.csvToSet(inputString); - assertThat(s1.size()).isEqualTo(expectedSize); + assertThat(s1).hasSize(expectedSize); assertThat(s1).contains(parts); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java index 9cf52eb3b4..463339ecd1 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/imports/internal/ImportServiceTests.java @@ -1634,8 +1634,8 @@ public class ImportServiceTests { assertThat(applicationPageIdsBeforeImport).hasSize(2); assertThat(applicationPageIdsBeforeImport).contains(savedPage.getId()); - assertThat(newPages.size()).isEqualTo(1); - assertThat(importedApplication.getPages().size()).isEqualTo(1); + assertThat(newPages).hasSize(1); + assertThat(importedApplication.getPages()).hasSize(1); assertThat(importedApplication.getPages().get(0).getId()) .isEqualTo(newPages.get(0).getId()); assertThat(newPages.get(0).getPublishedPage().getName()).isEqualTo("importedPage"); @@ -1701,7 +1701,7 @@ public class ImportServiceTests { .assertNext(newPages -> { // Check before import we had both the pages assertThat(applicationPageIdsBeforeImport).hasSize(1); - assertThat(newPages.size()).isEqualTo(3); + assertThat(newPages).hasSize(3); List pageNames = newPages.stream() .map(newPage -> newPage.getUnpublishedPage().getName()) .collect(Collectors.toList()); @@ -3600,14 +3600,14 @@ public class ImportServiceTests { .isFalse(); assertThat(applicationPagesDTO.getApplication().getForkingEnabled()) .isFalse(); - assertThat(applicationPagesDTO.getPages().size()).isEqualTo(4); + assertThat(applicationPagesDTO.getPages()).hasSize(4); List pageNames = applicationPagesDTO.getPages().stream() .map(PageNameIdDTO::getName) .collect(Collectors.toList()); assertThat(pageNames).contains("Home", "Home2", "About"); - assertThat(newActionList.size()).isEqualTo(2); // we imported two pages and each page has one action - assertThat(actionCollectionList.size()) - .isEqualTo(2); // we imported two pages and each page has one Collection + assertThat(newActionList).hasSize(2); // we imported two pages and each page has one action + assertThat(actionCollectionList) + .hasSize(2); // we imported two pages and each page has one Collection }) .verifyComplete(); } @@ -3648,7 +3648,7 @@ public class ImportServiceTests { StepVerifier.create(applicationPagesDTOMono) .assertNext(applicationPagesDTO -> { - assertThat(applicationPagesDTO.getPages().size()).isEqualTo(4); + assertThat(applicationPagesDTO.getPages()).hasSize(4); List pageNames = applicationPagesDTO.getPages().stream() .map(PageNameIdDTO::getName) .collect(Collectors.toList()); @@ -3797,8 +3797,8 @@ public class ImportServiceTests { assertThat(application1.getId()).isEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application1.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application1.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application1.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -3888,8 +3888,8 @@ public class ImportServiceTests { assertThat(application1.getId()).isEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application1.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application1.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application1.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -3998,8 +3998,8 @@ public class ImportServiceTests { assertThat(application3.getId()).isNotEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application3.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application3.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application3.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4109,8 +4109,8 @@ public class ImportServiceTests { assertThat(application3.getId()).isNotEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application3.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application3.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application3.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4220,8 +4220,8 @@ public class ImportServiceTests { assertThat(application3.getId()).isNotEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application3.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application3.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application3.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4296,8 +4296,8 @@ public class ImportServiceTests { assertThat(application1.getId()).isEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application1.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application1.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application1.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4376,8 +4376,8 @@ public class ImportServiceTests { assertThat(application1.getId()).isEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application1.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application1.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application1.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4435,7 +4435,7 @@ public class ImportServiceTests { .findAllApplicationsByWorkspaceId(workspaceId) .collectList()) .assertNext(applications -> { - assertThat(applicationList.size()).isEqualTo(applications.size()); + assertThat(applicationList).hasSize(applications.size()); }) .verifyComplete(); } @@ -4590,7 +4590,7 @@ public class ImportServiceTests { StepVerifier.create(resultMono) .assertNext(applicationJson -> { List pages = applicationJson.getPageList(); - assertThat(pages.size()).isEqualTo(2); + assertThat(pages).hasSize(2); assertThat(pages.get(1).getUnpublishedPage().getName()).isEqualTo("page_" + randomId); assertThat(pages.get(1).getUnpublishedPage().getIcon()).isEqualTo("flight"); }) @@ -4651,8 +4651,8 @@ public class ImportServiceTests { List actionList = tuple.getT3(); List actionCollectionList = tuple.getT4(); - assertThat(pageList.size()).isEqualTo(2); - assertThat(actionList.size()).isEqualTo(3); + assertThat(pageList).hasSize(2); + assertThat(actionList).hasSize(3); List pageNames = pageList.stream() .map(p -> p.getUnpublishedPage().getName()) @@ -5089,18 +5089,18 @@ public class ImportServiceTests { assertThat(updatedActionCollectionNames).isNotNull(); // only the first page should be present in the updated resources - assertThat(updatedPageNames.size()).isEqualTo(1); + assertThat(updatedPageNames).hasSize(1); assertThat(updatedPageNames).contains(renamedPageName); // only actions from first page should be present in the updated resources // 1 query + 1 method from action collection - assertThat(updatedActionNames.size()).isEqualTo(2); + assertThat(updatedActionNames).hasSize(2); assertThat(updatedActionNames).contains("first_page_action" + NAME_SEPARATOR + renamedPageName); assertThat(updatedActionNames) .contains("TestJsObject.testMethod" + NAME_SEPARATOR + renamedPageName); // only action collections from first page should be present in the updated resources - assertThat(updatedActionCollectionNames.size()).isEqualTo(1); + assertThat(updatedActionCollectionNames).hasSize(1); assertThat(updatedActionCollectionNames) .contains("TestJsObject" + NAME_SEPARATOR + renamedPageName); }) @@ -5185,7 +5185,7 @@ public class ImportServiceTests { assertThat(updatedActionNames).isNotNull(); // action should be present in the updated resources although action not updated but datasource is - assertThat(updatedActionNames.size()).isEqualTo(1); + assertThat(updatedActionNames).hasSize(1); updatedActionNames.forEach(actionName -> { assertThat(actionName).contains("MyAction"); }); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java index 0178353b15..f14f1aeb11 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java @@ -823,7 +823,7 @@ class RefactoringServiceCETest { assertThat(actionCollection.getUnpublishedCollection().getBody()) .isEqualTo("export default { x : \tNewNameTable1 }"); final ActionDTO unpublishedAction = action.getUnpublishedAction(); - assertThat(unpublishedAction.getJsonPathKeys().size()).isEqualTo(1); + assertThat(unpublishedAction.getJsonPathKeys()).hasSize(1); final Optional first = unpublishedAction.getJsonPathKeys().stream().findFirst(); assert first.isPresent(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/CustomUserDataRepositoryTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/CustomUserDataRepositoryTest.java index 3de30a5f01..4be0eb2736 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/CustomUserDataRepositoryTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/CustomUserDataRepositoryTest.java @@ -114,7 +114,7 @@ public class CustomUserDataRepositoryTest { StepVerifier.create(userDataAfterUpdateMono) .assertNext(userData -> { List recentlyUsedAppIds = userData.getRecentlyUsedAppIds(); - assertThat(recentlyUsedAppIds.size()).isEqualTo(1); + assertThat(recentlyUsedAppIds).hasSize(1); assertThat(recentlyUsedAppIds.get(0)).isEqualTo("456"); }) .verifyComplete(); @@ -144,10 +144,10 @@ public class CustomUserDataRepositoryTest { .assertNext(userData -> { List recentlyUsedAppIds = userData.getRecentlyUsedAppIds(); List recentlyUsedWorkspaceIds = userData.getRecentlyUsedWorkspaceIds(); - assertThat(recentlyUsedAppIds.size()).isEqualTo(1); + assertThat(recentlyUsedAppIds).hasSize(1); assertThat(recentlyUsedAppIds.get(0)).isEqualTo("456"); - assertThat(recentlyUsedWorkspaceIds.size()).isEqualTo(2); + assertThat(recentlyUsedWorkspaceIds).hasSize(2); assertThat(recentlyUsedWorkspaceIds).contains("abc", "hij"); }) .verifyComplete(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImplTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImplTest.java index d16307fafb..7fd4fbd141 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImplTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomActionCollectionRepositoryCEImplTest.java @@ -51,7 +51,7 @@ public class CustomActionCollectionRepositoryCEImplTest { StepVerifier.create(actionCollectionFlux.collectList()) .assertNext(actionCollectionList -> { - assertThat(actionCollectionList.size()).isEqualTo(5); + assertThat(actionCollectionList).hasSize(5); actionCollectionList.forEach(newAction -> { assertThat(newAction.getWorkspaceId()).isEqualTo("workspace-" + newAction.getId()); }); @@ -97,7 +97,7 @@ public class CustomActionCollectionRepositoryCEImplTest { StepVerifier.create(actionCollectionsMono) .assertNext(actionCollections -> { - assertThat(actionCollections.size()).isEqualTo(5); + assertThat(actionCollections).hasSize(5); actionCollections.forEach(newAction -> { assertThat(newAction.getWorkspaceId()).isEqualTo("workspace-" + newAction.getId()); }); @@ -135,7 +135,7 @@ public class CustomActionCollectionRepositoryCEImplTest { StepVerifier.create(actionCollectionListMono) .assertNext(actionCollectionList -> { - assertThat(actionCollectionList.size()).isEqualTo(1); + assertThat(actionCollectionList).hasSize(1); }) .verifyComplete(); @@ -147,7 +147,7 @@ public class CustomActionCollectionRepositoryCEImplTest { StepVerifier.create(actionCollectionListMono2) .assertNext(actionCollectionList -> { - assertThat(actionCollectionList.size()).isEqualTo(0); + assertThat(actionCollectionList).hasSize(0); }) .verifyComplete(); @@ -159,7 +159,7 @@ public class CustomActionCollectionRepositoryCEImplTest { StepVerifier.create(actionCollectionListMono3) .assertNext(actionCollectionList -> { - assertThat(actionCollectionList.size()).isEqualTo(0); + assertThat(actionCollectionList).hasSize(0); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImplTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImplTest.java index 9041d20692..38727211cf 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImplTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewActionRepositoryCEImplTest.java @@ -60,7 +60,7 @@ public class CustomNewActionRepositoryCEImplTest { StepVerifier.create(newActionFlux.collectList()) .assertNext(newActions -> { - assertThat(newActions.size()).isEqualTo(5); + assertThat(newActions).hasSize(5); newActions.forEach(newAction -> { assertThat(newAction.getWorkspaceId()).isEqualTo("workspace-" + newAction.getId()); }); @@ -105,7 +105,7 @@ public class CustomNewActionRepositoryCEImplTest { StepVerifier.create(newActionsMono) .assertNext(newActions -> { - assertThat(newActions.size()).isEqualTo(5); + assertThat(newActions).hasSize(5); newActions.forEach(newAction -> { assertThat(newAction.getWorkspaceId()).isEqualTo("workspace-" + newAction.getId()); }); @@ -178,7 +178,7 @@ public class CustomNewActionRepositoryCEImplTest { StepVerifier.create(pluginTypeAndCountDTOFlux.collectList()) .assertNext(list -> { - assertThat(list.size()).isEqualTo(3); + assertThat(list).hasSize(3); list.forEach(pluginTypeAndCountDTO -> { if (pluginTypeAndCountDTO.getPluginType().equals(PluginType.API)) { assertThat(pluginTypeAndCountDTO.getCount()).isEqualTo(2); @@ -218,8 +218,8 @@ public class CustomNewActionRepositoryCEImplTest { List app1Actions = objects.getT1(); List app2Actions = objects.getT2(); - assertThat(app1Actions.size()).isEqualTo(2); - assertThat(app2Actions.size()).isEqualTo(1); + assertThat(app1Actions).hasSize(2); + assertThat(app2Actions).hasSize(1); app1Actions.forEach(action -> { ActionDTO unpublishedActionDto = action.getUnpublishedAction(); @@ -272,8 +272,8 @@ public class CustomNewActionRepositoryCEImplTest { List app1Actions = objects.getT1(); List app2Actions = objects.getT2(); - assertThat(app1Actions.size()).isEqualTo(1); - assertThat(app2Actions.size()).isEqualTo(1); + assertThat(app1Actions).hasSize(1); + assertThat(app2Actions).hasSize(1); // merge actions from both list and verify they are in the same state when created List.of(app1Actions.get(0), app2Actions.get(0)).forEach(action -> { diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryTest.java index 4504d74a5e..7c89ee6a73 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/repositories/ce/CustomNewPageRepositoryTest.java @@ -66,8 +66,8 @@ class CustomNewPageRepositoryTest { StepVerifier.create(tuple2Mono) .assertNext(objects -> { - assertThat(objects.getT1().size()).isEqualTo(2); - assertThat(objects.getT2().size()).isEqualTo(1); + assertThat(objects.getT1()).hasSize(2); + assertThat(objects.getT2()).hasSize(1); objects.getT1().forEach(newPage -> { PageDTO publishedPage = newPage.getPublishedPage(); @@ -77,8 +77,8 @@ class CustomNewPageRepositoryTest { assertThat(publishedPage).isNotNull(); assertThat(unpublishedPage.getName()).isEqualTo(publishedPage.getName()); assertThat(unpublishedPage.getSlug()).isEqualTo(publishedPage.getSlug()); - assertThat(unpublishedPage.getLayouts().size()) - .isEqualTo(publishedPage.getLayouts().size()); + assertThat(unpublishedPage.getLayouts()) + .hasSize(publishedPage.getLayouts().size()); }); objects.getT2().forEach(newPage -> { @@ -93,7 +93,7 @@ class CustomNewPageRepositoryTest { assertThat(unpublishedPage.getSlug()).isNotNull(); assertThat(publishedPage.getSlug()).isNull(); - assertThat(unpublishedPage.getLayouts().size()).isEqualTo(1); + assertThat(unpublishedPage.getLayouts()).hasSize(1); assertThat(publishedPage.getLayouts()).isNull(); }); }) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionCollectionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionCollectionServiceTest.java index 17151e45b5..8a3d45c56a 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionCollectionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ActionCollectionServiceTest.java @@ -580,19 +580,19 @@ public class ActionCollectionServiceTest { StepVerifier.create(viewModeCollectionsMono) .assertNext(viewModeCollections -> { - assertThat(viewModeCollections.size()).isEqualTo(1); + assertThat(viewModeCollections).hasSize(1); final ActionCollectionViewDTO actionCollectionViewDTO = viewModeCollections.get(0); // Actions final List actions = actionCollectionViewDTO.getActions(); - assertThat(actions.size()).isEqualTo(1); + assertThat(actions).hasSize(1); assertThat(actions.get(0).getActionConfiguration().getBody()) .isEqualTo("mockBody"); // Variables final List variables = actionCollectionViewDTO.getVariables(); - assertThat(variables.size()).isEqualTo(1); + assertThat(variables).hasSize(1); assertThat(variables.get(0).getValue()).isEqualTo("test"); // Metadata diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationPageServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationPageServiceTest.java index 157ab8fd4a..248a7d4d8a 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationPageServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationPageServiceTest.java @@ -144,8 +144,8 @@ public class ApplicationPageServiceTest { StepVerifier.create(applicationMono) .assertNext(application -> { - assertThat(application.getPages().size()) - .isEqualTo(application.getPublishedPages().size()); + assertThat(application.getPages()) + .hasSize(application.getPublishedPages().size()); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationSnapshotServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationSnapshotServiceTest.java index 1d87285bb5..45bcb67b83 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationSnapshotServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationSnapshotServiceTest.java @@ -253,8 +253,8 @@ public class ApplicationSnapshotServiceTest { .assertNext(objects -> { ApplicationPagesDTO beforePages = objects.getT2(); ApplicationPagesDTO afterPages = objects.getT1(); - assertThat(beforePages.getPages().size()) - .isEqualTo(afterPages.getPages().size()); + assertThat(beforePages.getPages()) + .hasSize(afterPages.getPages().size()); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationTemplateServiceUnitTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationTemplateServiceUnitTest.java index e8fed2de45..4992737474 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationTemplateServiceUnitTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ApplicationTemplateServiceUnitTest.java @@ -126,7 +126,7 @@ public class ApplicationTemplateServiceUnitTest { StepVerifier.create(templateListMono) .assertNext(applicationTemplates -> { - assertThat(applicationTemplates.size()).isEqualTo(3); + assertThat(applicationTemplates).hasSize(3); }) .verifyComplete(); } @@ -155,7 +155,7 @@ public class ApplicationTemplateServiceUnitTest { // make sure we've received the response returned by the mockCloudServices StepVerifier.create(applicationTemplateService.getActiveTemplates(null)) .assertNext(applicationTemplates -> { - assertThat(applicationTemplates.size()).isEqualTo(1); + assertThat(applicationTemplates).hasSize(1); ApplicationTemplate applicationTemplate = applicationTemplates.get(0); assertThat(applicationTemplate.getPages()).hasSize(1); PageNameIdDTO pageNameIdDTO = applicationTemplate.getPages().get(0); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java index 9e7c102510..3103208da5 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlImporterServiceTest.java @@ -436,12 +436,9 @@ public class CurlImporterServiceTest { .getUrl()) .isEqualTo("http://localhost:8080"); assertThat(action1.getActionConfiguration().getPath()).isEqualTo("/api/v1/actions"); - assertThat(action1.getActionConfiguration().getHeaders().size()) - .isEqualTo(11); - assertThat(action1.getActionConfiguration() - .getQueryParameters() - .size()) - .isEqualTo(1); + assertThat(action1.getActionConfiguration().getHeaders()).hasSize(11); + assertThat(action1.getActionConfiguration().getQueryParameters()) + .hasSize(1); assertThat(action1.getActionConfiguration().getHttpMethod()).isEqualTo(HttpMethod.GET); assertThat(action1.getActionConfiguration().getBody()).isEqualTo("{someJson}"); @@ -499,12 +496,9 @@ public class CurlImporterServiceTest { .getUrl()) .isEqualTo("http://localhost:8080"); assertThat(action1.getActionConfiguration().getPath()).isEqualTo("/api/v1/actions"); - assertThat(action1.getActionConfiguration().getHeaders().size()) - .isEqualTo(11); - assertThat(action1.getActionConfiguration() - .getQueryParameters() - .size()) - .isEqualTo(1); + assertThat(action1.getActionConfiguration().getHeaders()).hasSize(11); + assertThat(action1.getActionConfiguration().getQueryParameters()) + .hasSize(1); assertThat(action1.getActionConfiguration().getHttpMethod()).isEqualTo(HttpMethod.GET); assertThat(action1.getActionConfiguration().getBody()).isEqualTo("{someJson}"); @@ -535,7 +529,7 @@ public class CurlImporterServiceTest { final ActionConfiguration actionConfiguration = action.getActionConfiguration(); assertThat(actionConfiguration.getPath()).isEqualTo("/scrap/api"); assertThat(actionConfiguration.getHeaders()).isNullOrEmpty(); - assertThat(actionConfiguration.getQueryParameters().size()).isEqualTo(2); + assertThat(actionConfiguration.getQueryParameters()).hasSize(2); assertThat(actionConfiguration.getHttpMethod()).isEqualTo(HttpMethod.POST); assertThat(actionConfiguration.getBody()).isNullOrEmpty(); } @@ -1092,7 +1086,7 @@ public class CurlImporterServiceTest { final ActionConfiguration actionConfiguration = actionDTO.getActionConfiguration(); assertThat(actionConfiguration.getPath()).isEqualTo("/{id}/users"); - assertThat(actionConfiguration.getQueryParameters().size()).isEqualTo(1); + assertThat(actionConfiguration.getQueryParameters()).hasSize(1); assertThat(actionConfiguration.getQueryParameters().get(0).getKey()).isEqualTo("name"); assertThat(actionConfiguration.getQueryParameters().get(0).getValue()).isEqualTo("test"); assertThat(actionConfiguration.getHttpMethod()).isEqualTo(HttpMethod.GET); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java index 47317b2b99..5c74c660df 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/DatasourceServiceTest.java @@ -1836,7 +1836,7 @@ public class DatasourceServiceTest { StepVerifier.create(listMono) .assertNext(datasources -> { - assertThat(datasources.size()).isEqualTo(4); + assertThat(datasources).hasSize(4); assertThat(datasources).allMatch(datasourceDTO -> Set.of("A", "B", "C", "D") .contains(datasourceDTO.getName())); @@ -1927,7 +1927,7 @@ public class DatasourceServiceTest { StepVerifier.create(datasourceMono) .assertNext(dbDatasource -> { - assertThat(dbDatasource.getDatasourceStorages().size()).isEqualTo(1); + assertThat(dbDatasource.getDatasourceStorages()).hasSize(1); assertThat(dbDatasource.getDatasourceStorages().get(defaultEnvironmentId)) .isNotNull(); DatasourceStorageDTO datasourceStorageDTO = diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java index 7e655b0c7e..ac18bdf707 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutActionServiceTest.java @@ -472,7 +472,7 @@ public class LayoutActionServiceTest { assertThat(actionDTO.getName()).isEqualTo("firstAction"); List actionUpdates = updatedLayout.getActionUpdates(); - assertThat(actionUpdates.size()).isEqualTo(1); + assertThat(actionUpdates).hasSize(1); assertThat(actionUpdates.get(0).getName()).isEqualTo("firstAction"); assertThat(actionUpdates.get(0).getExecuteOnLoad()).isTrue(); }) @@ -509,7 +509,7 @@ public class LayoutActionServiceTest { assertThat(actionDTO.getName()).isEqualTo("secondAction"); List actionUpdates = updatedLayout.getActionUpdates(); - assertThat(actionUpdates.size()).isEqualTo(2); + assertThat(actionUpdates).hasSize(2); Optional firstActionUpdateOptional = actionUpdates.stream() .filter(actionUpdate -> actionUpdate.getName().equals("firstAction")) @@ -747,7 +747,7 @@ public class LayoutActionServiceTest { StepVerifier.create(updateLayoutMono) .assertNext(updatedLayout -> { - assertThat(updatedLayout.getLayoutOnLoadActions().size()).isEqualTo(2); + assertThat(updatedLayout.getLayoutOnLoadActions()).hasSize(2); // Assert that both the actions don't belong to the same set. They should be run iteratively. DslExecutableDTO actionDTO = updatedLayout @@ -865,7 +865,7 @@ public class LayoutActionServiceTest { StepVerifier.create(updateLayoutMono) .assertNext(updatedLayout -> { - assertThat(updatedLayout.getLayoutOnLoadActions().size()).isEqualTo(2); + assertThat(updatedLayout.getLayoutOnLoadActions()).hasSize(2); // Assert that all three the actions dont belong to the same set final Set firstSet = @@ -958,7 +958,7 @@ public class LayoutActionServiceTest { StepVerifier.create(updateLayoutMono) .assertNext(updatedLayout -> { - assertThat(updatedLayout.getLayoutOnLoadActions().size()).isEqualTo(1); + assertThat(updatedLayout.getLayoutOnLoadActions()).hasSize(1); DslExecutableDTO actionDTO = updatedLayout .getLayoutOnLoadActions() @@ -1132,7 +1132,7 @@ public class LayoutActionServiceTest { StepVerifier.create(updateLayoutMono) .assertNext(updatedLayout -> { - assertThat(updatedLayout.getLayoutOnLoadActions().size()).isEqualTo(2); + assertThat(updatedLayout.getLayoutOnLoadActions()).hasSize(2); // Assert that both the actions don't belong to the same set. They should be run iteratively. DslExecutableDTO actionDTO1 = updatedLayout @@ -1204,7 +1204,7 @@ public class LayoutActionServiceTest { StepVerifier.create(updateLayoutMono) .assertNext(updatedLayout -> { - assertThat(updatedLayout.getLayoutOnLoadActions().size()).isEqualTo(1); + assertThat(updatedLayout.getLayoutOnLoadActions()).hasSize(1); // Assert that both the actions don't belong to the same set. They should be run iteratively. DslExecutableDTO actionDTO1 = updatedLayout diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java index 827ef2050f..6f5b86fb6b 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/LayoutServiceTest.java @@ -1385,7 +1385,7 @@ public class LayoutServiceTest { // We have reached here means we didn't get a throwable. That's good assertThat(layoutDTO).isNotNull(); // Since this is still a bad mustache binding, we couldn't have extracted the action name - assertThat(layoutDTO.getLayoutOnLoadActions().size()).isEqualTo(0); + assertThat(layoutDTO.getLayoutOnLoadActions()).hasSize(0); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java index 64c5dbd89a..b644d1f5e4 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/PageServiceTest.java @@ -728,7 +728,7 @@ public class PageServiceTest { // Confirm that the page action got copied as well List actions = tuple.getT2(); - assertThat(actions.size()).isEqualTo(2); + assertThat(actions).hasSize(2); NewAction actionWithoutCollection = actions.stream() .filter(newAction -> !StringUtils.hasLength( newAction.getUnpublishedAction().getCollectionId())) @@ -1101,7 +1101,7 @@ public class PageServiceTest { StepVerifier.create(applicationPageReOrdered) .assertNext(application -> { final List pages = application.getPages(); - assertThat(pages.size()).isEqualTo(4); + assertThat(pages).hasSize(4); assertThat(pages.get(0).getId()).isEqualTo(pageIds[0]); assertThat(pages.get(1).getId()).isEqualTo(pageIds[3]); assertThat(pages.get(2).getId()).isEqualTo(pageIds[1]); @@ -1152,7 +1152,7 @@ public class PageServiceTest { StepVerifier.create(applicationPageReOrdered) .assertNext(application -> { final List pages = application.getPages(); - assertThat(pages.size()).isEqualTo(4); + assertThat(pages).hasSize(4); assertThat(pages.get(3).getId()).isEqualTo(pageIds[0]); assertThat(pages.get(0).getId()).isEqualTo(pageIds[1]); assertThat(pages.get(1).getId()).isEqualTo(pageIds[2]); @@ -1200,7 +1200,7 @@ public class PageServiceTest { StepVerifier.create(applicationPageReOrdered) .assertNext(application -> { final List pages = application.getPages(); - assertThat(pages.size()).isEqualTo(4); + assertThat(pages).hasSize(4); assertThat(pages.get(3).getId()).isEqualTo(pageIds[0].getId()); assertThat(pages.get(0).getId()).isEqualTo(pageIds[1].getId()); assertThat(pages.get(1).getId()).isEqualTo(pageIds[2].getId()); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ThemeServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ThemeServiceTest.java index c94f435c69..500330cc5c 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ThemeServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ThemeServiceTest.java @@ -779,8 +779,8 @@ public class ThemeServiceTest { long systemThemesCount = availableThemes.stream() .filter(availableTheme -> availableTheme.isSystemTheme()) .count(); - assertThat(availableThemes.size()) - .isEqualTo(systemThemesCount + 1); // one custom theme + existing system themes + assertThat(availableThemes) + .hasSize((int) systemThemesCount + 1); // one custom theme + existing system themes // assert permissions by asserting that the themes have been found. assertThat(persistedThemeWithReadPermission.getId()).isNotNull(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserDataServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserDataServiceTest.java index d28fc941fc..ba421f349e 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserDataServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserDataServiceTest.java @@ -256,7 +256,7 @@ public class UserDataServiceTest { sampleWorkspaceId, userData.getRecentlyUsedWorkspaceIds().get(0)); - assertThat(userData.getRecentlyUsedEntityIds().size()).isEqualTo(1); + assertThat(userData.getRecentlyUsedEntityIds()).hasSize(1); assertThat(userData.getRecentlyUsedEntityIds().get(0).getWorkspaceId()) .isEqualTo(sampleWorkspaceId); }) @@ -297,7 +297,7 @@ public class UserDataServiceTest { "sample-org-id", userData.getRecentlyUsedWorkspaceIds().get(0)); - assertThat(userData.getRecentlyUsedEntityIds().size()).isEqualTo(3); + assertThat(userData.getRecentlyUsedEntityIds()).hasSize(3); assertThat(userData.getRecentlyUsedEntityIds().get(0).getWorkspaceId()) .isEqualTo("sample-org-id"); assertThat(userData.getRecentlyUsedEntityIds() @@ -349,15 +349,15 @@ public class UserDataServiceTest { StepVerifier.create(resultMono) .assertNext(userData -> { - assertThat(userData.getRecentlyUsedWorkspaceIds().size()).isEqualTo(MAX_RECENT_WORKSPACES_LIMIT); + assertThat(userData.getRecentlyUsedWorkspaceIds()).hasSize(MAX_RECENT_WORKSPACES_LIMIT); assertThat(userData.getRecentlyUsedWorkspaceIds().get(0)).isEqualTo(sampleWorkspaceId); assertThat(userData.getRecentlyUsedWorkspaceIds().get(9)).isEqualTo("org-9"); - assertThat(userData.getRecentlyUsedAppIds().size()).isEqualTo(MAX_RECENT_APPLICATIONS_LIMIT); + assertThat(userData.getRecentlyUsedAppIds()).hasSize(MAX_RECENT_APPLICATIONS_LIMIT); assertThat(userData.getRecentlyUsedAppIds().get(0)).isEqualTo(sampleAppId); assertThat(userData.getRecentlyUsedAppIds().get(19)).isEqualTo("app-19"); - assertThat(userData.getRecentlyUsedEntityIds().size()).isEqualTo(MAX_RECENT_WORKSPACES_LIMIT); + assertThat(userData.getRecentlyUsedEntityIds()).hasSize(MAX_RECENT_WORKSPACES_LIMIT); assertThat(userData.getRecentlyUsedEntityIds().get(0).getWorkspaceId()) .isEqualTo(sampleWorkspaceId); assertThat(userData.getRecentlyUsedEntityIds().get(9).getWorkspaceId()) @@ -367,20 +367,14 @@ public class UserDataServiceTest { .getApplicationIds() .get(0)) .isEqualTo(sampleAppId); - assertThat(userData.getRecentlyUsedEntityIds() - .get(0) - .getApplicationIds() - .size()) - .isEqualTo(1); + assertThat(userData.getRecentlyUsedEntityIds().get(0).getApplicationIds()) + .hasSize(1); // Truncation will be applied only after the specific entry for recently used entities goes through // the workflow assertThat(userData.getRecentlyUsedEntityIds().get(1).getWorkspaceId()) .isEqualTo("org-1"); - assertThat(userData.getRecentlyUsedEntityIds() - .get(1) - .getApplicationIds() - .size()) - .isEqualTo(22); + assertThat(userData.getRecentlyUsedEntityIds().get(1).getApplicationIds()) + .hasSize(22); }) .verifyComplete(); @@ -397,11 +391,8 @@ public class UserDataServiceTest { StepVerifier.create(updateRecentlyUsedEntitiesMono) .assertNext(userData -> { // Check whether a new org id is put at first. - assertThat(userData.getRecentlyUsedEntityIds() - .get(0) - .getApplicationIds() - .size()) - .isEqualTo(MAX_RECENT_APPLICATIONS_LIMIT); + assertThat(userData.getRecentlyUsedEntityIds().get(0).getApplicationIds()) + .hasSize(MAX_RECENT_APPLICATIONS_LIMIT); assertThat(userData.getRecentlyUsedEntityIds().get(0).getWorkspaceId()) .isEqualTo("org-1"); assertThat(userData.getRecentlyUsedEntityIds() diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserWorkspaceServiceUnitTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserWorkspaceServiceUnitTest.java index 7bbdf08c3e..27ab280072 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserWorkspaceServiceUnitTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/UserWorkspaceServiceUnitTest.java @@ -194,7 +194,7 @@ public class UserWorkspaceServiceUnitTest { StepVerifier.create(listMono) .assertNext(workspaceMemberInfoDTOS -> { - assertThat(workspaceMemberInfoDTOS.size()).isEqualTo(1); + assertThat(workspaceMemberInfoDTOS).hasSize(1); assertThat(workspaceMemberInfoDTOS.get(0).getPhotoId()).isEqualTo("sample-photo-id"); }) .verifyComplete(); @@ -226,8 +226,7 @@ public class UserWorkspaceServiceUnitTest { StepVerifier.create(mapMono) .assertNext(workspaceMemberInfoDTOSMap -> { - assertThat(workspaceMemberInfoDTOSMap.size()) - .isEqualTo(2); // should have 2 entries for 2 workspaces + assertThat(workspaceMemberInfoDTOSMap).hasSize(2); // should have 2 entries for 2 workspaces workspaceMemberInfoDTOSMap.values().forEach(workspaceMemberInfoDTOS -> { // should have one entry for the creator member only, get that MemberInfoDTO workspaceMemberInfoDTO = workspaceMemberInfoDTOS.get(0); @@ -254,7 +253,7 @@ public class UserWorkspaceServiceUnitTest { StepVerifier.create(userWorkspaceService.getUserWorkspacesByRecentlyUsedOrder()) .assertNext(workspaces -> { - assertThat(workspaces.size()).isEqualTo(4); + assertThat(workspaces).hasSize(4); workspaces.forEach(workspace -> { assertThat(workspaceIds.contains(workspace.getId())).isTrue(); assertThat(workspace.getTenantId()).isNotEmpty(); @@ -281,7 +280,7 @@ public class UserWorkspaceServiceUnitTest { StepVerifier.create(userWorkspaceService.getUserWorkspacesByRecentlyUsedOrder()) .assertNext(workspaces -> { - assertThat(workspaces.size()).isEqualTo(4); + assertThat(workspaces).hasSize(4); List fetchedWorkspaceIds = new ArrayList<>(); workspaces.forEach(workspace -> { fetchedWorkspaceIds.add(workspace.getId()); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/WorkspaceServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/WorkspaceServiceTest.java index 96642a0f2d..1ee8dec66a 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/WorkspaceServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/WorkspaceServiceTest.java @@ -193,7 +193,7 @@ public class WorkspaceServiceTest { assertThat(workspace1.getEmail()).isEqualTo("api_user"); assertThat(workspace1.getIsAutoGeneratedWorkspace()).isTrue(); assertThat(workspace1.getTenantId()).isEqualTo(user.getTenantId()); - assertThat(workspace1.getDefaultPermissionGroups().size()).isEqualTo(3); + assertThat(workspace1.getDefaultPermissionGroups()).hasSize(3); PermissionGroup adminPermissionGroup = permissionGroups.stream() .filter(permissionGroup -> permissionGroup.getName().startsWith(ADMINISTRATOR)) @@ -817,7 +817,7 @@ public class WorkspaceServiceTest { StepVerifier.create(usersMono) .assertNext(users -> { assertThat(users).isNotNull(); - assertThat(users.size()).isEqualTo(6); + assertThat(users).hasSize(6); // Assert that the members are sorted by the permission group and then email MemberInfoDTO userAndGroupDTO = users.get(0); assertThat(userAndGroupDTO.getUsername()).isEqualTo("api_user"); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java index bb15f9adc2..86d453bc8e 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ActionServiceCE_Test.java @@ -803,7 +803,7 @@ public class ActionServiceCE_Test { assertThat(actionViewDTO.getTimeoutInMillisecond()).isNotNull(); assertThat(actionViewDTO.getPageId()).isNotNull(); assertThat(actionViewDTO.getConfirmBeforeExecute()).isNotNull(); - assertThat(actionViewDTO.getJsonPathKeys().size()).isEqualTo(1); + assertThat(actionViewDTO.getJsonPathKeys()).hasSize(1); }) .verifyComplete(); } @@ -898,7 +898,7 @@ public class ActionServiceCE_Test { StepVerifier.create(newActionMono) .assertNext(actionDTO -> { assertThat(actionDTO).isNotNull(); - assertThat(actionDTO.getJsonPathKeys().size()).isEqualTo(1); + assertThat(actionDTO.getJsonPathKeys()).hasSize(1); assertThat(actionDTO.getJsonPathKeys()).isEqualTo(Set.of("one.text")); }) .verifyComplete(); @@ -946,7 +946,7 @@ public class ActionServiceCE_Test { .assertNext(actionDTO -> { assertThat(actionDTO).isNotNull(); assertThat(actionDTO.getActionConfiguration().getBody()).isEqualTo("New Body"); - assertThat(actionDTO.getJsonPathKeys().size()).isEqualTo(1); + assertThat(actionDTO.getJsonPathKeys()).hasSize(1); assertThat(actionDTO.getJsonPathKeys()).isEqualTo(Set.of("two.text")); }) .verifyComplete(); @@ -987,7 +987,7 @@ public class ActionServiceCE_Test { StepVerifier.create(newActionMono) .assertNext(actionDTO -> { assertThat(actionDTO).isNotNull(); - assertThat(actionDTO.getJsonPathKeys().size()).isEqualTo(0); + assertThat(actionDTO.getJsonPathKeys()).hasSize(0); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java index 7e389c34db..ecad3ba644 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java @@ -2783,7 +2783,7 @@ public class ApplicationServiceCETest { StepVerifier.create(forkedApp) .assertNext(application1 -> { - assertThat(application1.getPages().size()).isEqualTo(2); + assertThat(application1.getPages()).hasSize(2); }) .verifyComplete(); } @@ -3019,10 +3019,10 @@ public class ApplicationServiceCETest { List pages = tuple.getT2(); assertThat(application).isNotNull(); - assertThat(application.getPages().size()).isEqualTo(1); - assertThat(application.getPublishedPages().size()).isEqualTo(1); + assertThat(application.getPages()).hasSize(1); + assertThat(application.getPublishedPages()).hasSize(1); - assertThat(pages.size()).isEqualTo(1); + assertThat(pages).hasSize(1); NewPage newPage = pages.get(0); assertThat(newPage.getUnpublishedPage().getName()) .isEqualTo(newPage.getPublishedPage().getName()); @@ -3144,7 +3144,7 @@ public class ApplicationServiceCETest { assertThat(publishedPages).containsAnyOf(applicationPage); List editedApplicationPages = editedApplication.getPages(); - assertThat(editedApplicationPages.size()).isEqualTo(1); + assertThat(editedApplicationPages).hasSize(1); assertThat(editedApplicationPages).doesNotContain(applicationPage); }) .verifyComplete(); @@ -3188,7 +3188,7 @@ public class ApplicationServiceCETest { assertThat(publishedPages).containsAnyOf(applicationPage); List editedApplicationPages = editedApplication.getPages(); - assertThat(editedApplicationPages.size()).isEqualTo(1); + assertThat(editedApplicationPages).hasSize(1); assertThat(editedApplicationPages).doesNotContain(applicationPage); }) .verifyComplete(); @@ -3249,7 +3249,7 @@ public class ApplicationServiceCETest { assertThat(isFound).isTrue(); List editedApplicationPages = editedApplication.getPages(); - assertThat(editedApplicationPages.size()).isEqualTo(2); + assertThat(editedApplicationPages).hasSize(2); isFound = false; for (ApplicationPage page : editedApplicationPages) { if (page.getId().equals(unpublishedEditedPage.getId()) @@ -3310,7 +3310,7 @@ public class ApplicationServiceCETest { StepVerifier.create(viewModeApplicationMono) .assertNext(viewApplication -> { List editedApplicationPages = viewApplication.getPages(); - assertThat(editedApplicationPages.size()).isEqualTo(2); + assertThat(editedApplicationPages).hasSize(2); boolean isFound = false; for (ApplicationPage page : editedApplicationPages) { if (page.getId().equals(applicationPage.getId()) @@ -3457,7 +3457,7 @@ public class ApplicationServiceCETest { assertThat(cloneApp).isNotNull(); assertThat(pages.get(0).getId()).isNotEqualTo(pageId); - assertThat(actions.size()).isEqualTo(4); + assertThat(actions).hasSize(4); Set actionNames = actions.stream() .map(action -> action.getUnpublishedAction().getName()) .collect(Collectors.toSet()); @@ -3467,7 +3467,7 @@ public class ApplicationServiceCETest { "Clone App Test action2", "Clone App Test action3", "jsFunc"); - assertThat(actionCollections.size()).isEqualTo(1); + assertThat(actionCollections).hasSize(1); Set actionCollectionNames = actionCollections.stream() .map(actionCollection -> actionCollection.getUnpublishedCollection().getName()) @@ -3550,7 +3550,7 @@ public class ApplicationServiceCETest { StepVerifier.create(applicationPagesDTOMono) .assertNext(applicationPagesDTO -> { - assertThat(applicationPagesDTO.getPages().size()).isEqualTo(4); + assertThat(applicationPagesDTO.getPages()).hasSize(4); List pageNames = applicationPagesDTO.getPages().stream() .map(pageNameIdDTO -> pageNameIdDTO.getName()) .collect(Collectors.toList()); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/FeatureFlagServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/FeatureFlagServiceCETest.java index d0ef5a9e12..483c458b27 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/FeatureFlagServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/FeatureFlagServiceCETest.java @@ -281,7 +281,7 @@ public class FeatureFlagServiceCETest { // Assert that the cached feature flags are empty before the remote fetch CachedFeatures cachedFeaturesBeforeRemoteCall = featureFlagService.getCachedTenantFeatureFlags(); - assertThat(cachedFeaturesBeforeRemoteCall.getFeatures().size()).isEqualTo(1); + assertThat(cachedFeaturesBeforeRemoteCall.getFeatures()).hasSize(1); assertTrue(cachedFeaturesBeforeRemoteCall.getFeatures().get(TENANT_TEST_FEATURE.name())); Map tenantFeatures = new HashMap<>(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/GitServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/GitServiceCETest.java index 4b1049d856..a630d0b16c 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/GitServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/GitServiceCETest.java @@ -2330,8 +2330,8 @@ public class GitServiceCETest { StepVerifier.create(committedApplicationMono) .assertNext(application -> { List publishedPages = application.getPublishedPages(); - assertThat(application.getPublishedPages().size()) - .isEqualTo(preCommitApplication.getPublishedPages().size()); + assertThat(application.getPublishedPages()) + .hasSize(preCommitApplication.getPublishedPages().size()); publishedPages.forEach(publishedPage -> { assertThat(publishedPage.getId().equals(createdPage.getId())) .isFalse(); @@ -3515,8 +3515,8 @@ public class GitServiceCETest { .getGitAuth() .getPublicKey()) .isEqualTo(gitAuth.getPublicKey()); - assertThat(application.getUnpublishedCustomJSLibs().size()) - .isEqualTo(application.getPublishedCustomJSLibs().size()); + assertThat(application.getUnpublishedCustomJSLibs()) + .hasSize(application.getPublishedCustomJSLibs().size()); }) .verifyComplete(); } @@ -4620,7 +4620,7 @@ public class GitServiceCETest { StepVerifier.create(listMono) .assertNext(listBranch -> { - assertThat(listBranch.size()).isEqualTo(3); + assertThat(listBranch).hasSize(3); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/NewActionServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/NewActionServiceTest.java index ce6b9d7261..a3df9da93d 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/NewActionServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/NewActionServiceTest.java @@ -91,7 +91,7 @@ public class NewActionServiceTest { StepVerifier.create(actionListMono) .assertNext(actions -> { - assertThat(actions.size()).isEqualTo(3); + assertThat(actions).hasSize(3); actions.forEach(action -> { assertThat(action.getPublishedAction()).isNotNull(); // we've set name and pageId so these fields should not be null in edit mode diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/TenantServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/TenantServiceCETest.java index 3102690ad6..20e1771ce7 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/TenantServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/TenantServiceCETest.java @@ -313,11 +313,8 @@ class TenantServiceCETest { // Verify that the tenant is updated for the feature flag migration failure StepVerifier.create(tenantService.getById(tenant.getId())) .assertNext(updatedTenant -> { - assertThat(updatedTenant - .getTenantConfiguration() - .getFeaturesWithPendingMigration() - .size()) - .isEqualTo(1); + assertThat(updatedTenant.getTenantConfiguration().getFeaturesWithPendingMigration()) + .hasSize(1); assertThat(updatedTenant.getTenantConfiguration().getMigrationStatus()) .isEqualTo(IN_PROGRESS); }) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationFetcherTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationFetcherTest.java index 49d811b47b..9394606622 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationFetcherTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationFetcherTest.java @@ -74,10 +74,9 @@ public class ApplicationFetcherTest { .findFirst() .orElse(new WorkspaceApplicationsDTO()); - assertThat(orgApps.getApplications().size()).isEqualTo(1); - assertThat(orgApps.getApplications().get(0).getPublishedPages().size()) - .isEqualTo(1); - assertThat(orgApps.getApplications().get(0).getPages().size()).isEqualTo(2); + assertThat(orgApps.getApplications()).hasSize(1); + assertThat(orgApps.getApplications().get(0).getPublishedPages()).hasSize(1); + assertThat(orgApps.getApplications().get(0).getPages()).hasSize(2); }); } } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationFetcherUnitTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationFetcherUnitTest.java index 7d0c42507e..9ca921b24d 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationFetcherUnitTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationFetcherUnitTest.java @@ -225,10 +225,10 @@ public class ApplicationFetcherUnitTest { StepVerifier.create(applicationFetcher.getAllApplications()) .assertNext(userHomepageDTO -> { List dtos = userHomepageDTO.getWorkspaceApplications(); - assertThat(dtos.size()).isEqualTo(4); + assertThat(dtos).hasSize(4); for (WorkspaceApplicationsDTO dto : dtos) { assertThat(dto.getWorkspace().getTenantId()).isEqualTo(defaultTenantId); - assertThat(dto.getApplications().size()).isEqualTo(4); + assertThat(dto.getApplications()).hasSize(4); List applicationList = dto.getApplications(); for (Application application : applicationList) { application.getPages().forEach(page -> assertThat(page.getSlug()) @@ -269,10 +269,10 @@ public class ApplicationFetcherUnitTest { StepVerifier.create(applicationFetcher.getAllApplications()) .assertNext(userHomepageDTO -> { List dtos = userHomepageDTO.getWorkspaceApplications(); - assertThat(dtos.size()).isEqualTo(4); + assertThat(dtos).hasSize(4); for (WorkspaceApplicationsDTO dto : dtos) { assertThat(dto.getWorkspace().getTenantId()).isEqualTo(defaultTenantId); - assertThat(dto.getApplications().size()).isEqualTo(4); + assertThat(dto.getApplications()).hasSize(4); List applicationList = dto.getApplications(); for (Application application : applicationList) { application.getPages().forEach(page -> assertThat(page.getSlug()) @@ -301,9 +301,9 @@ public class ApplicationFetcherUnitTest { StepVerifier.create(userHomepageDTOMono) .assertNext(userHomepageDTO -> { List dtos = userHomepageDTO.getWorkspaceApplications(); - assertThat(dtos.size()).isEqualTo(4); + assertThat(dtos).hasSize(4); for (WorkspaceApplicationsDTO dto : dtos) { - assertThat(dto.getApplications().size()).isEqualTo(4); + assertThat(dto.getApplications()).hasSize(4); List applicationList = dto.getApplications(); for (Application application : applicationList) { application.getPages().forEach(page -> assertThat(page.getSlug()) @@ -358,9 +358,9 @@ public class ApplicationFetcherUnitTest { StepVerifier.create(userHomepageDTOMono) .assertNext(userHomepageDTO -> { List dtos = userHomepageDTO.getWorkspaceApplications(); - assertThat(dtos.size()).isEqualTo(4); + assertThat(dtos).hasSize(4); for (WorkspaceApplicationsDTO dto : dtos) { - assertThat(dto.getApplications().size()).isEqualTo(4); + assertThat(dto.getApplications()).hasSize(4); List applicationList = dto.getApplications(); for (Application application : applicationList) { application.getPages().forEach(page -> assertThat(page.getSlug()) @@ -401,7 +401,7 @@ public class ApplicationFetcherUnitTest { .assertNext(userHomepageDTO -> { List workspaceApplications = userHomepageDTO.getWorkspaceApplications(); assertThat(workspaceApplications).isNotNull(); - assertThat(workspaceApplications.size()).isEqualTo(4); + assertThat(workspaceApplications).hasSize(4); // apps under first org should be sorted as org-2-app-2, org-2-app-1, org-2-app-3, org-2-app-4 checkAppsAreSorted( @@ -463,7 +463,7 @@ public class ApplicationFetcherUnitTest { .assertNext(userHomepageDTO -> { List workspaceApplications = userHomepageDTO.getWorkspaceApplications(); assertThat(workspaceApplications).isNotNull(); - assertThat(workspaceApplications.size()).isEqualTo(4); + assertThat(workspaceApplications).hasSize(4); // apps under first org should be sorted as 1,2,3 checkAppsAreSorted( diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationForkingServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationForkingServiceTests.java index ca576664ce..e1bedc8e22 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationForkingServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationForkingServiceTests.java @@ -1139,7 +1139,7 @@ public class ApplicationForkingServiceTests { StepVerifier.create(applicationMono) .assertNext(forkedApplication -> { - assertThat(forkedApplication.getPages().size()).isEqualTo(1); + assertThat(forkedApplication.getPages()).hasSize(1); }) .verifyComplete(); } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/DatasourceStructureSolutionTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/DatasourceStructureSolutionTest.java index d7772368a1..bb64cb36c1 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/DatasourceStructureSolutionTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/DatasourceStructureSolutionTest.java @@ -208,7 +208,7 @@ public class DatasourceStructureSolutionTest { StepVerifier.create(datasourceStructureMono) .assertNext(datasourceStructure -> { - assertThat(datasourceStructure.getTables().size()).isEqualTo(2); + assertThat(datasourceStructure.getTables()).hasSize(2); assertThat(datasourceStructure.getTables().get(0).getName()).isEqualTo("Table1"); assertThat(datasourceStructure.getTables().get(1).getName()).isEqualTo("Table2"); }) @@ -235,7 +235,7 @@ public class DatasourceStructureSolutionTest { StepVerifier.create(datasourceStructureMono) .assertNext(datasourceStructure -> { - assertThat(datasourceStructure.getTables().size()).isEqualTo(2); + assertThat(datasourceStructure.getTables()).hasSize(2); assertThat(datasourceStructure.getTables().get(0).getName()).isEqualTo("Table1"); assertThat(datasourceStructure.getTables().get(1).getName()).isEqualTo("Table2"); }) @@ -262,7 +262,7 @@ public class DatasourceStructureSolutionTest { StepVerifier.create(datasourceStructureMono) .assertNext(datasourceStructure -> { - assertThat(datasourceStructure.getTables().size()).isEqualTo(2); + assertThat(datasourceStructure.getTables()).hasSize(2); assertThat(datasourceStructure.getTables().get(0).getName()).isEqualTo("Table1"); assertThat(datasourceStructure.getTables().get(1).getName()).isEqualTo("Table2"); }) @@ -289,7 +289,7 @@ public class DatasourceStructureSolutionTest { assertThat(datasourceStorageStructure.getEnvironmentId()).isEqualTo(defaultEnvironmentId); assertThat(datasourceStorageStructure.getStructure()).isNotNull(); DatasourceStructure datasourceStructure = datasourceStorageStructure.getStructure(); - assertThat(datasourceStructure.getTables().size()).isEqualTo(2); + assertThat(datasourceStructure.getTables()).hasSize(2); assertThat(datasourceStructure.getTables().get(0).getName()).isEqualTo("Table1"); assertThat(datasourceStructure.getTables().get(1).getName()).isEqualTo("Table2"); }) @@ -308,7 +308,7 @@ public class DatasourceStructureSolutionTest { StepVerifier.create(datasourceStructureMono) .assertNext(datasourceStructure -> { - assertThat(datasourceStructure.getTables().size()).isEqualTo(2); + assertThat(datasourceStructure.getTables()).hasSize(2); assertThat(datasourceStructure.getTables().get(0).getName()).isEqualTo("Table1"); assertThat(datasourceStructure.getTables().get(1).getName()).isEqualTo("Table2"); }) @@ -338,7 +338,7 @@ public class DatasourceStructureSolutionTest { StepVerifier.create(datasourceStructureMono) .assertNext(datasourceStructure -> { - assertThat(datasourceStructure.getTables().size()).isEqualTo(2); + assertThat(datasourceStructure.getTables()).hasSize(2); assertThat(datasourceStructure.getTables().get(0).getName()).isEqualTo("Table1"); assertThat(datasourceStructure.getTables().get(1).getName()).isEqualTo("Table2"); }) diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportApplicationServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportApplicationServiceTests.java index f478bcc729..d5ff1ca8bc 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportApplicationServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportApplicationServiceTests.java @@ -1675,8 +1675,8 @@ public class ImportApplicationServiceTests { assertThat(applicationPageIdsBeforeImport).hasSize(2); assertThat(applicationPageIdsBeforeImport).contains(savedPage.getId()); - assertThat(newPages.size()).isEqualTo(1); - assertThat(importedApplication.getPages().size()).isEqualTo(1); + assertThat(newPages).hasSize(1); + assertThat(importedApplication.getPages()).hasSize(1); assertThat(importedApplication.getPages().get(0).getId()) .isEqualTo(newPages.get(0).getId()); assertThat(newPages.get(0).getPublishedPage().getName()).isEqualTo("importedPage"); @@ -1741,7 +1741,7 @@ public class ImportApplicationServiceTests { .assertNext(newPages -> { // Check before import we had both the pages assertThat(applicationPageIdsBeforeImport).hasSize(1); - assertThat(newPages.size()).isEqualTo(3); + assertThat(newPages).hasSize(3); List pageNames = newPages.stream() .map(newPage -> newPage.getUnpublishedPage().getName()) .collect(Collectors.toList()); @@ -3626,14 +3626,14 @@ public class ImportApplicationServiceTests { .isFalse(); assertThat(applicationPagesDTO.getApplication().getForkingEnabled()) .isFalse(); - assertThat(applicationPagesDTO.getPages().size()).isEqualTo(4); + assertThat(applicationPagesDTO.getPages()).hasSize(4); List pageNames = applicationPagesDTO.getPages().stream() .map(PageNameIdDTO::getName) .collect(Collectors.toList()); assertThat(pageNames).contains("Home", "Home2", "About"); - assertThat(newActionList.size()).isEqualTo(2); // we imported two pages and each page has one action - assertThat(actionCollectionList.size()) - .isEqualTo(2); // we imported two pages and each page has one Collection + assertThat(newActionList).hasSize(2); // we imported two pages and each page has one action + assertThat(actionCollectionList) + .hasSize(2); // we imported two pages and each page has one Collection }) .verifyComplete(); } @@ -3674,7 +3674,7 @@ public class ImportApplicationServiceTests { StepVerifier.create(applicationPagesDTOMono) .assertNext(applicationPagesDTO -> { - assertThat(applicationPagesDTO.getPages().size()).isEqualTo(4); + assertThat(applicationPagesDTO.getPages()).hasSize(4); List pageNames = applicationPagesDTO.getPages().stream() .map(PageNameIdDTO::getName) .collect(Collectors.toList()); @@ -3818,8 +3818,8 @@ public class ImportApplicationServiceTests { assertThat(application1.getId()).isEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application1.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application1.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application1.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -3908,8 +3908,8 @@ public class ImportApplicationServiceTests { assertThat(application1.getId()).isEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application1.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application1.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application1.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4017,8 +4017,8 @@ public class ImportApplicationServiceTests { assertThat(application3.getId()).isNotEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application3.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application3.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application3.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4127,8 +4127,8 @@ public class ImportApplicationServiceTests { assertThat(application3.getId()).isNotEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application3.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application3.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application3.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4237,8 +4237,8 @@ public class ImportApplicationServiceTests { assertThat(application3.getId()).isNotEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application3.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application3.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application3.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4312,8 +4312,8 @@ public class ImportApplicationServiceTests { assertThat(application1.getId()).isEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application1.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application1.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application1.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4391,8 +4391,8 @@ public class ImportApplicationServiceTests { assertThat(application1.getId()).isEqualTo(finalApplication.getId()); assertThat(finalApplication.getPages().size()) .isLessThan(application1.getPages().size()); - assertThat(finalApplication.getPages().size()) - .isEqualTo(application1.getPublishedPages().size()); + assertThat(finalApplication.getPages()) + .hasSize(application1.getPublishedPages().size()); // Verify the pages after merging the template pageList.forEach(newPage -> { @@ -4449,7 +4449,7 @@ public class ImportApplicationServiceTests { .findAllApplicationsByWorkspaceId(workspaceId) .collectList()) .assertNext(applications -> { - assertThat(applicationList.size()).isEqualTo(applications.size()); + assertThat(applicationList).hasSize(applications.size()); }) .verifyComplete(); } @@ -4601,7 +4601,7 @@ public class ImportApplicationServiceTests { StepVerifier.create(resultMono) .assertNext(applicationJson -> { List pages = applicationJson.getPageList(); - assertThat(pages.size()).isEqualTo(2); + assertThat(pages).hasSize(2); assertThat(pages.get(1).getUnpublishedPage().getName()).isEqualTo("page_" + randomId); assertThat(pages.get(1).getUnpublishedPage().getIcon()).isEqualTo("flight"); }) @@ -4661,8 +4661,8 @@ public class ImportApplicationServiceTests { List actionList = tuple.getT3(); List actionCollectionList = tuple.getT4(); - assertThat(pageList.size()).isEqualTo(2); - assertThat(actionList.size()).isEqualTo(3); + assertThat(pageList).hasSize(2); + assertThat(actionList).hasSize(3); List pageNames = pageList.stream() .map(p -> p.getUnpublishedPage().getName()) @@ -5090,18 +5090,18 @@ public class ImportApplicationServiceTests { assertThat(updatedActionCollectionNames).isNotNull(); // only the first page should be present in the updated resources - assertThat(updatedPageNames.size()).isEqualTo(1); + assertThat(updatedPageNames).hasSize(1); assertThat(updatedPageNames).contains(renamedPageName); // only actions from first page should be present in the updated resources // 1 query + 1 method from action collection - assertThat(updatedActionNames.size()).isEqualTo(2); + assertThat(updatedActionNames).hasSize(2); assertThat(updatedActionNames).contains("first_page_action" + NAME_SEPARATOR + renamedPageName); assertThat(updatedActionNames) .contains("TestJsObject.testMethod" + NAME_SEPARATOR + renamedPageName); // only action collections from first page should be present in the updated resources - assertThat(updatedActionCollectionNames.size()).isEqualTo(1); + assertThat(updatedActionCollectionNames).hasSize(1); assertThat(updatedActionCollectionNames) .contains("TestJsObject" + NAME_SEPARATOR + renamedPageName); }) @@ -5186,7 +5186,7 @@ public class ImportApplicationServiceTests { assertThat(updatedActionNames).isNotNull(); // action should be present in the updated resources although action not updated but datasource is - assertThat(updatedActionNames.size()).isEqualTo(1); + assertThat(updatedActionNames).hasSize(1); updatedActionNames.forEach(actionName -> { assertThat(actionName).contains("MyAction"); }); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialExportServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialExportServiceTest.java index 0e275562bc..08643c20e7 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialExportServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialExportServiceTest.java @@ -268,7 +268,7 @@ public class PartialExportServiceTest { StepVerifier.create(partialExportFileDTOMono) .assertNext(applicationJson -> { - assertThat(applicationJson.getDatasourceList().size()).isEqualTo(2); + assertThat(applicationJson.getDatasourceList()).hasSize(2); List dsNames = applicationJson.getDatasourceList().stream() .map(DatasourceStorage::getName) .toList(); @@ -326,7 +326,7 @@ public class PartialExportServiceTest { StepVerifier.create(partialExportFileDTOMono) .assertNext(applicationJson -> { - assertThat(applicationJson.getDatasourceList().size()).isEqualTo(2); + assertThat(applicationJson.getDatasourceList()).hasSize(2); List dsNames = applicationJson.getDatasourceList().stream() .map(DatasourceStorage::getName) .toList(); @@ -335,7 +335,7 @@ public class PartialExportServiceTest { .isEqualTo("installed-plugin"); assertThat(applicationJson.getDatasourceList().get(1).getPluginId()) .isEqualTo("installed-plugin"); - assertThat(applicationJson.getActionList().size()).isEqualTo(1); + assertThat(applicationJson.getActionList()).hasSize(1); NewAction newAction = applicationJson.getActionList().get(0); assertThat(newAction.getUnpublishedAction().getName()).isEqualTo("validAction"); @@ -397,7 +397,7 @@ public class PartialExportServiceTest { StepVerifier.create(partialExportFileDTOMono) .assertNext(applicationJson -> { - assertThat(applicationJson.getDatasourceList().size()).isEqualTo(2); + assertThat(applicationJson.getDatasourceList()).hasSize(2); List dsNames = applicationJson.getDatasourceList().stream() .map(DatasourceStorage::getName) .toList(); @@ -406,7 +406,7 @@ public class PartialExportServiceTest { .isEqualTo("installed-plugin"); assertThat(applicationJson.getDatasourceList().get(1).getPluginId()) .isEqualTo("installed-plugin"); - assertThat(applicationJson.getActionList().size()).isEqualTo(1); + assertThat(applicationJson.getActionList()).hasSize(1); NewAction newAction = applicationJson.getActionList().get(0); assertThat(newAction.getUnpublishedAction().getName()).isEqualTo("validAction"); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialImportServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialImportServiceTest.java index 645308b074..51be750d5a 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialImportServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/PartialImportServiceTest.java @@ -296,15 +296,15 @@ public class PartialImportServiceTest { List actionCollectionList = object.getT3(); // Verify that the application has the imported resource - assertThat(application.getPages().size()).isEqualTo(1); + assertThat(application.getPages()).hasSize(1); - assertThat(actionCollectionList.size()).isEqualTo(1); + assertThat(actionCollectionList).hasSize(1); assertThat(actionCollectionList .get(0) .getUnpublishedCollection() .getName()) .isEqualTo("utils"); - assertThat(actionList.size()).isEqualTo(4); + assertThat(actionList).hasSize(4); Set actionNames = Set.of("DeleteQuery", "UpdateQuery", "SelectQuery", "InsertQuery"); actionList.forEach(action -> { assertThat(actionNames.contains( @@ -354,17 +354,17 @@ public class PartialImportServiceTest { List actionCollectionList = object.getT3(); // Verify that the application has the imported resource - assertThat(application1.getPages().size()).isEqualTo(2); + assertThat(application1.getPages()).hasSize(2); - assertThat(application1.getUnpublishedCustomJSLibs().size()).isEqualTo(1); + assertThat(application1.getUnpublishedCustomJSLibs()).hasSize(1); - assertThat(actionCollectionList.size()).isEqualTo(1); + assertThat(actionCollectionList).hasSize(1); assertThat(actionCollectionList .get(0) .getUnpublishedCollection() .getName()) .isEqualTo("Github_Transformer"); - assertThat(actionList.size()).isEqualTo(1); + assertThat(actionList).hasSize(1); Set actionNames = Set.of("get_force_roster"); actionList.forEach(action -> { assertThat(actionNames.contains( @@ -416,16 +416,16 @@ public class PartialImportServiceTest { List actionCollectionList = object.getT3(); // Verify that the application has the imported resource - assertThat(application.getPages().size()).isEqualTo(1); + assertThat(application.getPages()).hasSize(1); - assertThat(actionCollectionList.size()).isEqualTo(2); + assertThat(actionCollectionList).hasSize(2); Set nameList = Set.of("utils", "utils1"); actionCollectionList.forEach(collection -> { assertThat(nameList.contains( collection.getUnpublishedCollection().getName())) .isTrue(); }); - assertThat(actionList.size()).isEqualTo(8); + assertThat(actionList).hasSize(8); Set actionNames = Set.of( "DeleteQuery", "UpdateQuery",