74f0d605960be14c67f092178eda7409211fd822
[so.git] / asdc-controller / src / test / java / org / onap / so / asdc / BaseTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 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
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.asdc;
22
23 import static org.mockito.Mockito.reset;
24
25 import org.junit.After;
26 import org.junit.runner.RunWith;
27 import org.onap.so.asdc.installer.ToscaResourceStructure;
28 import org.onap.so.asdc.installer.VfResourceStructure;
29 import org.onap.so.asdc.installer.heat.ToscaResourceInstaller;
30 import org.onap.so.asdc.tenantIsolation.WatchdogDistribution;
31 import org.onap.so.spring.SpringContextHelper;
32 import org.springframework.beans.factory.annotation.Value;
33 import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
34 import org.springframework.boot.test.context.SpringBootTest;
35 import org.springframework.boot.test.mock.mockito.MockBean;
36 import org.springframework.boot.test.mock.mockito.SpyBean;
37 import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
38 import org.springframework.test.context.ActiveProfiles;
39 import org.springframework.test.context.ContextConfiguration;
40 import org.springframework.test.context.junit4.SpringRunner;
41
42 @RunWith(SpringRunner.class)
43 @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
44 @ActiveProfiles("test")
45 @ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigFileApplicationContextInitializer.class)
46 @AutoConfigureWireMock(port = 0)
47 public abstract class BaseTest {
48         @MockBean
49         protected VfResourceStructure vfResourceStructure;
50         @MockBean
51         protected ToscaResourceStructure toscaResourceStruct;
52         @SpyBean
53         protected WatchdogDistribution watchdogDistributionSpy;
54         @SpyBean
55         protected ToscaResourceInstaller toscaInstaller;
56         
57         @Value("${wiremock.server.port}")
58     protected String wireMockPort;
59
60         @After
61         public void after() {
62                 reset(vfResourceStructure);
63                 reset(toscaResourceStruct);
64         }
65 }