Add optional API for PM Mapper
[dmaap/datarouter.git] / datarouter-prov / src / test / java / org / onap / dmaap / datarouter / provisioning / beans / SubscriptionTest.java
1 /*******************************************************************************
2  * ============LICENSE_START==================================================
3  * * org.onap.dmaap
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  * *
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * *
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====================================================
19  * *
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  * *
22  ******************************************************************************/
23
24 package org.onap.dmaap.datarouter.provisioning.beans;
25
26 import org.junit.Assert;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
30 import org.powermock.modules.junit4.PowerMockRunner;
31
32
33 @RunWith(PowerMockRunner.class)
34 @SuppressStaticInitializationFor({"org.onap.dmaap.datarouter.provisioning.beans.Subscription"})
35 public class SubscriptionTest {
36
37     private Subscription subscription;
38
39     @Test
40     public void validate_Subscription_Created_With_Default_Constructor() {
41         subscription = new Subscription();
42         Assert.assertEquals(subscription.getSubid(), -1);
43         Assert.assertEquals(subscription.getGroupid(), -1);
44         Assert.assertEquals(subscription.getSubscriber(), "");
45     }
46
47     @Test
48     public void validate_Getters_And_Setters() {
49         String url = "1.2.3.4";
50         String user = "myUser";
51         String password = "myPass";
52         String subscriber = "mySubscriber";
53         SubDelivery subDelivery = new SubDelivery(url, user, password, false);
54         SubLinks subLinks = new SubLinks();
55         subLinks.setFeed("feed");
56         subLinks.setLog("log");
57         subLinks.setSelf("self");
58
59         subscription = new Subscription();
60         subscription.setGroupid(2);
61         subscription.setDelivery(subDelivery);
62         subscription.setMetadataOnly(false);
63         subscription.setSubscriber(subscriber);
64         subscription.setSuspended(false);
65         subscription.setPrivilegedSubscriber(false);
66         subscription.setLinks(subLinks);
67
68         Assert.assertEquals(2, subscription.getGroupid());
69         Assert.assertEquals(subDelivery, subscription.getDelivery());
70         Assert.assertEquals(subLinks, subscription.getLinks());
71         Assert.assertFalse(subscription.isMetadataOnly());
72         Assert.assertFalse(subscription.isSuspended());
73         Assert.assertFalse(subscription.isPrivilegedSubscriber());
74     }
75 }