1a7293d35331976351ca98015823c33fde021d13
[aaf/authz.git] / cadi / core / src / test / java / org / onap / aaf / cadi / lur / test / JU_NullLur.java
1 /*******************************************************************************
2  * ============LICENSE_START====================================================
3  * * org.onap.aaf
4  * * ===========================================================================
5  * * Copyright © 2017 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,Z
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.cadi.lur.test;
23
24 import java.security.Principal;
25 import java.util.List;
26
27 import static org.hamcrest.CoreMatchers.*;
28 import static org.junit.Assert.*;
29 import org.junit.*;
30 import org.mockito.Mock;
31 import org.mockito.MockitoAnnotations;
32 import java.lang.reflect.*;
33
34 import org.onap.aaf.cadi.Permission;
35 import org.onap.aaf.cadi.lur.NullLur;
36
37 public class JU_NullLur {
38
39         @Mock
40         Principal p;
41
42         @Mock
43         Permission perm;
44
45         @Mock
46         List<Permission> perms;
47
48         private NullLur nullLur;
49
50         @Before
51         public void setup() {
52                 MockitoAnnotations.initMocks(this);
53
54                 nullLur = new NullLur();
55         }
56
57         @Test
58         public void coverageTests() throws Exception {
59
60                 Field nullClass = NullLur.class.getDeclaredField("NULL");
61                 nullClass.setAccessible(true);
62                 assertThat(((Permission) nullClass.get(NullLur.class)).permType(), is(""));
63                 assertThat(((Permission) nullClass.get(NullLur.class)).getKey(), is(""));
64                 assertFalse(((Permission) nullClass.get(NullLur.class)).match(perm));
65
66                 nullLur.fishAll(p, perms);
67                 nullLur.destroy();
68
69                 assertFalse(nullLur.fish(p, perm));
70                 assertFalse(nullLur.handlesExclusively(perm));
71                 assertFalse(nullLur.handles(p));
72                 assertThat(nullLur.createPerm(""), is(nullClass.get(NullLur.class)));
73
74                 StringBuilder sb = new StringBuilder();
75                 nullLur.clear(p, sb);
76                 assertThat(sb.toString(), is("NullLur\n"));
77                 assertThat(nullLur.toString(), is("NullLur\n"));
78         }
79
80 }