Remove Tabs, per Jococo
[aaf/authz.git] / auth / auth-cass / src / test / java / org / onap / aaf / auth / dao / cass / JU_Namespace.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
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
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  */
21
22 package org.onap.aaf.auth.dao.cass;
23
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
26 import static org.mockito.MockitoAnnotations.initMocks;
27
28 import java.io.IOException;
29 import java.nio.ByteBuffer;
30 import java.util.ArrayList;
31 import java.util.HashMap;
32 import java.util.List;
33
34 import org.junit.Before;
35 import org.junit.Test;
36 import org.onap.aaf.misc.env.APIException;
37
38 public class JU_Namespace {
39
40     Namespace namespace;
41     
42     @Before
43     public void setUp() throws APIException, IOException {
44         initMocks(this);
45     }
46
47     @Test
48     public void testInit() {
49         new Namespace();
50         NsDAO.Data data = new NsDAO.Data();
51         data.name = "name";
52         namespace = new Namespace(data);
53         assertTrue(namespace.name.equals("name"));
54         data.attrib = new HashMap<>();
55         namespace = new Namespace(data);
56         data.attrib.put("test", "test");
57         namespace = new Namespace(data);
58     }
59     
60     
61     
62     @Test
63     public void testSecondConstructor() {
64
65         NsDAO.Data data = new NsDAO.Data();
66         data.name = "name";
67         List<String> owner = new ArrayList<>();
68         List<String> admin = new ArrayList<>();;
69         namespace = new Namespace(data,owner, admin);
70         assertTrue(namespace.name.equals("name"));
71         data.attrib = new HashMap<>();
72         namespace = new Namespace(data,owner, admin);
73         data.attrib.put("test", "test");
74         namespace = new Namespace(data ,owner, admin);
75         
76         NsDAO.Data retData = namespace.data();
77         assertTrue(retData.name.equals("name"));
78     
79     }
80     @Test
81     public void testBytify() {
82         testSecondConstructor();
83         try {
84             ByteBuffer retVal = namespace.bytify();
85             namespace.reconstitute(retVal);
86             namespace.hashCode();
87             namespace.toString();
88         } catch (IOException e) {
89             // TODO Auto-generated catch block
90             e.printStackTrace();
91         }
92     }
93     @Test
94     public void testEquals() {
95         testSecondConstructor();
96         NsDAO.Data data = new NsDAO.Data();
97         data.name = "name";
98         Namespace nameObj = null;
99         assertFalse(namespace.equals(nameObj));
100         assertFalse(namespace.equals(data));
101         nameObj = new Namespace(data);
102         assertTrue(namespace.equals(nameObj));
103     }
104     
105 }