diff --git a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryHealthIndicatorWithNestedStructureTests.java b/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryHealthIndicatorWithNestedStructureTests.java index 3e694c9a..6c74562e 100644 --- a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryHealthIndicatorWithNestedStructureTests.java +++ b/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryHealthIndicatorWithNestedStructureTests.java @@ -1,5 +1,10 @@ package org.springframework.cloud.zookeeper.discovery; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.curator.framework.CuratorFramework; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,11 +25,9 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.client.RestTemplate; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import java.util.List; +import java.lang.invoke.MethodHandles; -import static org.assertj.core.api.BDDAssertions.then; +import static com.toomuchcoding.jsonassert.JsonAssertion.*; /** * @author Marcin Grzejszczak @@ -35,62 +38,23 @@ import static org.assertj.core.api.BDDAssertions.then; @WebIntegrationTest(randomPort = true) public class ZookeeperDiscoveryHealthIndicatorWithNestedStructureTests { + private static final Log log = LogFactory.getLog(MethodHandles.lookup().lookupClass()); + @Autowired TestRibbonClient testRibbonClient; // Issue: #54 - ZookeeperDiscoveryHealthIndicator fails on nested structure @Test public void should_return_a_response_that_app_is_in_a_healthy_state_when_nested_folders_in_zookeeper_are_present() { // when: - Response response = this.testRibbonClient.callService("me", "health", Response.class); + String response = this.testRibbonClient.callService("me", "health"); // then: - then(response.discoveryComposite.zookeeper.services).extracting("name").contains("me", "/a/b/c/d/anotherservice"); + log.info("Received response [" + response + "]"); + twoServicesArePresentedInHealthEndpoint(response); } - public static class Response { - DiscoveryComposite discoveryComposite; - - public DiscoveryComposite getDiscoveryComposite() { - return this.discoveryComposite; - } - - public void setDiscoveryComposite(DiscoveryComposite discoveryComposite) { - this.discoveryComposite = discoveryComposite; - } - } - - public static class DiscoveryComposite { - Zoo zookeeper; - - public Zoo getZookeeper() { - return this.zookeeper; - } - - public void setZookeeper(Zoo zookeeper) { - this.zookeeper = zookeeper; - } - } - - public static class Zoo { - List services; - - public List getServices() { - return this.services; - } - - public void setServices(List services) { - this.services = services; - } - } - - public static class Service { - String name; - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } + private boolean twoServicesArePresentedInHealthEndpoint(String response) { + assertThat(response).field("discoveryComposite").field("zookeeper").array("services").field("name").isEqualTo("me"); + assertThat(response).field("discoveryComposite").field("zookeeper").array("services").field("name").isEqualTo("/a/b/c/d/anotherservice"); + return true; } @Configuration