From 56b3eba57ccdb2d7e9cdb298b2455a78441a2160 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Mon, 4 Mar 2024 07:33:45 +0530 Subject: [PATCH] test: Add AssertJ for plugins, for better assertions (#31380) PR adds assertj to the plugin modules as well so we can write better assertions there. We're changing just one test, but to illustrate as an example. With the previous assertion used here, failure messages looked like this: ``` Expected , but got . ``` But with the better assertions introduced in this PR, we should see something like: ``` Expected `Random unexpected string` to end with `Host not allowed.` ``` Which should help us much better in troubleshooting. --- app/server/appsmith-plugins/pom.xml | 114 +----------------- .../external/plugins/RestApiPluginTest.java | 6 +- 2 files changed, 8 insertions(+), 112 deletions(-) diff --git a/app/server/appsmith-plugins/pom.xml b/app/server/appsmith-plugins/pom.xml index 2387c138d5..13203aaab1 100644 --- a/app/server/appsmith-plugins/pom.xml +++ b/app/server/appsmith-plugins/pom.xml @@ -5,136 +5,79 @@ 4.0.0 - com.appsmith - integrated - 1.0-SNAPSHOT - appsmith-plugins - 1.0-SNAPSHOT - pom - oraclePlugin - postgresPlugin - restApiPlugin - mongoPlugin - mysqlPlugin - elasticSearchPlugin - dynamoPlugin - redisPlugin - mssqlPlugin - firestorePlugin - redshiftPlugin - amazons3Plugin - googleSheetsPlugin - graphqlPlugin - snowflakePlugin - arangoDBPlugin - jsPlugin - saasPlugin - smtpPlugin - openAiPlugin - anthropicPlugin - googleAiPlugin appsmithAiPlugin - awsLambdaPlugin - databricksPlugin - - 0.11.5 - - org.pf4j - pf4j-spring - 0.8.0 - provided - - - org.slf4j - slf4j-reload4j - - - - org.pf4j - pf4j - ${org.pf4j.version} - - com.appsmith - interfaces - 1.0-SNAPSHOT - provided - - org.projectlombok - lombok - provided - @@ -142,133 +85,86 @@ - org.junit.jupiter - junit-jupiter-engine - test - - org.junit.platform - junit-platform-suite-engine - test - - org.junit.jupiter - junit-jupiter-params - test + + + org.assertj + assertj-core + test - org.junit.platform - junit-platform-launcher - test - - io.projectreactor - reactor-test - ${reactor-test.version} - test - - org.mockito - mockito-core - ${mockito.version} - test - - org.mockito - mockito-inline - ${mockito.version} - - - com.squareup.okhttp3 - mockwebserver3 - ${mockwebserver.version} - test - - - io.quarkus - quarkus-junit4-mock - 2.14.2.Final - test - - org.testcontainers - junit-jupiter - ${testcontainers.version} - test - - - junit - junit - - - diff --git a/app/server/appsmith-plugins/restApiPlugin/src/test/java/com/external/plugins/RestApiPluginTest.java b/app/server/appsmith-plugins/restApiPlugin/src/test/java/com/external/plugins/RestApiPluginTest.java index e5ec54af90..e4b67375fd 100644 --- a/app/server/appsmith-plugins/restApiPlugin/src/test/java/com/external/plugins/RestApiPluginTest.java +++ b/app/server/appsmith-plugins/restApiPlugin/src/test/java/com/external/plugins/RestApiPluginTest.java @@ -66,6 +66,7 @@ import static com.appsmith.external.helpers.restApiUtils.helpers.HintMessageUtil import static com.appsmith.external.helpers.restApiUtils.helpers.HintMessageUtils.DUPLICATE_ATTRIBUTE_LOCATION.ACTION_CONFIG_ONLY; import static com.appsmith.external.helpers.restApiUtils.helpers.HintMessageUtils.DUPLICATE_ATTRIBUTE_LOCATION.DATASOURCE_AND_ACTION_CONFIG; import static com.appsmith.external.helpers.restApiUtils.helpers.HintMessageUtils.DUPLICATE_ATTRIBUTE_LOCATION.DATASOURCE_CONFIG_ONLY; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertIterableEquals; @@ -1912,9 +1913,8 @@ public class RestApiPluginTest { StepVerifier.create(resultMono) .assertNext(result -> { assertFalse(result.getIsExecutionSuccess()); - assertTrue(result.getPluginErrorDetails() - .getDownstreamErrorMessage() - .contains("Host not allowed.")); + assertThat(result.getPluginErrorDetails().getDownstreamErrorMessage()) + .endsWith("Host not allowed."); }) .verifyComplete(); }