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.dao.cass.ApprovalDAO;
31 import org.onap.aaf.auth.env.AuthzTrans;
32 import org.onap.aaf.auth.helpers.Approval;
34 import junit.framework.Assert;
36 import static org.mockito.Mockito.*;
38 import java.util.Date;
39 import java.util.List;
40 import java.util.UUID;
42 import org.junit.Test;
44 public class JU_Approval {
54 ticket = new UUID(0, 0);
57 approval = new Approval(id, ticket, "approver", date,
58 "user", "memo", "operation", "status", "type", 100l);
62 public void testRoleFromMemo() {
63 Assert.assertNull(approval.roleFromMemo(null));
64 Assert.assertEquals(".admin", approval.roleFromMemo("Re-Validate as Administrator for AAF Namespace '\'test\'test"));
65 Assert.assertEquals(".owner", approval.roleFromMemo("Re-Validate Ownership for AAF Namespace '\'test\'test"));
66 Assert.assertEquals("", approval.roleFromMemo("Re-Approval in Role '\'test\'test"));
70 public void testExpunge() {
75 public void testGetLast_notified() {
76 Assert.assertTrue(approval.getLast_notified()instanceof Date);
80 public void testSetLastNotified() {
81 approval.setLastNotified(date);
85 public void testGetStatus() {
86 Assert.assertEquals("status", approval.getStatus());
90 public void testSetStatus() {
91 approval.setStatus("status");
95 public void testGetId() {
96 Assert.assertTrue(approval.getId() instanceof UUID);
100 public void testGetTicket() {
101 Assert.assertTrue(approval.getTicket() instanceof UUID);
105 public void testGetMemo() {
106 Assert.assertEquals("memo", approval.getMemo());
110 public void testGetOperation() {
111 Assert.assertEquals("operation", approval.getOperation());
115 public void testGetType() {
116 Assert.assertEquals("type", approval.getType());
120 public void testLapsed() {
125 public void testGetRole() {
126 Assert.assertNull(approval.getRole());
130 public void testToString() {
131 Assert.assertEquals("user memo", approval.toString());
135 public void testResetLocalData() {
136 approval.resetLocalData();
140 public void testSizeForDeletion() {
141 Assert.assertEquals(0, approval.sizeForDeletion());
145 public void testPendingDelete() {
146 Assert.assertFalse(approval.pendingDelete(approval));
150 public void testDelayDelete() {
151 AuthzTrans trans = mock(AuthzTrans.class);
152 ApprovalDAO dao = mock(ApprovalDAO.class);
153 List<Approval> list = null;
154 approval.delayDelete(trans, dao, true, list, "text");