2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.dmaap.dbcapi.model;
22 import static org.junit.Assert.*;
24 import java.lang.reflect.Constructor;
25 import java.lang.reflect.InvocationTargetException;
26 import java.lang.reflect.Method;
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31 public class DRSubTest {
32 String d, un, up, f, du, lu, s, o;
36 public void setUp() throws Exception {
42 du = "sub.server.onap.org:8443/deliver/here";
43 lu = "https://drps.onap.org:8443/sublog/123";
50 public void tearDown() throws Exception {
55 public void testDRSubClassDefaultConstructor() {
57 DR_Sub t = new DR_Sub();
59 assertTrue( t.getDcaeLocationName() == null );
60 assertTrue( t.getUsername() == null );
61 assertTrue( t.getUserpwd() == null );
62 assertTrue( t.getFeedId() == null );
63 assertTrue( t.getDeliveryURL() == null );
64 assertTrue( t.getLogURL() == null );
65 assertTrue( t.getSubId() == null );
66 assertTrue( ! t.isUse100() );
67 assertTrue( ! t.isSuspended() );
68 assertTrue( t.getOwner() == null );
73 public void testDRSubClassConstructor() {
75 DR_Sub t = new DR_Sub( d, un, up, f, du, lu, u100 );
77 assertTrue( d.equals( t.getDcaeLocationName() ));
78 assertTrue( un.equals( t.getUsername() ));
79 assertTrue( up.equals( t.getUserpwd() ));
80 assertTrue( f.equals( t.getFeedId() ));
81 assertTrue( du.equals( t.getDeliveryURL() ) );
82 assertTrue( lu.equals( t.getLogURL() ) );
83 assertTrue( t.isUse100() );
84 assertTrue( ! t.isSuspended() );
88 public void testDRSubClassSetters() {
90 DR_Sub t = new DR_Sub();
92 t.setDcaeLocationName( d );
93 assertTrue( d.equals( t.getDcaeLocationName() ));
95 assertTrue( un.equals( t.getUsername() ));
97 assertTrue( up.equals( t.getUserpwd() ));
99 assertTrue( f.equals( t.getFeedId() ));
101 assertTrue( s.equals( t.getSubId() ));
102 t.setDeliveryURL( du );
103 assertTrue( du.equals( t.getDeliveryURL() ) );
105 assertTrue( lu.equals( t.getLogURL() ) );
110 public void test3() {
111 String json = String.format( "{ \"%s\": \"%s\", \"%s\": false, \"%s\": { \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": \"%s\" }, \"%s\": { \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": \"%s\", \"%s\": true } }",
112 "subscriber", "owner",
115 "feed", "https://feed.onap.org/publish/22",
116 "self", "https://feed.onap.org/subscriber/44",
126 DR_Sub t = new DR_Sub( json );
128 assertTrue( un.equals( t.getUsername() ));
129 assertTrue( up.equals( t.getUserpwd() ));
130 assertTrue( f.equals( t.getFeedId() ));
131 assertTrue( du.equals( t.getDeliveryURL() ) );
132 assertTrue( lu.equals( t.getLogURL() ) );
133 assertTrue( ! t.isSuspended() );
135 String o = t.toString();