diff --git a/testing/register-test-azure/src/test/java/org/opengroup/osdu/register/subscriber/TestListTopicsApi.java b/testing/register-test-azure/src/test/java/org/opengroup/osdu/register/subscriber/TestListTopicsApi.java index 063a8b90ccdbb353168f8714291f4fa2fa76a8a9..eaa0ee087e7e152cfc20d7e6e2267e3650ce79f9 100644 --- a/testing/register-test-azure/src/test/java/org/opengroup/osdu/register/subscriber/TestListTopicsApi.java +++ b/testing/register-test-azure/src/test/java/org/opengroup/osdu/register/subscriber/TestListTopicsApi.java @@ -16,13 +16,21 @@ package org.opengroup.osdu.register.subscriber; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.sun.jersey.api.client.ClientResponse; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.opengroup.osdu.register.model.Topic; import org.opengroup.osdu.register.util.AzureTestUtils; +import org.opengroup.osdu.register.util.RestDescriptor; + +import java.util.ArrayList; +import java.util.List; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class TestListTopicsApi extends ListTopicsApiTest { @@ -38,6 +46,18 @@ public class TestListTopicsApi extends ListTopicsApiTest { this.testUtils = null; } + @Override + protected void validate20XResponse(ClientResponse response, RestDescriptor descriptor) { + String body = response.getEntity(String.class); + java.lang.reflect.Type listType = new TypeToken<ArrayList<Topic>>() { + }.getType(); + Gson gson = new Gson(); + List<Topic> messages = gson.fromJson(body, listType); + assertTrue(messages.size() > 0); + String topic = System.getProperty("TEST_TOPIC_NAME", System.getenv("TEST_TOPIC_NAME")); + assertTrue(messages.stream().anyMatch(m -> m.name.equalsIgnoreCase(topic))); + } + @Test @Override public void should_return400_when_makingHttpRequestWithoutToken() throws Exception {