1 /*******************************************************************************
2 * ============LICENSE_START====================================================
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
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====================================================
21 ******************************************************************************/
22 package org.onap.aaf.auth.rserv.test;
24 import static org.junit.Assert.*;
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.when;
28 import static org.mockito.Matchers.anyString;
30 import java.io.IOException;
32 import javax.servlet.ServletException;
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;
47 @RunWith(PowerMockRunner.class)
48 public class JU_TypedCode {
51 RouteReport routeReportMock;
55 typedCode = new TypedCode();
59 public void testFirst(){
60 String returnVal = typedCode.first();
61 assertNull(returnVal);
65 public void testAdd() {
66 HttpCode<?, ?> code = mock(HttpCode.class);
67 typedCode.add(code , "test", "test1", "test2");
71 public void testPrep() throws IOException, ServletException, ClassNotFoundException {
72 Trans trans = mock(Trans.class);
73 TimeTaken time = new TimeTaken("yell", 2) {
75 public void output(StringBuilder sb) {
76 // TODO Auto-generated method stub
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
86 typedCode.add(code , "");
87 typedCode.prep(null , "q");
89 typedCode.add(code , "t");
90 typedCode.prep(trans , null);
92 typedCode.add(code , "t");
93 typedCode.prep(trans , "");
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,*/*");
100 public void testRelatedTo() {
101 HttpCode<?, ?> code = mock(HttpCode.class);
102 StringBuilder sb = new StringBuilder();
103 typedCode.relatedTo(code, sb);