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.cadi.client.test;
24 import static org.junit.Assert.*;
25 import static org.hamcrest.CoreMatchers.*;
26 import static org.mockito.Mockito.*;
29 import org.onap.aaf.cadi.CadiException;
30 import org.onap.aaf.cadi.client.AbsTransferSS;
31 import org.onap.aaf.cadi.config.SecurityInfoC;
32 import org.onap.aaf.cadi.principal.TaggedPrincipal;
34 import java.net.HttpURLConnection;
36 public class JU_AbsTransferSS {
38 @Mock TaggedPrincipal princMock;
39 @Mock SecurityInfoC<HttpURLConnection> siMock;
41 private static final String princName = "name";
42 private static final String princTag = "tag";
43 private static final String app = "app";
47 MockitoAnnotations.initMocks(this);
49 when(princMock.getName()).thenReturn(princName);
50 when(princMock.tag()).thenReturn(princTag);
55 TransferSSStub stub = new TransferSSStub(princMock, app);
56 assertThat(stub.getID(), is(princName));
57 assertThat(stub.getValue(), is(princName + ':' + app + ':' + princTag + ':' + "AS"));
59 stub = new TransferSSStub(null, app, siMock);
60 assertThat(stub.getID(), is(""));
61 assertThat(stub.getValue(), is(nullValue()));
64 private class TransferSSStub extends AbsTransferSS<HttpURLConnection> {
65 public TransferSSStub(TaggedPrincipal principal, String app) { super(principal, app); }
66 public TransferSSStub(TaggedPrincipal principal, String app, SecurityInfoC<HttpURLConnection> si) { super(principal, app, si); }
67 @Override public void setSecurity(HttpURLConnection client) throws CadiException { }
68 @Override public int setLastResponse(int respCode) { return 0; }
69 public String getValue() { return value; }