From 588b7bd403e0fe1ab87dd5cc81da40593492ff0c Mon Sep 17 00:00:00 2001 From: Jaro Hartmann Date: Tue, 23 Jan 2024 17:45:50 +0100 Subject: [PATCH] feat(edc-client):[#344] Extend SemanticHubWiremockTest --- .../semanticshub/SemanticHubWiremockTest.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/irs-api/src/test/java/org/eclipse/tractusx/irs/semanticshub/SemanticHubWiremockTest.java b/irs-api/src/test/java/org/eclipse/tractusx/irs/semanticshub/SemanticHubWiremockTest.java index 738a1d9373..1106c18891 100644 --- a/irs-api/src/test/java/org/eclipse/tractusx/irs/semanticshub/SemanticHubWiremockTest.java +++ b/irs-api/src/test/java/org/eclipse/tractusx/irs/semanticshub/SemanticHubWiremockTest.java @@ -29,44 +29,35 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.givenThat; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.tractusx.irs.testing.wiremock.WireMockConfig.restTemplateProxy; -import com.github.tomakehurst.wiremock.WireMockServer; +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; +import com.github.tomakehurst.wiremock.junit5.WireMockTest; import org.eclipse.tractusx.irs.configuration.SemanticsHubConfiguration; import org.eclipse.tractusx.irs.services.validation.SchemaNotFoundException; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.web.client.RestTemplate; +@WireMockTest class SemanticHubWiremockTest { - private WireMockServer wireMockServer; - + private static final String PROXY_SERVER_HOST = "127.0.0.1"; private SemanticsHubFacade semanticsHubFacade; - private SemanticsHubConfiguration config; @BeforeEach - void configureSystemUnderTest() { - this.wireMockServer = new WireMockServer(options().dynamicPort()); - this.wireMockServer.start(); - configureFor(this.wireMockServer.port()); + void configureSystemUnderTest(WireMockRuntimeInfo wireMockRuntimeInfo) { + final RestTemplate restTemplate = restTemplateProxy(PROXY_SERVER_HOST, wireMockRuntimeInfo.getHttpPort()); - config = new SemanticsHubConfiguration(); + final SemanticsHubConfiguration config = new SemanticsHubConfiguration(); config.setPageSize(10); - config.setUrl(String.format("http://localhost:%d/models", this.wireMockServer.port())); - config.setModelJsonSchemaEndpoint("sem.hub/models/{urn}/json-schema"); + config.setUrl("http://semantic.hub/models"); + config.setModelJsonSchemaEndpoint("http://semantic.hub/models/{urn}/json-schema"); - final RestTemplate restTemplate = new RestTemplate(); final SemanticsHubClient semanticsHubClient = new SemanticsHubClientImpl(restTemplate, config); semanticsHubFacade = new SemanticsHubFacade(semanticsHubClient); } - @AfterEach - void tearDown() { - this.wireMockServer.stop(); - } - @Test void shouldReturn1Page() throws SchemaNotFoundException { givenThat(get(urlPathEqualTo("/models")).willReturn(aResponse().withStatus(200)