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.helpers.test;
24 import static org.junit.Assert.*;
25 import org.junit.After;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.Mock;
29 import org.mockito.Mockito;
30 import org.onap.aaf.auth.actions.URDelete;
31 import org.onap.aaf.auth.dao.cass.UserRoleDAO;
32 import org.onap.aaf.auth.env.AuthzTrans;
33 import org.onap.aaf.auth.helpers.UserRole;
35 import junit.framework.Assert;
37 import static org.mockito.Mockito.*;
39 import java.io.PrintStream;
40 import java.util.Date;
42 import org.junit.Test;
44 public class JU_UserRole {
54 userRole = new UserRole("user", "ns", "rname", date);
55 userRole = new UserRole("user", "role", "ns", "rname", date);
59 public void testTotalLoaded() {
60 Assert.assertEquals(0, userRole.totalLoaded());
64 public void testDeleted() {
65 Assert.assertEquals(0, userRole.deleted());
69 public void testExpunge() {
74 public void testSetDeleteStream() {
75 userRole.setDeleteStream(ds);
79 public void testSetRecoverStream() {
80 userRole.setRecoverStream(ds);
84 public void testUrdd() {
85 Assert.assertTrue(userRole.urdd() instanceof UserRoleDAO.Data);
89 public void testUser() {
90 Assert.assertEquals("user", userRole.user());
94 public void testRole() {
95 Assert.assertEquals("role", userRole.role());
99 public void testNs() {
100 Assert.assertEquals("ns", userRole.ns());
104 public void testRName() {
105 Assert.assertEquals("rname", userRole.rname());
109 public void testExpires() {
110 Assert.assertEquals(date, userRole.expires());
111 userRole.expires(date);
115 public void testToString() {
116 Assert.assertTrue(userRole.toString() instanceof String);
120 public void testGet() {
121 userRole.get("u", "r");
125 public void testResetLocalData() {
126 userRole.resetLocalData();
130 public void testSizeForDeletion() {
131 Assert.assertEquals(0, userRole.sizeForDeletion());
135 public void testPendingDelete() {
136 Assert.assertFalse(userRole.pendingDelete(userRole));
140 public void testActuateDeletionNow() {
141 AuthzTrans trans = mock(AuthzTrans.class);
142 URDelete urd = mock(URDelete.class);
143 userRole.actuateDeletionNow(trans,urd);