From 92a5536b030fa4547108a226cda562ef578f0567 Mon Sep 17 00:00:00 2001 From: Timon Borter Date: Mon, 24 Jun 2024 20:30:18 +0200 Subject: [PATCH] fix: adjust resolver methods to ignore nullable values --- .../openapi/actions/OpenApiActionBuilder.java | 34 +------- .../actions/OpenApiClientActionBuilder.java | 30 +------ .../actions/OpenApiServerActionBuilder.java | 30 +------ .../actions/OpenApiActionBuilderTest.java | 20 ++++- .../OpenApiClientActionBuilderTest.java | 25 ++++++ .../OpenApiServerActionBuilderTest.java | 25 ++++++ ...ferenceResolverAwareTestActionBuilder.java | 32 +++++++ ...nceResolverAwareTestActionBuilderTest.java | 87 +++++++++++++++++++ .../CitrusContextProvider.java | 6 +- .../camel/actions/CamelActionBuilder.java | 11 ++- .../actions/CamelRouteActionBuilder.java | 30 +------ .../camel/actions/CamelActionBuilderTest.java | 62 +++++++++++-- .../actions/CamelRouteActionBuilderTest.java | 22 +++++ .../http/actions/HttpActionBuilder.java | 30 +------ .../http/actions/HttpClientActionBuilder.java | 30 +------ .../http/actions/HttpServerActionBuilder.java | 29 +------ .../http/actions/HttpActionBuilderTest.java | 28 ++++-- .../actions/HttpClientActionBuilderTest.java | 33 +++++-- .../actions/HttpServerActionBuilderTest.java | 7 ++ .../ws/actions/SoapActionBuilder.java | 30 +------ .../ws/actions/SoapClientActionBuilder.java | 24 +---- .../ws/actions/SoapServerActionBuilder.java | 30 +------ .../ws/actions/SoapActionBuilderTest.java | 20 ++++- .../actions/SoapClientActionBuilderTest.java | 24 +++++ .../actions/SoapServerActionBuilderTest.java | 24 +++++ 25 files changed, 417 insertions(+), 306 deletions(-) create mode 100644 connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiClientActionBuilderTest.java create mode 100644 connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiServerActionBuilderTest.java create mode 100644 core/citrus-api/src/main/java/org/citrusframework/spi/AbstractReferenceResolverAwareTestActionBuilder.java create mode 100644 core/citrus-api/src/test/java/org/citrusframework/spi/AbstractReferenceResolverAwareTestActionBuilderTest.java create mode 100644 endpoints/citrus-camel/src/test/java/org/citrusframework/camel/actions/CamelRouteActionBuilderTest.java create mode 100644 endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapClientActionBuilderTest.java create mode 100644 endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapServerActionBuilderTest.java diff --git a/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiActionBuilder.java b/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiActionBuilder.java index cd60dc39b1..1328b036ff 100644 --- a/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiActionBuilder.java +++ b/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiActionBuilder.java @@ -16,18 +16,17 @@ package org.citrusframework.openapi.actions; -import java.net.URL; - import org.citrusframework.TestAction; -import org.citrusframework.TestActionBuilder; import org.citrusframework.endpoint.Endpoint; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.http.client.HttpClient; import org.citrusframework.openapi.OpenApiSpecification; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; -import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; +import java.net.URL; + /** * Action executes client and server operations using given OpenApi specification. * Action creates proper request and response data from given specification rules. @@ -35,12 +34,7 @@ * @author Christoph Deppisch * @since 4.1 */ -public class OpenApiActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { - - /** Bean reference resolver */ - private ReferenceResolver referenceResolver; - - private TestActionBuilder delegate; +public class OpenApiActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { private OpenApiSpecification specification; @@ -155,24 +149,4 @@ public TestAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiClientActionBuilder.java b/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiClientActionBuilder.java index 3d26d4d349..5c7b615272 100644 --- a/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiClientActionBuilder.java +++ b/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiClientActionBuilder.java @@ -17,11 +17,10 @@ package org.citrusframework.openapi.actions; import org.citrusframework.TestAction; -import org.citrusframework.TestActionBuilder; import org.citrusframework.endpoint.Endpoint; import org.citrusframework.openapi.OpenApiSpecification; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; -import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; import org.springframework.http.HttpStatus; @@ -31,19 +30,14 @@ * @author Christoph Deppisch * @since 4.1 */ -public class OpenApiClientActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { +public class OpenApiClientActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { private final OpenApiSpecification specification; - /** Bean reference resolver */ - private ReferenceResolver referenceResolver; - /** Target http client instance */ private Endpoint httpClient; private String httpClientUri; - private TestActionBuilder delegate; - /** * Default constructor. */ @@ -124,24 +118,4 @@ public TestAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiServerActionBuilder.java b/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiServerActionBuilder.java index eafa3421e7..2db556ff30 100644 --- a/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiServerActionBuilder.java +++ b/connectors/citrus-openapi/src/main/java/org/citrusframework/openapi/actions/OpenApiServerActionBuilder.java @@ -17,11 +17,10 @@ package org.citrusframework.openapi.actions; import org.citrusframework.TestAction; -import org.citrusframework.TestActionBuilder; import org.citrusframework.endpoint.Endpoint; import org.citrusframework.openapi.OpenApiSpecification; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; -import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; import org.springframework.http.HttpStatus; @@ -31,19 +30,14 @@ * @author Christoph Deppisch * @since 4.1 */ -public class OpenApiServerActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { +public class OpenApiServerActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { private final OpenApiSpecification specification; - /** Bean reference resolver */ - private ReferenceResolver referenceResolver; - /** Target http client instance */ private Endpoint httpServer; private String httpServerUri; - private TestActionBuilder delegate; - /** * Default constructor. */ @@ -125,24 +119,4 @@ public TestAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiActionBuilderTest.java b/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiActionBuilderTest.java index 0b37361d0c..4c2d40db4f 100644 --- a/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiActionBuilderTest.java +++ b/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiActionBuilderTest.java @@ -16,17 +16,28 @@ package org.citrusframework.openapi.actions; -import java.util.Map; - import org.citrusframework.TestActionBuilder; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.testng.Assert; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.Map; + +import static org.testng.Assert.assertTrue; + /** * @author Christoph Deppisch */ public class OpenApiActionBuilderTest { + private OpenApiActionBuilder fixture; + + @BeforeMethod + public void beforeMethod() { + fixture = new OpenApiActionBuilder(); + } + @Test public void shouldLookupTestActionBuilder() { Map> endpointBuilders = TestActionBuilder.lookup(); @@ -35,4 +46,9 @@ public void shouldLookupTestActionBuilder() { Assert.assertTrue(TestActionBuilder.lookup("openapi").isPresent()); Assert.assertEquals(TestActionBuilder.lookup("openapi").get().getClass(), OpenApiActionBuilder.class); } + + @Test + public void isReferenceResolverAwareTestActionBuilder() { + assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); + } } diff --git a/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiClientActionBuilderTest.java b/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiClientActionBuilderTest.java new file mode 100644 index 0000000000..1095cba8e2 --- /dev/null +++ b/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiClientActionBuilderTest.java @@ -0,0 +1,25 @@ +package org.citrusframework.openapi.actions; + +import org.citrusframework.endpoint.Endpoint; +import org.citrusframework.openapi.OpenApiSpecification; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.mockito.Mockito.mock; +import static org.testng.Assert.assertTrue; + +public class OpenApiClientActionBuilderTest { + + private OpenApiClientActionBuilder fixture; + + @BeforeMethod + public void beforeMethod() { + fixture = new OpenApiClientActionBuilder(mock(Endpoint.class), mock(OpenApiSpecification.class)); + } + + @Test + public void isReferenceResolverAwareTestActionBuilder() { + assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); + } +} diff --git a/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiServerActionBuilderTest.java b/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiServerActionBuilderTest.java new file mode 100644 index 0000000000..dce3c9962f --- /dev/null +++ b/connectors/citrus-openapi/src/test/java/org/citrusframework/openapi/actions/OpenApiServerActionBuilderTest.java @@ -0,0 +1,25 @@ +package org.citrusframework.openapi.actions; + +import org.citrusframework.endpoint.Endpoint; +import org.citrusframework.openapi.OpenApiSpecification; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.mockito.Mockito.mock; +import static org.testng.Assert.assertTrue; + +public class OpenApiServerActionBuilderTest { + + private OpenApiServerActionBuilder fixture; + + @BeforeMethod + public void beforeMethod() { + fixture = new OpenApiServerActionBuilder(mock(Endpoint.class), mock(OpenApiSpecification.class)); + } + + @Test + public void isReferenceResolverAwareTestActionBuilder() { + assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); + } +} diff --git a/core/citrus-api/src/main/java/org/citrusframework/spi/AbstractReferenceResolverAwareTestActionBuilder.java b/core/citrus-api/src/main/java/org/citrusframework/spi/AbstractReferenceResolverAwareTestActionBuilder.java new file mode 100644 index 0000000000..5bfd81b143 --- /dev/null +++ b/core/citrus-api/src/main/java/org/citrusframework/spi/AbstractReferenceResolverAwareTestActionBuilder.java @@ -0,0 +1,32 @@ +package org.citrusframework.spi; + +import jakarta.annotation.Nullable; +import org.citrusframework.TestAction; +import org.citrusframework.TestActionBuilder; + +public abstract class AbstractReferenceResolverAwareTestActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { + + /** Bean reference resolver */ + protected ReferenceResolver referenceResolver; + + protected TestActionBuilder delegate; + + @Override + public TestActionBuilder getDelegate() { + return delegate; + } + + /** + * Specifies the referenceResolver. + */ + @Override + public void setReferenceResolver(@Nullable ReferenceResolver referenceResolver) { + if (referenceResolver != null) { + this.referenceResolver = referenceResolver; + + if (delegate instanceof ReferenceResolverAware referenceResolverAware) { + referenceResolverAware.setReferenceResolver(referenceResolver); + } + } + } +} diff --git a/core/citrus-api/src/test/java/org/citrusframework/spi/AbstractReferenceResolverAwareTestActionBuilderTest.java b/core/citrus-api/src/test/java/org/citrusframework/spi/AbstractReferenceResolverAwareTestActionBuilderTest.java new file mode 100644 index 0000000000..2b70101e6e --- /dev/null +++ b/core/citrus-api/src/test/java/org/citrusframework/spi/AbstractReferenceResolverAwareTestActionBuilderTest.java @@ -0,0 +1,87 @@ +package org.citrusframework.spi; + +import org.citrusframework.TestAction; +import org.citrusframework.TestActionBuilder; +import org.mockito.Mock; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.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.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.MockitoAnnotations.openMocks; +import static org.springframework.test.util.ReflectionTestUtils.getField; +import static org.springframework.test.util.ReflectionTestUtils.setField; + +public class AbstractReferenceResolverAwareTestActionBuilderTest { + + @Mock + private ReferenceResolver referenceResolver; + + @Mock + private TestReferenceResolver referenceResolverAware; + + private AbstractReferenceResolverAwareTestActionBuilder fixture; + + private AutoCloseable openedMocks; + + @BeforeMethod + public void beforeMethod() { + openedMocks = openMocks(this); + + fixture = new AbstractReferenceResolverAwareTestActionBuilder() { + + @Override + public TestAction build() { + throw new IllegalArgumentException("Test implementation!"); + } + }; + + setField(fixture, "delegate", referenceResolverAware); + } + + @Test + public void getDelegate() { + assertEquals(referenceResolverAware, fixture.getDelegate()); + } + + @Test + public void setReferenceResolver() { + fixture.setReferenceResolver(referenceResolver); + + assertNotNull(getField(fixture, "referenceResolver"), "ReferenceResolver should be set"); + verify(referenceResolverAware).setReferenceResolver(referenceResolver); + } + + @Test + public void setReferenceResolver_doesNotPropagateToNonReferenceResolverAware() { + var testActionBuilder = mock(TestActionBuilder.class); + setField(fixture, "delegate", testActionBuilder); + + fixture.setReferenceResolver(referenceResolver); + + assertNotNull(getField(fixture, "referenceResolver"), "ReferenceResolver should be set"); + verifyNoInteractions(referenceResolverAware); + verifyNoInteractions(testActionBuilder); + } + + @Test + public void setReferenceResolver_ignoresNullReferenceResolver() { + fixture.setReferenceResolver(null); + + assertNull(getField(fixture, "referenceResolver"), "ReferenceResolver should NOT be set"); + verifyNoInteractions(referenceResolverAware); + } + + @AfterMethod + public void afterMethod() throws Exception { + openedMocks.close(); + } + + private abstract static class TestReferenceResolver implements TestActionBuilder, ReferenceResolverAware { + } +} diff --git a/core/citrus-base/src/main/java/org/citrusframework/CitrusContextProvider.java b/core/citrus-base/src/main/java/org/citrusframework/CitrusContextProvider.java index e40ee6850e..7e09745402 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/CitrusContextProvider.java +++ b/core/citrus-base/src/main/java/org/citrusframework/CitrusContextProvider.java @@ -63,15 +63,15 @@ static CitrusContextProvider lookup() { } if (provider.size() > 1) { - logger.warn(String.format("Found %d Citrus context provider implementations. Please choose one of them.", provider.size())); + logger.warn("Found {} Citrus context provider implementations. Please choose one of them.", provider.size()); } if (logger.isDebugEnabled()) { - provider.forEach((k, v) -> logger.debug(String.format("Found Citrus context provider '%s' as %s", k, v.getClass()))); + provider.forEach((k, v) -> logger.debug("Found Citrus context provider '{}' as {}", k, v.getClass())); } CitrusContextProvider contextProvider = provider.values().iterator().next(); - logger.debug(String.format("Using Citrus context provider '%s' as %s", provider.keySet().iterator().next(), contextProvider)); + logger.debug("Using Citrus context provider '{}' as {}", provider.keySet().iterator().next(), contextProvider); return contextProvider; } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelActionBuilder.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelActionBuilder.java index 67b39d4049..edbbf7cf95 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelActionBuilder.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelActionBuilder.java @@ -16,6 +16,7 @@ package org.citrusframework.camel.actions; +import jakarta.annotation.Nullable; import org.apache.camel.CamelContext; import org.citrusframework.TestAction; import org.citrusframework.TestActionBuilder; @@ -93,14 +94,12 @@ public TestActionBuilder getDelegate() { /** * Specifies the referenceResolver. - * @param referenceResolver */ @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } + public void setReferenceResolver(@Nullable ReferenceResolver referenceResolver) { + if (referenceResolver != null + && delegate instanceof ReferenceResolverAware referenceResolverAware) { + referenceResolverAware.setReferenceResolver(referenceResolver); } } } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelRouteActionBuilder.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelRouteActionBuilder.java index 4c00df3215..a50b533668 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelRouteActionBuilder.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelRouteActionBuilder.java @@ -19,24 +19,18 @@ import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.model.ModelCamelContext; -import org.citrusframework.TestActionBuilder; import org.citrusframework.camel.message.CamelRouteProcessor; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; -import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; /** * Action builder. */ -public class CamelRouteActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { - - /** Bean reference resolver */ - private ReferenceResolver referenceResolver; +public class CamelRouteActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { private CamelContext camelContext; - private TestActionBuilder delegate; - /** * Fluent API action building entry method used in Java DSL. * @return @@ -169,24 +163,4 @@ public AbstractCamelRouteAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/actions/CamelActionBuilderTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/actions/CamelActionBuilderTest.java index bb5a1d2cc4..d4d0541a25 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/actions/CamelActionBuilderTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/actions/CamelActionBuilderTest.java @@ -16,23 +16,73 @@ package org.citrusframework.camel.actions; -import java.util.Map; - import org.citrusframework.TestActionBuilder; -import org.testng.Assert; +import org.citrusframework.spi.ReferenceResolver; +import org.citrusframework.spi.ReferenceResolverAware; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.Map; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.springframework.test.util.ReflectionTestUtils.setField; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + /** * @author Christoph Deppisch */ public class CamelActionBuilderTest { + private CamelActionBuilder fixture; + + @BeforeMethod + public void beforeMethod() { + fixture = new CamelActionBuilder(); + } + @Test public void shouldLookupTestActionBuilder() { Map> endpointBuilders = TestActionBuilder.lookup(); - Assert.assertTrue(endpointBuilders.containsKey("camel")); + assertTrue(endpointBuilders.containsKey("camel")); + + assertTrue(TestActionBuilder.lookup("camel").isPresent()); + assertEquals(TestActionBuilder.lookup("camel").get().getClass(), CamelActionBuilder.class); + } + + @Test + public void passReferenceResolverToDelegate() { + var referenceResolverAware = mock(TestReferenceResolver.class); + setField(fixture, "delegate", referenceResolverAware); + + var referenceResolver = mock(ReferenceResolver.class); + fixture.setReferenceResolver(referenceResolver); + + verify(referenceResolverAware).setReferenceResolver(referenceResolver); + } + + @Test + public void setReferenceResolver_ignoresNonReferenceResolverAware() { + var referenceResolverAware = mock(TestActionBuilder.class); + setField(fixture, "delegate", referenceResolverAware); + + fixture.setReferenceResolver(mock(ReferenceResolver.class)); + + verifyNoInteractions(referenceResolverAware); + } + + @Test + public void setReferenceResolver_ignoresNullReferenceResolver() { + var referenceResolverAware = mock(TestReferenceResolver.class); + setField(fixture, "delegate", referenceResolverAware); + + fixture.setReferenceResolver(null); + + verifyNoInteractions(referenceResolverAware); + } - Assert.assertTrue(TestActionBuilder.lookup("camel").isPresent()); - Assert.assertEquals(TestActionBuilder.lookup("camel").get().getClass(), CamelActionBuilder.class); + private abstract class TestReferenceResolver implements TestActionBuilder, ReferenceResolverAware { } } diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/actions/CamelRouteActionBuilderTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/actions/CamelRouteActionBuilderTest.java new file mode 100644 index 0000000000..434813ec83 --- /dev/null +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/actions/CamelRouteActionBuilderTest.java @@ -0,0 +1,22 @@ +package org.citrusframework.camel.actions; + +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertTrue; + +public class CamelRouteActionBuilderTest { + + private CamelRouteActionBuilder fixture; + + @BeforeMethod + public void beforeMethod() { + fixture = new CamelRouteActionBuilder(); + } + + @Test + public void isReferenceResolverAwareTestActionBuilder() { + assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); + } +} diff --git a/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpActionBuilder.java b/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpActionBuilder.java index e93bae127d..e579a449d5 100644 --- a/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpActionBuilder.java +++ b/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpActionBuilder.java @@ -17,11 +17,10 @@ package org.citrusframework.http.actions; import org.citrusframework.TestAction; -import org.citrusframework.TestActionBuilder; import org.citrusframework.endpoint.Endpoint; import org.citrusframework.http.client.HttpClient; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; -import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; /** @@ -30,12 +29,7 @@ * @author Christoph Deppisch * @since 2.4 */ -public class HttpActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { - - /** Bean reference resolver */ - private ReferenceResolver referenceResolver; - - private TestActionBuilder delegate; +public class HttpActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { /** * Static entrance method for the Http fluent action builder. @@ -99,24 +93,4 @@ public TestAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpClientActionBuilder.java b/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpClientActionBuilder.java index 0d41b1767d..eb9323c3cf 100644 --- a/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpClientActionBuilder.java +++ b/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpClientActionBuilder.java @@ -17,10 +17,9 @@ package org.citrusframework.http.actions; import org.citrusframework.TestAction; -import org.citrusframework.TestActionBuilder; import org.citrusframework.endpoint.Endpoint; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; -import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; import org.citrusframework.util.StringUtils; import org.springframework.http.HttpMethod; @@ -32,17 +31,12 @@ * @author Christoph Deppisch * @since 2.4 */ -public class HttpClientActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { - - /** Bean reference resolver */ - private ReferenceResolver referenceResolver; +public class HttpClientActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { /** Target http client instance */ private Endpoint httpClient; private String httpClientUri; - private TestActionBuilder delegate; - /** * Default constructor. */ @@ -271,24 +265,4 @@ public TestAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpServerActionBuilder.java b/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpServerActionBuilder.java index c99ac0eaea..0996a978bb 100644 --- a/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpServerActionBuilder.java +++ b/endpoints/citrus-http/src/main/java/org/citrusframework/http/actions/HttpServerActionBuilder.java @@ -18,10 +18,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.sun.istack.NotNull; import org.citrusframework.TestAction; import org.citrusframework.TestActionBuilder; import org.citrusframework.endpoint.Endpoint; import org.citrusframework.exceptions.CitrusRuntimeException; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; @@ -38,19 +40,14 @@ * @author Christoph Deppisch * @since 2.4 */ -public class HttpServerActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { +public class HttpServerActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().enable(INDENT_OUTPUT); - /** Bean reference resolver */ - private ReferenceResolver referenceResolver; - /** Target http client instance */ private Endpoint httpServer; private String httpServerUri; - private TestActionBuilder delegate; - /** * Default constructor. */ @@ -322,24 +319,4 @@ public TestAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpActionBuilderTest.java b/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpActionBuilderTest.java index 8016ae44c2..dc331ac23b 100644 --- a/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpActionBuilderTest.java +++ b/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpActionBuilderTest.java @@ -16,23 +16,39 @@ package org.citrusframework.http.actions; -import java.util.Map; - import org.citrusframework.TestActionBuilder; -import org.testng.Assert; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.Map; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + /** * @author Christoph Deppisch */ public class HttpActionBuilderTest { + private HttpActionBuilder fixture; + + @BeforeMethod + public void beforeMethod() { + fixture = new HttpActionBuilder(); + } + @Test public void shouldLookupTestActionBuilder() { Map> endpointBuilders = TestActionBuilder.lookup(); - Assert.assertTrue(endpointBuilders.containsKey("http")); + assertTrue(endpointBuilders.containsKey("http")); - Assert.assertTrue(TestActionBuilder.lookup("http").isPresent()); - Assert.assertEquals(TestActionBuilder.lookup("http").get().getClass(), HttpActionBuilder.class); + assertTrue(TestActionBuilder.lookup("http").isPresent()); + assertEquals(TestActionBuilder.lookup("http").get().getClass(), HttpActionBuilder.class); + } + + @Test + public void isReferenceResolverAwareTestActionBuilder() { + assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); } } diff --git a/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpClientActionBuilderTest.java b/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpClientActionBuilderTest.java index ffa59bd0ac..578f39903c 100644 --- a/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpClientActionBuilderTest.java +++ b/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpClientActionBuilderTest.java @@ -2,36 +2,45 @@ import org.citrusframework.http.client.HttpClient; import org.citrusframework.http.message.HttpMessage; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; +import org.mockito.Mock; import org.springframework.http.HttpStatusCode; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import static org.citrusframework.http.message.HttpMessageHeaders.HTTP_REASON_PHRASE; import static org.citrusframework.http.message.HttpMessageHeaders.HTTP_STATUS_CODE; -import static org.mockito.Mockito.mock; +import static org.mockito.MockitoAnnotations.openMocks; import static org.springframework.http.HttpStatus.OK; import static org.springframework.test.util.ReflectionTestUtils.getField; +import static org.testng.Assert.assertTrue; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNotNull; public class HttpClientActionBuilderTest { + @Mock private HttpClient httpClientMock; + private HttpClientActionBuilder fixture; + + private AutoCloseable openMocks; + @BeforeMethod void beforeMethodSetup() { - httpClientMock = mock(HttpClient.class); + openMocks = openMocks(this); + fixture = new HttpClientActionBuilder(httpClientMock); } @Test public void responseWithHttpStatus() { - var fixture = new HttpClientActionBuilder(httpClientMock) - .receive() + var httpMessageBuilderSupport = fixture.receive() .response(OK) // Method under test .message(); - var httpMessage = (HttpMessage) getField(fixture, HttpClientResponseActionBuilder.HttpMessageBuilderSupport.class, "httpMessage"); + var httpMessage = (HttpMessage) getField(httpMessageBuilderSupport, HttpClientResponseActionBuilder.HttpMessageBuilderSupport.class, "httpMessage"); assertNotNull(httpMessage); var headers = httpMessage.getHeaders(); @@ -43,16 +52,26 @@ public void responseWithHttpStatus() { public void responseWithHttpStatusCode() { var code = 123; - var fixture = new HttpClientActionBuilder(httpClientMock) + var httpMessageBuilderSupport = new HttpClientActionBuilder(httpClientMock) .receive() .response(HttpStatusCode.valueOf(code)) // Method under test .message(); - var httpMessage = (HttpMessage) getField(fixture, HttpClientResponseActionBuilder.HttpMessageBuilderSupport.class, "httpMessage"); + var httpMessage = (HttpMessage) getField(httpMessageBuilderSupport, HttpClientResponseActionBuilder.HttpMessageBuilderSupport.class, "httpMessage"); assertNotNull(httpMessage); var headers = httpMessage.getHeaders(); assertEquals(code, headers.get(HTTP_STATUS_CODE)); assertFalse(headers.containsKey(HTTP_REASON_PHRASE)); } + + @Test + public void isReferenceResolverAwareTestActionBuilder() { + assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); + } + + @AfterMethod + public void afterMethod() throws Exception { + openMocks.close(); + } } diff --git a/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpServerActionBuilderTest.java b/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpServerActionBuilderTest.java index d0b46c8a55..a3c6d541af 100644 --- a/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpServerActionBuilderTest.java +++ b/endpoints/citrus-http/src/test/java/org/citrusframework/http/actions/HttpServerActionBuilderTest.java @@ -18,8 +18,10 @@ import org.citrusframework.endpoint.Endpoint; import org.citrusframework.http.message.HttpMessage; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -66,6 +68,11 @@ public void sendOkJsonFromObject() { verifyOkJsonResponse(httpMessageBuilderSupport); } + @Test + public void isReferenceResolverAwareTestActionBuilder() { + Assert.assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); + } + private record TestJsonObject(String property) { } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapActionBuilder.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapActionBuilder.java index 41402d9ec8..30351fe76b 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapActionBuilder.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapActionBuilder.java @@ -17,9 +17,8 @@ package org.citrusframework.ws.actions; import org.citrusframework.TestAction; -import org.citrusframework.TestActionBuilder; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; -import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; import org.citrusframework.ws.client.WebServiceClient; import org.citrusframework.ws.server.WebServiceServer; @@ -30,12 +29,7 @@ * @author Christoph Deppisch * @since 2.6 */ -public class SoapActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { - - /** Bean reference resolver */ - private ReferenceResolver referenceResolver; - - private TestActionBuilder delegate; +public class SoapActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { /** * Static entrance method for the SOAP fluent action builder. @@ -99,24 +93,4 @@ public TestAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapClientActionBuilder.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapClientActionBuilder.java index 91eedd7549..ceb29b16d4 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapClientActionBuilder.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapClientActionBuilder.java @@ -19,8 +19,8 @@ import org.citrusframework.TestAction; import org.citrusframework.TestActionBuilder; import org.citrusframework.endpoint.Endpoint; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; -import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; /** @@ -29,7 +29,7 @@ * @author Christoph Deppisch * @since 2.6 */ -public class SoapClientActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { +public class SoapClientActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { /** Bean reference resolver */ private ReferenceResolver referenceResolver; @@ -122,24 +122,4 @@ public TestAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapServerActionBuilder.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapServerActionBuilder.java index 117a0a64f1..30a6f14e43 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapServerActionBuilder.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SoapServerActionBuilder.java @@ -17,10 +17,9 @@ package org.citrusframework.ws.actions; import org.citrusframework.TestAction; -import org.citrusframework.TestActionBuilder; import org.citrusframework.endpoint.Endpoint; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.citrusframework.spi.ReferenceResolver; -import org.citrusframework.spi.ReferenceResolverAware; import org.citrusframework.util.ObjectHelper; /** @@ -29,17 +28,12 @@ * @author Christoph Deppisch * @since 2.6 */ -public class SoapServerActionBuilder implements TestActionBuilder.DelegatingTestActionBuilder, ReferenceResolverAware { - - /** Bean reference resolver */ - private ReferenceResolver referenceResolver; +public class SoapServerActionBuilder extends AbstractReferenceResolverAwareTestActionBuilder { /** Target soap client instance */ private Endpoint soapServer; private String soapServerUri; - private TestActionBuilder delegate; - /** * Default constructor. */ @@ -122,24 +116,4 @@ public TestAction build() { ObjectHelper.assertNotNull(delegate, "Missing delegate action to build"); return delegate.build(); } - - @Override - public TestActionBuilder getDelegate() { - return delegate; - } - - /** - * Specifies the referenceResolver. - * @param referenceResolver - */ - @Override - public void setReferenceResolver(ReferenceResolver referenceResolver) { - if (referenceResolver == null) { - this.referenceResolver = referenceResolver; - - if (delegate instanceof ReferenceResolverAware) { - ((ReferenceResolverAware) delegate).setReferenceResolver(referenceResolver); - } - } - } } diff --git a/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapActionBuilderTest.java b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapActionBuilderTest.java index 4cc361eb47..39b0838d55 100644 --- a/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapActionBuilderTest.java +++ b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapActionBuilderTest.java @@ -16,17 +16,28 @@ package org.citrusframework.ws.actions; -import java.util.Map; - import org.citrusframework.TestActionBuilder; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; import org.testng.Assert; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import java.util.Map; + +import static org.testng.Assert.assertTrue; + /** * @author Christoph Deppisch */ public class SoapActionBuilderTest { + private SoapActionBuilder fixture; + + @BeforeMethod + void beforeMethod() { + fixture = new SoapActionBuilder(); + } + @Test public void shouldLookupTestActionBuilder() { Map> endpointBuilders = TestActionBuilder.lookup(); @@ -35,4 +46,9 @@ public void shouldLookupTestActionBuilder() { Assert.assertTrue(TestActionBuilder.lookup("soap").isPresent()); Assert.assertEquals(TestActionBuilder.lookup("soap").get().getClass(), SoapActionBuilder.class); } + + @Test + public void isReferenceResolverAwareTestActionBuilder() { + assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); + } } diff --git a/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapClientActionBuilderTest.java b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapClientActionBuilderTest.java new file mode 100644 index 0000000000..e61fdd5d22 --- /dev/null +++ b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapClientActionBuilderTest.java @@ -0,0 +1,24 @@ +package org.citrusframework.ws.actions; + +import org.citrusframework.endpoint.Endpoint; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.mockito.Mockito.mock; +import static org.testng.Assert.assertTrue; + +public class SoapClientActionBuilderTest { + + private SoapClientActionBuilder fixture; + + @BeforeMethod + public void beforeMethod() { + fixture = new SoapClientActionBuilder(mock(Endpoint.class)); + } + + @Test + public void isReferenceResolverAwareTestActionBuilder() { + assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); + } +} diff --git a/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapServerActionBuilderTest.java b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapServerActionBuilderTest.java new file mode 100644 index 0000000000..864807e367 --- /dev/null +++ b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/actions/SoapServerActionBuilderTest.java @@ -0,0 +1,24 @@ +package org.citrusframework.ws.actions; + +import org.citrusframework.endpoint.Endpoint; +import org.citrusframework.spi.AbstractReferenceResolverAwareTestActionBuilder; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.mockito.Mockito.mock; +import static org.testng.Assert.assertTrue; + +public class SoapServerActionBuilderTest { + + private SoapServerActionBuilder fixture; + + @BeforeMethod + public void beforeMethod() { + fixture = new SoapServerActionBuilder(mock(Endpoint.class)); + } + + @Test + public void isReferenceResolverAwareTestActionBuilder() { + assertTrue(fixture instanceof AbstractReferenceResolverAwareTestActionBuilder, "Is instanceof AbstractReferenceResolverAwareTestActionBuilder"); + } +}