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.cadi.test.principal;
25 import static org.junit.Assert.*;
26 import static org.hamcrest.CoreMatchers.*;
29 import org.onap.aaf.cadi.principal.TaggedPrincipal;
30 import org.onap.aaf.cadi.principal.TaggedPrincipal.TagLookup;
31 import org.onap.aaf.cadi.CadiException;
32 import org.onap.aaf.cadi.principal.StringTagLookup;
34 public class JU_TaggedPrincipal {
36 private final String name = "stubbedName";
37 private final String tag = "tag";
39 private class TaggedPrincipalStub extends TaggedPrincipal {
40 public TaggedPrincipalStub() { super(); }
41 public TaggedPrincipalStub(final TagLookup tl) { super(tl); }
42 @Override public String getName() { return name; }
43 @Override public String tag() { return null; }
46 private class WhinyTagLookup implements TagLookup {
47 public WhinyTagLookup(final String tag) { }
49 public String lookup() throws CadiException {
50 throw new CadiException();
55 public void personalNameTest() {
56 TaggedPrincipal tp = new TaggedPrincipalStub();
57 assertThat(tp.personalName(), is(name));
59 StringTagLookup stl = new StringTagLookup(tag);
60 tp = new TaggedPrincipalStub(stl);
61 assertThat(tp.personalName(), is(tag));
63 WhinyTagLookup wtl = new WhinyTagLookup(tag);
65 assertThat(tp.personalName(), is(name));