1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 *******************************************************************************/
22 package org.onap.dmaap.mr.client.impl;
24 import java.io.IOException;
25 import java.util.Collection;
26 import java.util.LinkedList;
28 import org.junit.Before;
29 import org.junit.Test;
31 import static org.junit.Assert.assertNotNull;
32 import static org.junit.Assert.assertTrue;
33 import com.att.nsa.apiClient.http.HttpException;
34 import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
35 import org.onap.dmaap.mr.client.MRTopicManager.TopicInfo;
38 public class MRMetaClientTest {
40 //@Rule public WireMockRule wireMock = new WireMockRule();
43 public void setUp(){/*
44 wireMock.stubFor(get(urlEqualTo("/topics"))
45 .willReturn(aResponse().withBody("{\"topics\":[\"topic1\",\"topic2\"]}").withHeader("Content-Type", "application/json")));
46 wireMock.stubFor(get(urlEqualTo("/topics/topic1"))
47 .willReturn(aResponse().withBody("{\"topics\":[\"topic1\",\"topic2\"]}").withHeader("Content-Type", "application/json")));
48 wireMock.stubFor(post(urlEqualTo("/topics/create"))
49 .willReturn(aResponse().withStatus(200)));
53 public void getTopicsTest()
55 final Collection<String> hosts = new LinkedList<String> ();
56 hosts.add ( "localhost:" +3904 );
60 c = new MRMetaClient(hosts);
61 Set<String> setString=c.getTopics();
62 } catch (IOException e) {
68 // assertEquals ("http://localhost:8080/events/" + "topic/cg/cid", url );
73 public void getTopicMetadataTest() {
74 final Collection<String> hosts = new LinkedList<String> ();
75 hosts.add ( "localhost:" + 3904 );
77 final String topic ="topic1";
81 c = new MRMetaClient(hosts);
82 TopicInfo topicInfo=c.getTopicMetadata(topic);
83 } catch (IOException | HttpObjectNotFoundException e) {
91 public void testcreateTopic(){
92 final Collection<String> hosts = new LinkedList<String> ();
93 hosts.add ( "localhost:" + 3904 );
97 c = new MRMetaClient(hosts);
98 c.createTopic("topic1", "testTopic", 1, 1);
99 } catch (IOException | HttpException e) {
102 assertNotNull(hosts);
105 public void testupdateApiKey(){
106 final Collection<String> hosts = new LinkedList<String> ();
107 hosts.add ( "localhost:" + 3904 );
111 c = new MRMetaClient(hosts);
112 c.updateCurrentApiKey("test@onap.com", "test email");
113 }catch (HttpException e) {
115 } catch (IOException e) {
116 // TODO Auto-generated catch block
119 catch (NullPointerException e) {