Test coverage for ParseAdminArtifact
[appc.git] / appc-config / appc-encryption-tool / provider / src / test / java / org / onap / appc / encryptiontool / fqdn / ParseAdminArtifactTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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  *
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.appc.encryptiontool.fqdn;
23
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;
34
35 public class ParseAdminArtifactTest {
36
37     @Rule
38     public ExpectedException expectedEx = ExpectedException.none();
39
40     @Test
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);
51     }
52
53 }