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.assertEquals;
26 import static org.junit.Assert.assertTrue;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
32 public class MRClientTest {
34 ReflectionHarness rh = new ReflectionHarness();
39 public void setUp() throws Exception {
40 System.setProperty("ConfigFile", "src/test/resources/dmaapbc.properties");
42 t = "org.onap.dmaap.interestingTopic";
43 f = "mrc.onap.org:3904/events/org.onap.dmaap.interestingTopic";
50 // can't use simple reflection to test for null since null constructor
51 // initializes some fields.
52 // rh.reflect( "org.onap.dmaap.dbcapi.model.MR_Client", "get", null );
53 // so brute force instead...
54 String[] a = { "put", "view" };
55 MR_Client m = new MR_Client();
57 assertTrue(null == m.getDcaeLocationName());
58 assertTrue(null == m.getFqtn());
59 assertTrue(null == m.getClientRole());
60 assertTrue(null == m.getAction());
66 String[] a = { "put", "view" };
67 MR_Client m = new MR_Client(d, f, c, a);
69 assertTrue(d.equals(m.getDcaeLocationName()));
70 assertTrue(f.equals(m.getFqtn()));
71 assertTrue(c.equals(m.getClientRole()));
72 String[] ma = m.getAction();
73 assertTrue(a.length == ma.length);
74 for (int i = 0; i < a.length; i++) {
75 assertTrue(a[i].equals(ma[i]));
81 String v = "Validate";
82 rh.reflect("org.onap.dmaap.dbcapi.model.MR_Client", "set", v);
87 MR_Client mrClient = new MR_Client();
88 String stringArray[] = { "test" };
89 mrClient.setAction(stringArray);
90 mrClient.hasAction("");
91 mrClient.setMrClientId("mrClientId");
92 mrClient.setTopicURL("testTopicURL");
93 mrClient.setClientIdentity("clientIdentity");
95 assertEquals("clientIdentity", mrClient.getClientIdentity());
96 assertEquals("testTopicURL", mrClient.getTopicURL());
97 assertEquals("mrClientId", mrClient.getMrClientId());
98 assertEquals(false, mrClient.isPublisher());
99 assertEquals(false, mrClient.isSubscriber());
100 assertEquals("test", mrClient.getAction()[0]);