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 125cb266..3e694c9a 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,8 +1,5 @@ package org.springframework.cloud.zookeeper.discovery; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; - import org.apache.curator.framework.CuratorFramework; import org.junit.Test; import org.junit.runner.RunWith; @@ -23,7 +20,11 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.client.RestTemplate; -import static com.toomuchcoding.jsonassert.JsonAssertion.*; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import java.util.List; + +import static org.assertj.core.api.BDDAssertions.then; /** * @author Marcin Grzejszczak @@ -39,17 +40,58 @@ public class ZookeeperDiscoveryHealthIndicatorWithNestedStructureTests { // 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: - String response = this.testRibbonClient.callService("me", "health"); + Response response = this.testRibbonClient.callService("me", "health", Response.class); // then: - twoServicesArePresentedInHealthEndpoint(response); + then(response.discoveryComposite.zookeeper.services).extracting("name").contains("me", "/a/b/c/d/anotherservice"); } - 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; + 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; + } } - @Configuration @EnableAutoConfiguration diff --git a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryTests.java b/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryTests.java index be273acf..2291366d 100644 --- a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryTests.java +++ b/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoveryTests.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.concurrent.Callable; import com.jayway.awaitility.Awaitility; -import com.toomuchcoding.jsonassert.JsonAssertion; import com.toomuchcoding.jsonassert.JsonPath; import org.junit.Test;