From b003f7e5e8a955ccc33ea2d6e90b9f687dc0df8a Mon Sep 17 00:00:00 2001 From: haaggarw <haaggarw@microsoft.com> Date: Sat, 17 Oct 2020 06:51:00 +0000 Subject: [PATCH] minor fix --- .../subscriber/TestListTopicsApi.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 063a8b90c..eaa0ee087 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 { -- GitLab