c80a1495b7c3f3b01903c80235f1ff30595a4599
[dcaegen2/services.git] /
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  slice-analysis-ms
4  *  ================================================================================
5  *   Copyright (C) 2022 Huawei Canada Limited.
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
22 package org.onap.slice.analysis.ms.service.ccvpn;
23
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.mockito.InjectMocks;
28 import org.mockito.Mockito;
29 import org.mockito.MockitoAnnotations;
30 import org.mockito.Spy;
31 import org.springframework.boot.test.context.SpringBootTest;
32 import org.springframework.test.context.junit4.SpringRunner;
33 import static org.mockito.Mockito.mock;
34
35 @RunWith(SpringRunner.class)
36 @SpringBootTest(classes = BandwidthEvaluatorTest.class)
37 public class BandwidthEvaluatorTest {
38
39     @Spy
40     @InjectMocks
41     BandwidthEvaluator bandwidthEvaluator;
42
43     @Before
44     public void setup(){
45         MockitoAnnotations.initMocks(this);
46     }
47
48     @Test
49     public void initTest(){
50         bandwidthEvaluator.init();
51         Mockito.verify(bandwidthEvaluator, Mockito.atLeastOnce()).init();
52     }
53
54     @Test
55     public void stopTest(){
56         bandwidthEvaluator.init();
57         bandwidthEvaluator.stop();
58         Mockito.verify(bandwidthEvaluator, Mockito.atLeastOnce()).stop();
59     }
60
61     @Test
62     public void postTest() {
63         Event evt = mock(SimpleEvent.class);
64         bandwidthEvaluator.post(evt);
65         Mockito.verify(bandwidthEvaluator, Mockito.atLeastOnce()).post(Mockito.any(Event.class));
66     }
67 }