AT&T 2.0.19 Code drop, stage 3
[aaf/authz.git] / auth / auth-core / src / test / java / org / onap / aaf / auth / rserv / test / JU_TypedCode.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,
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.rserv.test;
23
24 import static org.junit.Assert.*;
25
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.when;
28 import static org.mockito.Matchers.anyString;
29
30 import java.io.IOException;
31
32 import javax.servlet.ServletException;
33
34 import org.junit.Before;
35 import org.junit.Test;
36 import org.junit.runner.RunWith;
37 import org.mockito.Mock;
38 //import org.onap.aaf.auth.rserv.Acceptor;
39 import org.onap.aaf.auth.rserv.HttpCode;
40 import org.onap.aaf.auth.rserv.HttpMethods;
41 import org.onap.aaf.auth.rserv.RouteReport;
42 import org.onap.aaf.auth.rserv.TypedCode;
43 import org.onap.aaf.misc.env.TimeTaken;
44 import org.onap.aaf.misc.env.Trans;
45 import org.powermock.modules.junit4.PowerMockRunner;
46
47 @RunWith(PowerMockRunner.class)
48 public class JU_TypedCode {
49         TypedCode typedCode;
50         @Mock
51         RouteReport routeReportMock;
52         
53         @Before
54         public void setUp(){
55                 typedCode = new TypedCode();
56         }
57         
58         @Test
59         public void testFirst(){
60                 String returnVal = typedCode.first();
61                 assertNull(returnVal);
62         }
63         
64         @Test
65         public void testAdd() {
66                 HttpCode<?, ?> code = mock(HttpCode.class);
67                 typedCode.add(code , "test", "test1", "test2");
68         }
69         
70         @Test
71         public void testPrep() throws IOException, ServletException, ClassNotFoundException {
72                 Trans trans = mock(Trans.class);
73                 TimeTaken time = new TimeTaken("yell", 2) {
74                         @Override
75                         public void output(StringBuilder sb) {
76                                 // TODO Auto-generated method stub      
77                         }
78                 };
79                 when(trans.start(";na=me;,prop", 8)).thenReturn(time);
80                 HttpCode<?, ?> code = mock(HttpCode.class);
81                 code.pathParam(null, null);
82                 code.isAuthorized(null); //Testing httpcode, currently not working
83                 code.no_cache();
84                 code.toString();
85                 
86                 typedCode.add(code , "");
87                 typedCode.prep(null , "q");
88                 
89                 typedCode.add(code , "t");
90                 typedCode.prep(trans , null);
91                 
92                 typedCode.add(code , "t");
93                 typedCode.prep(trans , "");
94                 
95                 typedCode.add(code, "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*");
96                 //typedCode.prep(trans , "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*");               
97         }
98         
99         @Test
100         public void testRelatedTo() {
101                 HttpCode<?, ?> code = mock(HttpCode.class);
102                 StringBuilder sb = new StringBuilder();
103                 typedCode.relatedTo(code, sb);
104         }
105
106 }