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====================================================
23 package org.onap.aaf.auth.batch.helpers.test;
25 import static org.junit.Assert.*;
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.mockito.Mock;
30 import org.mockito.Mockito;
31 import org.onap.aaf.auth.batch.helpers.Cred;
32 import org.onap.aaf.auth.batch.helpers.Cred.CredCount;
33 import org.onap.aaf.auth.batch.helpers.Cred.Instance;
34 import org.onap.aaf.auth.common.Define;
35 import org.onap.aaf.cadi.CadiException;
36 import org.onap.aaf.cadi.PropAccess;
37 import org.onap.aaf.cadi.config.Config;
38 import org.onap.aaf.misc.env.Trans;
40 import com.datastax.driver.core.Session;
42 import junit.framework.Assert;
44 import static org.mockito.Mockito.*;
46 import java.io.ByteArrayOutputStream;
47 import java.io.PrintStream;
48 import java.util.Date;
50 import org.junit.Test;
52 public class JU_Cred {
54 private ByteArrayOutputStream outStream;
55 private ByteArrayOutputStream errStream;
61 Define define = new Define();
67 public void setUp() throws CadiException {
68 outStream = new ByteArrayOutputStream();
69 errStream = new ByteArrayOutputStream();
70 System.setOut(new PrintStream(outStream));
71 System.setErr(new PrintStream(errStream));
73 integer = new Integer(20);
74 trans = mock(Trans.class);
75 session = mock(Session.class);
76 cc = new CredCount(3);
77 prop = new PropAccess();
78 prop.setProperty(Config.AAF_ROOT_NS, "org.onap.aaf");
79 prop.setProperty(Config.AAF_ROOT_COMPANY,"test");
82 instance = new Instance(12, date, integer, 125642678910L,"234");
83 cred = new Cred("myid1234@aaf.att.com");
87 public void testLast() { //TODO: set instances
88 Assert.assertNull(cred.last(null));
92 public void testTypes() { //TODO: set instances
93 Assert.assertNotNull(cred.types());
97 public void testCount() { //TODO: set instances
98 Assert.assertNotNull(cred.count(3));
102 public void testToString() { //TODO: set instances
103 Assert.assertEquals("myid1234@aaf.att.com[]", cred.toString());
107 public void testHashCode() { //TODO: set instances
108 Assert.assertEquals(-1619358251, cred.hashCode());
112 public void testEquals() { //TODO: set instances
113 Assert.assertEquals(true, cred.equals("myid1234@aaf.att.com"));
117 public void testInc() {
118 Date begin = new Date(date.getTime() - 10);
119 Date after = new Date(date.getTime() + 10);
120 cc.inc(-1, begin, after);
121 cc.inc(1, begin, after);
122 cc.inc(2, begin, after);
123 cc.inc(200, begin, after);
127 public void testAuthCount() { //TODO: set instances
128 Assert.assertEquals(0, cc.authCount(1));
132 public void testX509Count() { //TODO: set instances
133 Assert.assertEquals(0, cc.x509Count(0));
137 public void cleanUp() {
138 System.setErr(System.err);
139 System.setOut(System.out);