diff --git a/service-registration/eureka/src/main/java/io/smallrye/stork/serviceregistration/eureka/EurekaServiceRegistrar.java b/service-registration/eureka/src/main/java/io/smallrye/stork/serviceregistration/eureka/EurekaServiceRegistrar.java index 66d1a729..eb487e2f 100644 --- a/service-registration/eureka/src/main/java/io/smallrye/stork/serviceregistration/eureka/EurekaServiceRegistrar.java +++ b/service-registration/eureka/src/main/java/io/smallrye/stork/serviceregistration/eureka/EurekaServiceRegistrar.java @@ -42,7 +42,7 @@ public Uni registerServiceInstance(String serviceName, Metadata registrationLatch.countDown(), failure -> fail("")); await().atMost(Duration.ofSeconds(10)) @@ -109,6 +110,14 @@ public void testRegistrationServiceInstances(TestInfo info) { assertThat(httpResponse).isNotNull(); assertThat(httpResponse.statusCode()).isEqualTo(200); + JsonObject jsonResponse = httpResponse.bodyAsJsonObject(); + JsonObject application = jsonResponse.getJsonObject("application"); + JsonObject jsonServiceInstance = application.getJsonArray("instance").getJsonObject(0); + + assertThat(jsonServiceInstance.getString("instanceId")).isEqualTo("my-service"); + assertThat(jsonServiceInstance.getString("ipAddr")).isEqualTo("localhost"); + assertThat(jsonServiceInstance.getJsonObject("port").getInteger("$")).isEqualTo(8406); + } } diff --git a/service-registration/eureka/src/test/java/io/smallrye/stork/serviceregistration/eureka/EurekaRegistrationTest.java b/service-registration/eureka/src/test/java/io/smallrye/stork/serviceregistration/eureka/EurekaRegistrationTest.java index 669635e7..43a86bb9 100644 --- a/service-registration/eureka/src/test/java/io/smallrye/stork/serviceregistration/eureka/EurekaRegistrationTest.java +++ b/service-registration/eureka/src/test/java/io/smallrye/stork/serviceregistration/eureka/EurekaRegistrationTest.java @@ -27,6 +27,7 @@ import io.smallrye.stork.impl.EurekaMetadataKey; import io.smallrye.stork.test.StorkTestUtils; import io.smallrye.stork.test.TestConfigProvider; +import io.vertx.core.json.JsonObject; import io.vertx.ext.web.client.WebClientOptions; import io.vertx.mutiny.core.Vertx; import io.vertx.mutiny.core.buffer.Buffer; @@ -77,7 +78,7 @@ public void testRegistrationServiceInstances(TestInfo info) { CountDownLatch registrationLatch = new CountDownLatch(1); eurekaServiceRegistrar.registerServiceInstance(serviceName, Metadata.of(EurekaMetadataKey.class) - .with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "acme.com", 8406).subscribe() + .with(EurekaMetadataKey.META_EUREKA_SERVICE_ID, serviceName), "localhost", 8406).subscribe() .with(success -> registrationLatch.countDown(), failure -> fail("")); await().atMost(Duration.ofSeconds(10)) @@ -93,6 +94,14 @@ public void testRegistrationServiceInstances(TestInfo info) { assertThat(httpResponse).isNotNull(); assertThat(httpResponse.statusCode()).isEqualTo(200); + JsonObject jsonResponse = httpResponse.bodyAsJsonObject(); + JsonObject application = jsonResponse.getJsonObject("application"); + JsonObject jsonServiceInstance = application.getJsonArray("instance").getJsonObject(0); + + assertThat(jsonServiceInstance.getString("instanceId")).isEqualTo("my-service"); + assertThat(jsonServiceInstance.getString("ipAddr")).isEqualTo("localhost"); + assertThat(jsonServiceInstance.getJsonObject("port").getInteger("$")).isEqualTo(8406); + } }