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 );
69 assertTrue( t.isGuaranteedDelivery() == false );
70 assertTrue( t.isGuaranteedSequence() == false );
71 assertTrue( t.isPrivilegedSubscriber() == false );
72 assertTrue( t.isDecompress() == false );
76 public void testDRSubClassConstructor() {
78 DR_Sub t = new DR_Sub( d, un, up, f, du, lu, u100 );
80 assertTrue( d.equals( t.getDcaeLocationName() ));
81 assertTrue( un.equals( t.getUsername() ));
82 assertTrue( up.equals( t.getUserpwd() ));
83 assertTrue( f.equals( t.getFeedId() ));
84 assertTrue( du.equals( t.getDeliveryURL() ) );
85 assertTrue( lu.equals( t.getLogURL() ) );
86 assertTrue( t.isUse100() );
87 assertTrue( ! t.isSuspended() );
91 public void testDRSubClassSetters() {
93 DR_Sub t = new DR_Sub();
95 t.setDcaeLocationName( d );
96 assertTrue( d.equals( t.getDcaeLocationName() ));
98 assertTrue( un.equals( t.getUsername() ));
100 assertTrue( up.equals( t.getUserpwd() ));
102 assertTrue( f.equals( t.getFeedId() ));
104 assertTrue( s.equals( t.getSubId() ));
105 t.setDeliveryURL( du );
106 assertTrue( du.equals( t.getDeliveryURL() ) );
108 assertTrue( lu.equals( t.getLogURL() ) );
110 t.setGuaranteedDelivery( v );
111 assertTrue( t.isGuaranteedDelivery() == v );
112 t.setGuaranteedSequence(v);
113 assertTrue( t.isGuaranteedSequence() == v );
114 t.setPrivilegedSubscriber(v);
115 assertTrue( t.isPrivilegedSubscriber() == v );
117 assertTrue( t.isDecompress() == v );
121 public void testJSONfromONAP() {
124 DR_Sub s = new DR_Sub( d, un, up, f, du, lu, u100 );
125 String j = s.toProvJSON();
127 DR_Sub t = new DR_Sub( j );
129 assertTrue( un.equals( t.getUsername() ));
130 assertTrue( up.equals( t.getUserpwd() ));
131 //assertTrue( f.equals( t.getFeedId() ));
132 assertTrue( du.equals( t.getDeliveryURL() ) );
133 //assertTrue( lu.equals( t.getLogURL() ) );
134 assertTrue( ! t.isSuspended() );
139 public void testJSONfromATT() {
142 DR_Sub s = new DR_Sub( d, un, up, f, du, lu, u100 );
144 DR_Sub t = new DR_Sub( s.toProvJSONforATT() );
146 assertTrue( un.equals( t.getUsername() ));
147 assertTrue( up.equals( t.getUserpwd() ));
148 //assertTrue( f.equals( t.getFeedId() ));
149 assertTrue( du.equals( t.getDeliveryURL() ) );
150 // assertTrue( lu.equals( t.getLogURL() ) );
151 assertTrue( ! t.isSuspended() );