2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (C) 2019 IBM.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.dmaap.dbcapi.model;
25 import static org.junit.Assert.*;
27 import org.junit.After;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
32 public class MRClientTest {
34 private static final String fmt = "%24s: %s%n";
36 ReflectionHarness rh = new ReflectionHarness();
41 public void setUp() throws Exception {
43 t = "org.onap.dmaap.interestingTopic";
44 f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
50 public void tearDown() throws Exception {
56 // can't use simple reflection to test for null since null constructor
57 // initializes some fields.
58 // rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null );
59 // so brute force instead...
60 String[] a = { "put", "view" };
61 MR_Client m = new MR_Client();
63 assertTrue(null == m.getDcaeLocationName());
64 assertTrue(null == m.getFqtn());
65 assertTrue(null == m.getClientRole());
66 assertTrue(null == m.getAction());
72 String[] a = { "put", "view" };
73 MR_Client m = new MR_Client(d, f, c, a);
75 assertTrue(d.equals(m.getDcaeLocationName()));
76 assertTrue(f.equals(m.getFqtn()));
77 assertTrue(c.equals(m.getClientRole()));
78 String[] ma = m.getAction();
79 assertTrue(a.length == ma.length);
80 for (int i = 0; i < a.length; i++) {
81 assertTrue(a[i].equals(ma[i]));
88 String v = "Validate";
89 rh.reflect("org.onap.dmaap.dbcapi.model.MR_Client", "set", v);
94 MR_Client mrClient = new MR_Client();
95 String stringArray[] = { "test" };
96 mrClient.setAction(stringArray);
97 mrClient.hasAction("");
98 mrClient.setMrClientId("mrClientId");
99 mrClient.setTopicURL("testTopicURL");
100 mrClient.setClientIdentity("clientIdentity");
102 assertEquals("clientIdentity", mrClient.getClientIdentity());
103 assertEquals("testTopicURL", mrClient.getTopicURL());
104 assertEquals("mrClientId", mrClient.getMrClientId());
105 assertEquals(false, mrClient.isPublisher());
106 assertEquals(false, mrClient.isSubscriber());
107 assertEquals("test", mrClient.getAction()[0]);