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 ******************************************************************************/
23 package org.onap.aaf.auth.rserv.test;
25 import static org.junit.Assert.*;
27 import static org.mockito.Mockito.mock;
28 import static org.mockito.Mockito.when;
29 import static org.mockito.Matchers.anyString;
31 import java.io.IOException;
33 import javax.servlet.ServletException;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 import org.mockito.Mock;
39 //import org.onap.aaf.auth.rserv.Acceptor;
40 import org.onap.aaf.auth.rserv.HttpCode;
41 import org.onap.aaf.auth.rserv.HttpMethods;
42 import org.onap.aaf.auth.rserv.RouteReport;
43 import org.onap.aaf.auth.rserv.TypedCode;
44 import org.onap.aaf.misc.env.TimeTaken;
45 import org.onap.aaf.misc.env.Trans;
46 import org.powermock.modules.junit4.PowerMockRunner;
48 @RunWith(PowerMockRunner.class)
49 public class JU_TypedCode {
52 RouteReport routeReportMock;
56 typedCode = new TypedCode();
60 public void testFirst(){
61 String returnVal = typedCode.first();
62 assertNull(returnVal);
66 public void testAdd() {
67 HttpCode<?, ?> code = mock(HttpCode.class);
68 typedCode.add(code , "test", "test1", "test2");
72 public void testPrep() throws IOException, ServletException, ClassNotFoundException {
73 Trans trans = mock(Trans.class);
74 TimeTaken time = new TimeTaken("yell", 2) {
76 public void output(StringBuilder sb) {
77 // TODO Auto-generated method stub
80 when(trans.start(";na=me;,prop", 8)).thenReturn(time);
81 HttpCode<?, ?> code = mock(HttpCode.class);
82 code.pathParam(null, null);
83 code.isAuthorized(null); //Testing httpcode, currently not working
87 typedCode.add(code , "");
88 typedCode.prep(null , "q");
90 typedCode.add(code , "t");
91 typedCode.prep(trans , null);
93 typedCode.add(code , "t");
94 typedCode.prep(trans , "");
96 typedCode.add(code, "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*");
97 //typedCode.prep(trans , "POST /authn/validate application/CredRequest+json;charset=utf-8;version=2.0,application/json;version=2.0,*/*");
101 public void testRelatedTo() {
102 HttpCode<?, ?> code = mock(HttpCode.class);
103 StringBuilder sb = new StringBuilder();
104 typedCode.relatedTo(code, sb);