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====================================================
22 package org.onap.aaf.auth.oauth.mapper;
24 import static org.junit.Assert.assertEquals;
25 import static org.mockito.MockitoAnnotations.initMocks;
27 import java.util.HashSet;
29 import javax.servlet.http.HttpServletRequest;
30 import javax.xml.ws.handler.MessageContext.Scope;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.mockito.Mock;
35 import org.onap.aaf.auth.dao.cass.OAuthTokenDAO.Data;
36 import org.onap.aaf.auth.layer.Result;
38 import aafoauth.v2_0.Introspect;
40 public class JU_MapperIntrospect1_0Test {
42 private HttpServletRequest req;
53 public void testIntrospect() {
56 Result<Data> dataResult = Result.create(data, 0, "detail", "var");
58 MapperIntrospect<Introspect> mapper = new MapperIntrospect1_0();
60 Result<Introspect> intro = mapper.introspect(dataResult);
62 assertEquals(intro.value.getClientType(), "confidential");
66 public void testIntrospectWithUnknowType() {
68 data.scopes = new HashSet<String>();
70 data.scopes.add(Scope.APPLICATION.toString());
71 data.scopes.add(Scope.HANDLER.toString());
73 Result<Data> dataResult = Result.create(data, 0, "detail", "var");
75 MapperIntrospect<Introspect> mapper = new MapperIntrospect1_0();
77 Result<Introspect> intro = mapper.introspect(dataResult);
79 assertEquals(intro.value.getClientType(), "unknown");
83 public void testIntrospectWithNotOk() {
86 Result<Data> dataResult = Result.create(data, 1, "detail", "var");
88 MapperIntrospect<Introspect> mapper = new MapperIntrospect1_0();
90 Result<Introspect> intro = mapper.introspect(dataResult);
92 assertEquals(intro.value, null);