38113b80789fa498f2e8d86356e471efdce90b61
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / client / orchestration / SDNOHealthCheckResourcesTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 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
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  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.client.orchestration;
22
23 import static org.junit.Assert.assertTrue;
24 import static org.mockito.Matchers.isA;
25 import static org.mockito.Mockito.doReturn;
26
27 import java.util.UUID;
28
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.mockito.InjectMocks;
33 import org.mockito.Mock;
34 import org.mockito.runners.MockitoJUnitRunner;
35 import org.onap.so.bpmn.common.data.TestDataSetup;
36 import org.onap.so.bpmn.common.InjectionHelper;
37 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
38 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
39 import org.onap.so.client.sdno.SDNOValidator;
40
41 @RunWith(MockitoJUnitRunner.class)
42 public class SDNOHealthCheckResourcesTest  extends TestDataSetup{
43         @InjectMocks
44         private SDNOHealthCheckResources sdnoHealthCheckResources = new SDNOHealthCheckResources();
45         
46         private GenericVnf genericVnf;
47         private RequestContext requestContext;
48         
49         @Mock
50         protected SDNOValidator MOCK_sdnoValidator;
51         
52         @Mock
53         protected InjectionHelper MOCK_injectionHelper;
54         
55         @Before
56         public void before() {
57                 genericVnf = buildGenericVnf(); 
58                 requestContext = buildRequestContext();
59                 doReturn(MOCK_sdnoValidator).when(MOCK_injectionHelper).getSdnoValidator();
60         }
61         
62         @Test
63         public void healthCheckTest() throws Exception {
64                 doReturn(true).when(MOCK_sdnoValidator).healthDiagnostic(isA(String.class), isA(UUID.class), isA(String.class));
65                 assertTrue(sdnoHealthCheckResources.healthCheck(genericVnf, requestContext));
66         }       
67 }