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====================================================
22 package org.onap.aaf.auth.dao.cass;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
26 import static org.mockito.MockitoAnnotations.initMocks;
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;
34 import org.junit.Before;
35 import org.junit.Test;
36 import org.onap.aaf.misc.env.APIException;
38 public class JU_Namespace {
43 public void setUp() throws APIException, IOException {
48 public void testInit() {
50 NsDAO.Data data = new NsDAO.Data();
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);
63 public void testSecondConstructor() {
65 NsDAO.Data data = new NsDAO.Data();
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);
76 NsDAO.Data retData = namespace.data();
77 assertTrue(retData.name.equals("name"));
81 public void testBytify() {
82 testSecondConstructor();
84 ByteBuffer retVal = namespace.bytify();
85 namespace.reconstitute(retVal);
88 } catch (IOException e) {
89 // TODO Auto-generated catch block
94 public void testEquals() {
95 testSecondConstructor();
96 NsDAO.Data data = new NsDAO.Data();
98 Namespace nameObj = null;
99 assertFalse(namespace.equals(nameObj));
100 assertFalse(namespace.equals(data));
101 nameObj = new Namespace(data);
102 assertTrue(namespace.equals(nameObj));