Add AAF in a Nutshell to docs
[aaf/authz.git] / auth / auth-batch / src / test / java / org / onap / aaf / auth / batch / helpers / test / JU_MiscID.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.batch.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.batch.BatchException;
31 import org.onap.aaf.auth.batch.helpers.MiscID;
32
33 import com.datastax.driver.core.Row;
34
35 import junit.framework.Assert;
36
37 import static org.mockito.Mockito.*;
38 import org.junit.Test;
39
40 public class JU_MiscID {
41     
42     MiscID miscId;
43     
44     @Before
45     public void setUp() {
46         miscId = new MiscID();
47     }
48     
49     @Test
50     public void testRowSet() {
51         Row row = mock(Row.class);
52         miscId.set(row);
53     }
54     
55     @Test
56     public void testStringSet() throws BatchException {
57         String[] strArr = {"id", "sponsor", "created", "renewal"};
58         miscId.set(strArr);
59     }
60     
61     @Test
62     public void testHashcode() throws BatchException {
63         String[] strArr = {"id", "sponsor", "created", "renewal"};
64         miscId.set(strArr);
65         Assert.assertEquals(3355, miscId.hashCode());
66     }
67     
68     @Test
69     public void testEquals() throws BatchException {
70         String[] strArr = {"id", "sponsor", "created", "renewal"};
71         miscId.set(strArr);
72         Assert.assertFalse(miscId.equals("id"));
73         Assert.assertTrue(miscId.equals(miscId));
74     }
75     
76     @Test
77     public void testInsertStmt() throws IllegalArgumentException, IllegalAccessException {
78         String expected = "INSERT INTO authz.miscid (id,created,sponsor,renewal) VALUES ('null','null','null','null')";
79         String result = miscId.insertStmt().toString();
80         Assert.assertEquals(expected, result);
81     }
82     
83     @Test
84     public void testUpdateStmt() throws IllegalArgumentException, IllegalAccessException, BatchException {
85         String expected = "UPDATE authz.miscid SET sponser='sponsor1',created='created1',renewal='renewal1' WHERE id='id'";
86         String[] strArr = {"id", "sponsor", "created", "renewal"};
87         miscId.set(strArr);
88         MiscID miscId1 = new MiscID();
89         String[] strArr1 = {"id", "sponsor1", "created1", "renewal1"};
90         miscId1.set(strArr1);        
91         StringBuilder result = miscId.updateStmt(miscId1);
92
93         Assert.assertEquals(expected, result.toString());
94     }
95
96
97 }