update the package name
[dmaap/messagerouter/dmaapclient.git] / src / test / java / org / onap / dmaap / mr / client / impl / MRMetaClientTest.java
-/*******************************************************************************\r
- *  ============LICENSE_START=======================================================\r
- *  org.onap.dmaap\r
- *  ================================================================================\r
- *  Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- *  ================================================================================\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *  You may obtain a copy of the License at\r
- *        http://www.apache.org/licenses/LICENSE-2.0\r
- *  \r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
- *  ============LICENSE_END=========================================================\r
- *\r
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- *  \r
- *******************************************************************************/\r
-package com.att.nsa.mr.client.impl;\r
-\r
-import java.io.IOException;\r
-import java.net.MalformedURLException;\r
-import java.util.Collection;\r
-import java.util.LinkedList;\r
-import java.util.Set;\r
-\r
-import org.junit.Before;\r
-import org.junit.Rule;\r
-import org.junit.Test;\r
-\r
-import static com.github.tomakehurst.wiremock.client.WireMock.*;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import com.att.nsa.apiClient.http.HttpException;\r
-import com.att.nsa.apiClient.http.HttpObjectNotFoundException;\r
-import com.att.nsa.mr.client.MRClient.MRApiException;\r
-import com.att.nsa.mr.client.MRTopicManager.TopicInfo;\r
-import com.github.tomakehurst.wiremock.junit.WireMockRule;\r
-\r
-\r
-public class MRMetaClientTest {\r
-       \r
-       @Rule public WireMockRule wireMock = new WireMockRule();\r
-       \r
-       @Before\r
-       public void setUp(){\r
-               wireMock.stubFor(get(urlEqualTo("/topics"))\r
-                .willReturn(aResponse().withBody("{\"topics\":[\"topic1\",\"topic2\"]}").withHeader("Content-Type", "application/json")));\r
-               wireMock.stubFor(get(urlEqualTo("/topics/topic1"))\r
-                .willReturn(aResponse().withBody("{\"topics\":[\"topic1\",\"topic2\"]}").withHeader("Content-Type", "application/json")));\r
-               wireMock.stubFor(post(urlEqualTo("/topics/create"))\r
-                               .willReturn(aResponse().withStatus(200)));\r
-       }\r
-       \r
-       @Test\r
-       public void getTopicsTest() \r
-       {\r
-               final Collection<String> hosts = new LinkedList<String> ();\r
-               hosts.add ( "localhost:" + wireMock.port() );\r
-               \r
-               MRMetaClient c;\r
-               try {\r
-                       c = new MRMetaClient(hosts);\r
-                       Set<String> setString=c.getTopics();\r
-               } catch (IOException e) {\r
-                       e.printStackTrace();\r
-               }\r
-               \r
-               \r
-       //      assertEquals ("http://localhost:8080/events/" + "topic/cg/cid", url );\r
-               \r
-       }\r
-       \r
-       @Test\r
-       public void getTopicMetadataTest() {\r
-               final Collection<String> hosts = new LinkedList<String> ();\r
-               hosts.add ( "localhost:" + wireMock.port() );\r
-               \r
-               final String topic ="topic1";\r
-               \r
-               MRMetaClient c;\r
-               try {\r
-                       c = new MRMetaClient(hosts);\r
-                       TopicInfo topicInfo=c.getTopicMetadata(topic);\r
-               } catch (IOException | HttpObjectNotFoundException e) {\r
-                       e.printStackTrace();\r
-               }       \r
-               \r
-       }\r
-       \r
-       @Test\r
-       public void testcreateTopic(){\r
-               final Collection<String> hosts = new LinkedList<String> ();\r
-               hosts.add ( "localhost:" + wireMock.port() );\r
-               \r
-               MRMetaClient c;\r
-               try {\r
-                       c = new MRMetaClient(hosts);\r
-                       c.createTopic("topic1", "testTopic", 1, 1);\r
-               } catch (IOException | HttpException e) {\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-       @Test\r
-       public void testupdateApiKey(){\r
-               final Collection<String> hosts = new LinkedList<String> ();\r
-               hosts.add ( "localhost:" + wireMock.port() );\r
-               \r
-               MRMetaClient c;\r
-               try {\r
-                       c = new MRMetaClient(hosts);\r
-                       c.updateCurrentApiKey("test@onap.com", "test email");\r
-               }catch (HttpException e) {\r
-                       \r
-               } catch (IOException e) {\r
-                       // TODO Auto-generated catch block\r
-                       e.printStackTrace();\r
-               }\r
-               catch (NullPointerException e) {\r
-                       assertTrue(true);\r
-               }\r
-               \r
-       }\r
-\r
-       \r
-}\r
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  org.onap.dmaap
+ *  ================================================================================
+ *  Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ *  ================================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  ============LICENSE_END=========================================================
+ *
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ *  
+ *******************************************************************************/
+package org.onap.dmaap.mr.client.impl;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.junit.Assert.assertTrue;
+
+import com.att.nsa.apiClient.http.HttpException;
+import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
+import org.onap.dmaap.mr.client.MRClient.MRApiException;
+import org.onap.dmaap.mr.client.MRTopicManager.TopicInfo;
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
+
+public class MRMetaClientTest {
+       
+       @Rule public WireMockRule wireMock = new WireMockRule();
+       
+       @Before
+       public void setUp(){
+               wireMock.stubFor(get(urlEqualTo("/topics"))
+                .willReturn(aResponse().withBody("{\"topics\":[\"topic1\",\"topic2\"]}").withHeader("Content-Type", "application/json")));
+               wireMock.stubFor(get(urlEqualTo("/topics/topic1"))
+                .willReturn(aResponse().withBody("{\"topics\":[\"topic1\",\"topic2\"]}").withHeader("Content-Type", "application/json")));
+               wireMock.stubFor(post(urlEqualTo("/topics/create"))
+                               .willReturn(aResponse().withStatus(200)));
+       }
+       
+       @Test
+       public void getTopicsTest() 
+       {
+               final Collection<String> hosts = new LinkedList<String> ();
+               hosts.add ( "localhost:" + wireMock.port() );
+               
+               MRMetaClient c;
+               try {
+                       c = new MRMetaClient(hosts);
+                       Set<String> setString=c.getTopics();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               
+               
+       //      assertEquals ("http://localhost:8080/events/" + "topic/cg/cid", url );
+               
+       }
+       
+       @Test
+       public void getTopicMetadataTest() {
+               final Collection<String> hosts = new LinkedList<String> ();
+               hosts.add ( "localhost:" + wireMock.port() );
+               
+               final String topic ="topic1";
+               
+               MRMetaClient c;
+               try {
+                       c = new MRMetaClient(hosts);
+                       TopicInfo topicInfo=c.getTopicMetadata(topic);
+               } catch (IOException | HttpObjectNotFoundException e) {
+                       e.printStackTrace();
+               }       
+               
+       }
+       
+       @Test
+       public void testcreateTopic(){
+               final Collection<String> hosts = new LinkedList<String> ();
+               hosts.add ( "localhost:" + wireMock.port() );
+               
+               MRMetaClient c;
+               try {
+                       c = new MRMetaClient(hosts);
+                       c.createTopic("topic1", "testTopic", 1, 1);
+               } catch (IOException | HttpException e) {
+                       e.printStackTrace();
+               }
+       }
+       @Test
+       public void testupdateApiKey(){
+               final Collection<String> hosts = new LinkedList<String> ();
+               hosts.add ( "localhost:" + wireMock.port() );
+               
+               MRMetaClient c;
+               try {
+                       c = new MRMetaClient(hosts);
+                       c.updateCurrentApiKey("test@onap.com", "test email");
+               }catch (HttpException e) {
+                       
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+               catch (NullPointerException e) {
+                       assertTrue(true);
+               }
+               
+       }
+
+       
+}