2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Ericsson
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.
19 * ============LICENSE_END=========================================================
22 package org.onap.appc.encryptiontool.fqdn;
24 import static org.hamcrest.CoreMatchers.isA;
25 import org.junit.Rule;
26 import org.junit.Test;
27 import org.junit.rules.ExpectedException;
28 import org.mockito.Mockito;
29 import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
33 import org.powermock.reflect.Whitebox;
35 public class ParseAdminArtifactTest {
38 public ExpectedException expectedEx = ExpectedException.none();
41 public void test() throws SvcLogicException {
42 ParseAdminArtifcat artifact = ParseAdminArtifcat.initialise();
43 SqlResource sqlResource = Mockito.mock(SqlResource.class);
44 Mockito.when(sqlResource.query(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.anyString(),
45 Mockito.anyString(), Mockito.anyString(), Mockito.any(SvcLogicContext.class))).thenReturn(QueryStatus.FAILURE);
46 Whitebox.setInternalState(artifact, "serviceLogic", sqlResource);
47 SvcLogicContext ctx = new SvcLogicContext();
48 expectedEx.expect(RuntimeException.class);
49 expectedEx.expectCause(isA(SvcLogicException.class));
50 artifact.getAdminArtifact(ctx);