Mass removal of all Tabs (Style Warnings)
[aaf/authz.git] / auth / auth-batch / src / test / java / org / onap / aaf / auth / helpers / test / JU_Approval.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.helpers.test;
23
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;
33
34 import junit.framework.Assert;
35
36 import static org.mockito.Mockito.*;
37
38 import java.util.Date;
39 import java.util.List;
40 import java.util.UUID;
41
42 import org.junit.Test;
43
44 public class JU_Approval {
45     
46     Approval approval;
47     UUID id;
48     UUID ticket;
49     Date date;
50     
51     @Before
52     public void setUp() {
53         id = new UUID(0, 0);
54         ticket = new UUID(0, 0);
55         date = new Date();
56         
57         approval = new Approval(id, ticket, "approver", date, 
58                  "user", "memo", "operation", "status", "type", 100l);
59     }
60
61     @Test
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"));
67     }
68     
69     @Test
70     public void testExpunge() {
71         approval.expunge();
72     }
73     
74     @Test
75     public void testGetLast_notified() {
76         Assert.assertTrue(approval.getLast_notified()instanceof Date);
77     }
78     
79     @Test
80     public void testSetLastNotified() {
81         approval.setLastNotified(date);
82     }
83     
84     @Test
85     public void testGetStatus() {
86         Assert.assertEquals("status", approval.getStatus());
87     }
88     
89     @Test
90     public void testSetStatus() {
91         approval.setStatus("status");
92     }
93     
94     @Test
95     public void testGetId() {
96         Assert.assertTrue(approval.getId() instanceof UUID);
97     }
98     
99     @Test
100     public void testGetTicket() {
101         Assert.assertTrue(approval.getTicket() instanceof UUID);
102     }
103     
104     @Test
105     public void testGetMemo() {
106         Assert.assertEquals("memo", approval.getMemo());
107     }
108     
109     @Test
110     public void testGetOperation() {
111         Assert.assertEquals("operation", approval.getOperation());
112     }
113     
114     @Test
115     public void testGetType() {
116         Assert.assertEquals("type", approval.getType());
117     }
118     
119     @Test
120     public void testLapsed() {
121         approval.lapsed();
122     }
123     
124     @Test
125     public void testGetRole() {
126         Assert.assertNull(approval.getRole());
127     }
128     
129     @Test
130     public void testToString() {
131         Assert.assertEquals("user memo", approval.toString());
132     }
133     
134     @Test
135     public void testResetLocalData() {
136         approval.resetLocalData();
137     }
138     
139     @Test
140     public void testSizeForDeletion() {
141         Assert.assertEquals(0, approval.sizeForDeletion());
142     }
143     
144     @Test
145     public void testPendingDelete() {
146         Assert.assertFalse(approval.pendingDelete(approval));
147     }
148     
149     @Test
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");
155     }
156
157 }