This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 62416635bd2b4ba2f954be2747f548b02901127a Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Wed Jul 22 15:04:43 2020 +0200 [CAMEL-11807] Upgrade camel-servicenow to junit5 --- .../camel-servicenow-component/pom.xml | 6 +- .../servicenow/ServiceNowAttachmentTest.java | 6 +- .../ServiceNowComponentVerifierExtensionTest.java | 71 +++++++++++----------- .../ServiceNowComponentVerifierTest.java | 71 +++++++++++----------- .../servicenow/ServiceNowImportSetTest.java | 9 ++- .../ServiceNowMetaDataExtensionTest.java | 38 ++++++------ .../servicenow/ServiceNowScorecardTest.java | 4 +- .../servicenow/ServiceNowServiceCatalogTest.java | 14 +++-- .../component/servicenow/ServiceNowTableTest.java | 8 ++- .../camel/component/servicenow/ServiceNowTest.java | 21 ++++--- .../servicenow/ServiceNowTestSupport.java | 2 +- .../camel-servicenow-maven-plugin/pom.xml | 6 +- .../maven/CamelServiceNowGenerateMojoTest.java | 9 +-- 13 files changed, 149 insertions(+), 116 deletions(-) diff --git a/components/camel-servicenow/camel-servicenow-component/pom.xml b/components/camel-servicenow/camel-servicenow-component/pom.xml index b2d4f8a..4e18901 100644 --- a/components/camel-servicenow/camel-servicenow-component/pom.xml +++ b/components/camel-servicenow/camel-servicenow-component/pom.xml @@ -102,7 +102,7 @@ <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> <dependency> @@ -111,8 +111,8 @@ <scope>test</scope> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> </dependencies> diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowAttachmentTest.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowAttachmentTest.java index 2d930cf..ea08d82 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowAttachmentTest.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowAttachmentTest.java @@ -26,9 +26,13 @@ import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.servicenow.model.AttachmentMeta; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.apache.camel.support.ResourceHelper.resolveResourceAsInputStream; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ServiceNowAttachmentTest extends ServiceNowTestSupport { @Produce("direct:servicenow") diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierExtensionTest.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierExtensionTest.java index a36b50c..ce20daf 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierExtensionTest.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierExtensionTest.java @@ -22,8 +22,11 @@ import javax.ws.rs.ProcessingException; import org.apache.camel.Component; import org.apache.camel.component.extension.ComponentVerifierExtension; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupport { public ServiceNowComponentVerifierExtensionTest() { @@ -51,7 +54,7 @@ public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupp Map<String, Object> parameters = getParameters(); ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); + assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); } @Test @@ -60,10 +63,10 @@ public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupp parameters.remove("instanceName"); ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode()); - Assert.assertEquals("instanceName", result.getErrors().get(0).getParameterKeys().iterator().next()); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode()); + assertEquals("instanceName", result.getErrors().get(0).getParameterKeys().iterator().next()); } @Test @@ -72,10 +75,10 @@ public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupp parameters.remove("userName"); ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode()); - Assert.assertEquals("userName", result.getErrors().get(0).getParameterKeys().iterator().next()); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode()); + assertEquals("userName", result.getErrors().get(0).getParameterKeys().iterator().next()); } // ********************************* @@ -87,7 +90,7 @@ public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupp Map<String, Object> parameters = getParameters(); ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); + assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); } @Test @@ -97,7 +100,7 @@ public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupp ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); + assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); } @Test @@ -107,11 +110,11 @@ public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupp ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode()); - Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); - Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ProcessingException); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode()); + assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); + assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ProcessingException); } @Test @@ -121,12 +124,12 @@ public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupp ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode()); - Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); - Assert.assertEquals(400, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE)); - Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode()); + assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); + assertEquals(400, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE)); + assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException); } @Test @@ -138,15 +141,15 @@ public class ServiceNowComponentVerifierExtensionTest extends ServiceNowTestSupp ComponentVerifierExtension.Result result = getExtension().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.AUTHENTICATION, result.getErrors().get(0).getCode()); - Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); - Assert.assertEquals(401, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE)); - Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException); - Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("userName")); - Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("password")); - Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientId")); - Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientSecret")); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.AUTHENTICATION, result.getErrors().get(0).getCode()); + assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); + assertEquals(401, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE)); + assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException); + assertTrue(result.getErrors().get(0).getParameterKeys().contains("userName")); + assertTrue(result.getErrors().get(0).getParameterKeys().contains("password")); + assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientId")); + assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientSecret")); } } diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierTest.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierTest.java index 7f4c1ce..21cf4c4 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierTest.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowComponentVerifierTest.java @@ -21,8 +21,11 @@ import java.util.Map; import javax.ws.rs.ProcessingException; import org.apache.camel.component.extension.ComponentVerifierExtension; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport { public ServiceNowComponentVerifierTest() { @@ -47,7 +50,7 @@ public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport { Map<String, Object> parameters = getParameters(); ComponentVerifierExtension.Result result = getVerifier().verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); + assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); } @Test @@ -56,10 +59,10 @@ public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport { parameters.remove("instanceName"); ComponentVerifierExtension.Result result = getVerifier().verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode()); - Assert.assertEquals("instanceName", result.getErrors().get(0).getParameterKeys().iterator().next()); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode()); + assertEquals("instanceName", result.getErrors().get(0).getParameterKeys().iterator().next()); } @Test @@ -68,10 +71,10 @@ public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport { parameters.remove("userName"); ComponentVerifierExtension.Result result = getVerifier().verify(ComponentVerifierExtension.Scope.PARAMETERS, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode()); - Assert.assertEquals("userName", result.getErrors().get(0).getParameterKeys().iterator().next()); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.MISSING_PARAMETER, result.getErrors().get(0).getCode()); + assertEquals("userName", result.getErrors().get(0).getParameterKeys().iterator().next()); } // ********************************* @@ -83,7 +86,7 @@ public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport { Map<String, Object> parameters = getParameters(); ComponentVerifierExtension.Result result = getVerifier().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); + assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); } @Test @@ -93,7 +96,7 @@ public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport { ComponentVerifierExtension.Result result = getVerifier().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); + assertEquals(ComponentVerifierExtension.Result.Status.OK, result.getStatus()); } @Test @@ -103,11 +106,11 @@ public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport { ComponentVerifierExtension.Result result = getVerifier().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode()); - Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); - Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ProcessingException); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode()); + assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); + assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ProcessingException); } @Test @@ -117,12 +120,12 @@ public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport { ComponentVerifierExtension.Result result = getVerifier().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode()); - Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); - Assert.assertEquals(400, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE)); - Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.EXCEPTION, result.getErrors().get(0).getCode()); + assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); + assertEquals(400, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE)); + assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException); } @Test @@ -134,15 +137,15 @@ public class ServiceNowComponentVerifierTest extends ServiceNowTestSupport { ComponentVerifierExtension.Result result = getVerifier().verify(ComponentVerifierExtension.Scope.CONNECTIVITY, parameters); - Assert.assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); - Assert.assertEquals(1, result.getErrors().size()); - Assert.assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.AUTHENTICATION, result.getErrors().get(0).getCode()); - Assert.assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); - Assert.assertEquals(401, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE)); - Assert.assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException); - Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("userName")); - Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("password")); - Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientId")); - Assert.assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientSecret")); + assertEquals(ComponentVerifierExtension.Result.Status.ERROR, result.getStatus()); + assertEquals(1, result.getErrors().size()); + assertEquals(ComponentVerifierExtension.VerificationError.StandardCode.AUTHENTICATION, result.getErrors().get(0).getCode()); + assertNotNull(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE)); + assertEquals(401, result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.HttpAttribute.HTTP_CODE)); + assertTrue(result.getErrors().get(0).getDetails().get(ComponentVerifierExtension.VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE) instanceof ServiceNowException); + assertTrue(result.getErrors().get(0).getParameterKeys().contains("userName")); + assertTrue(result.getErrors().get(0).getParameterKeys().contains("password")); + assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientId")); + assertTrue(result.getErrors().get(0).getParameterKeys().contains("oauthClientSecret")); } } diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowImportSetTest.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowImportSetTest.java index 6b49d89..87b15e8 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowImportSetTest.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowImportSetTest.java @@ -29,8 +29,11 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.servicenow.model.ImportSetResult; import org.apache.camel.component.servicenow.model.Incident; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * To set-up ServiceNow for this tests: @@ -38,7 +41,7 @@ import org.junit.Test; * 1. Create a new web service named u_test_imp_incident targeting incident table * 2. Create a mapping (automatic) */ -@Ignore +@Disabled public class ServiceNowImportSetTest extends ServiceNowTestSupport { @Test diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowMetaDataExtensionTest.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowMetaDataExtensionTest.java index 0b60f1b..4eb109e 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowMetaDataExtensionTest.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowMetaDataExtensionTest.java @@ -21,11 +21,14 @@ import java.util.Map; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.camel.component.extension.MetaDataExtension; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class ServiceNowMetaDataExtensionTest extends ServiceNowTestSupport { private static final Logger LOGGER = LoggerFactory.getLogger(ServiceNowMetaDataExtensionTest.class); @@ -63,17 +66,17 @@ public class ServiceNowMetaDataExtensionTest extends ServiceNowTestSupport { MetaDataExtension.MetaData result = getExtension().meta(parameters).orElseThrow(RuntimeException::new); - Assert.assertEquals("application/schema+json", result.getAttribute(MetaDataExtension.MetaData.CONTENT_TYPE)); - Assert.assertNotNull(result.getAttribute("date.format")); - Assert.assertNotNull(result.getAttribute("time.format")); - Assert.assertNotNull(result.getAttribute("date-time.format")); - Assert.assertEquals(JsonNode.class, result.getAttribute(MetaDataExtension.MetaData.JAVA_TYPE)); - Assert.assertNotNull(result.getPayload(JsonNode.class)); - Assert.assertNotNull(result.getPayload(JsonNode.class).get("properties")); - Assert.assertNotNull(result.getPayload(JsonNode.class).get("$schema")); - Assert.assertEquals("http://json-schema.org/schema#", result.getPayload(JsonNode.class).get("$schema").asText()); - Assert.assertNotNull(result.getPayload(JsonNode.class).get("id")); - Assert.assertNotNull(result.getPayload(JsonNode.class).get("type")); + assertEquals("application/schema+json", result.getAttribute(MetaDataExtension.MetaData.CONTENT_TYPE)); + assertNotNull(result.getAttribute("date.format")); + assertNotNull(result.getAttribute("time.format")); + assertNotNull(result.getAttribute("date-time.format")); + assertEquals(JsonNode.class, result.getAttribute(MetaDataExtension.MetaData.JAVA_TYPE)); + assertNotNull(result.getPayload(JsonNode.class)); + assertNotNull(result.getPayload(JsonNode.class).get("properties")); + assertNotNull(result.getPayload(JsonNode.class).get("$schema")); + assertEquals("http://json-schema.org/schema#", result.getPayload(JsonNode.class).get("$schema").asText()); + assertNotNull(result.getPayload(JsonNode.class).get("id")); + assertNotNull(result.getPayload(JsonNode.class).get("type")); LOGGER.debug( new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result.getPayload()) @@ -92,20 +95,21 @@ public class ServiceNowMetaDataExtensionTest extends ServiceNowTestSupport { MetaDataExtension.MetaData result = getExtension().meta(parameters).orElseThrow(RuntimeException::new); - Assert.assertEquals("application/json", result.getAttribute(MetaDataExtension.MetaData.CONTENT_TYPE)); - Assert.assertEquals(JsonNode.class, result.getAttribute(MetaDataExtension.MetaData.JAVA_TYPE)); + assertEquals("application/json", result.getAttribute(MetaDataExtension.MetaData.CONTENT_TYPE)); + assertEquals(JsonNode.class, result.getAttribute(MetaDataExtension.MetaData.JAVA_TYPE)); LOGGER.debug( new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result.getPayload()) ); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testInvalidObjectType() throws Exception { Map<String, Object> parameters = getParameters(); parameters.put("objectType", "test"); parameters.put("objectName", "incident"); - getExtension().meta(parameters); + assertThrows(UnsupportedOperationException.class, + () -> getExtension().meta(parameters)); } } diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowScorecardTest.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowScorecardTest.java index c1ec219..0099b7c 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowScorecardTest.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowScorecardTest.java @@ -22,7 +22,9 @@ import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.servicenow.model.Scorecard; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; public class ServiceNowScorecardTest extends ServiceNowTestSupport { @Produce("direct:servicenow") diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowServiceCatalogTest.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowServiceCatalogTest.java index 4a0403e..8b6c51a 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowServiceCatalogTest.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowServiceCatalogTest.java @@ -23,7 +23,10 @@ import org.apache.camel.CamelExecutionException; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; public class ServiceNowServiceCatalogTest extends ServiceNowTestSupport { @Produce("direct:servicenow") @@ -58,9 +61,10 @@ public class ServiceNowServiceCatalogTest extends ServiceNowTestSupport { assertFalse(result2.isEmpty()); } - @Test(expected = CamelExecutionException.class) + @Test public void testWrongSubject() throws Exception { - List<Map<?, ?>> result = template.requestBodyAndHeaders( + assertThrows(CamelExecutionException.class, + () -> template.requestBodyAndHeaders( "direct:servicenow", null, kvBuilder() @@ -69,9 +73,7 @@ public class ServiceNowServiceCatalogTest extends ServiceNowTestSupport { .put(ServiceNowConstants.ACTION_SUBJECT, "Invalid") .build(), List.class - ); - - assertFalse(result.isEmpty()); + )); } // ************************************************************************* diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTableTest.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTableTest.java index 21a748b..8f20e66 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTableTest.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTableTest.java @@ -24,7 +24,13 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.servicenow.model.Incident; import org.apache.camel.component.servicenow.model.IncidentWithParms; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class ServiceNowTableTest extends ServiceNowTestSupport { diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTest.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTest.java index ac77d68..02d4a28 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTest.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTest.java @@ -28,8 +28,13 @@ import org.apache.camel.CamelExecutionException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.component.servicenow.model.Incident; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class ServiceNowTest extends ServiceNowTestSupport { @@ -210,9 +215,9 @@ public class ServiceNowTest extends ServiceNowTestSupport { DateTimeBean deserialized = mapper.readValue(serialized, DateTimeBean.class); - Assert.assertEquals(bean.dateTime, deserialized.dateTime); - Assert.assertEquals(bean.date, deserialized.date); - Assert.assertEquals(bean.time, deserialized.time); + assertEquals(bean.dateTime, deserialized.dateTime); + assertEquals(bean.date, deserialized.date); + assertEquals(bean.time, deserialized.time); } @Test @@ -229,9 +234,9 @@ public class ServiceNowTest extends ServiceNowTestSupport { DateTimeBean deserialized = mapper.readValue(serialized, DateTimeBean.class); - Assert.assertEquals(bean.dateTime, deserialized.dateTime); - Assert.assertEquals(bean.date, deserialized.date); - Assert.assertEquals(bean.time, deserialized.time); + assertEquals(bean.dateTime, deserialized.dateTime); + assertEquals(bean.date, deserialized.date); + assertEquals(bean.time, deserialized.time); } public static class DateTimeBean { diff --git a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestSupport.java b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestSupport.java index 6e155df..38d07a8 100644 --- a/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestSupport.java +++ b/components/camel-servicenow/camel-servicenow-component/src/test/java/org/apache/camel/component/servicenow/ServiceNowTestSupport.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; -import org.apache.camel.test.junit4.CamelTestSupport; +import org.apache.camel.test.junit5.CamelTestSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/components/camel-servicenow/camel-servicenow-maven-plugin/pom.xml b/components/camel-servicenow/camel-servicenow-maven-plugin/pom.xml index 14c6904..258c83b 100644 --- a/components/camel-servicenow/camel-servicenow-maven-plugin/pom.xml +++ b/components/camel-servicenow/camel-servicenow-maven-plugin/pom.xml @@ -147,13 +147,13 @@ <scope>test</scope> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> + <artifactId>camel-test-junit5</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/components/camel-servicenow/camel-servicenow-maven-plugin/src/test/java/org/apache/camel/maven/CamelServiceNowGenerateMojoTest.java b/components/camel-servicenow/camel-servicenow-maven-plugin/src/test/java/org/apache/camel/maven/CamelServiceNowGenerateMojoTest.java index 70890b2..1794697 100644 --- a/components/camel-servicenow/camel-servicenow-maven-plugin/src/test/java/org/apache/camel/maven/CamelServiceNowGenerateMojoTest.java +++ b/components/camel-servicenow/camel-servicenow-maven-plugin/src/test/java/org/apache/camel/maven/CamelServiceNowGenerateMojoTest.java @@ -19,8 +19,9 @@ package org.apache.camel.maven; import java.util.Arrays; import edu.emory.mathcs.backport.java.util.Collections; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; public class CamelServiceNowGenerateMojoTest extends CamelServiceNowMojoTestSupport { @@ -34,7 +35,7 @@ public class CamelServiceNowGenerateMojoTest extends CamelServiceNowMojoTestSupp mojo.execute(); - Assert.assertTrue("Output directory was not created", mojo.outputDirectory.exists()); - Assert.assertTrue("Output directory is empty", mojo.outputDirectory.list().length > 0); + assertTrue(mojo.outputDirectory.exists(), "Output directory was not created"); + assertTrue(mojo.outputDirectory.list().length > 0, "Output directory is empty"); } }