Improve testing stability
[sdc.git] / catalog-fe / src / test / java / org / openecomp / sdc / fe / impl / PluginStatusBLTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 Nokia. 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.openecomp.sdc.fe.impl;
22
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.mockito.Mock;
26 import org.openecomp.sdc.exception.InvalidArgumentException;
27 import org.openecomp.sdc.fe.config.ConfigurationManager;
28
29 import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanConstructor;
30 import static org.hamcrest.CoreMatchers.allOf;
31 import static org.hamcrest.MatcherAssert.assertThat;
32 import static org.mockito.Mockito.when;
33 import static org.mockito.MockitoAnnotations.openMocks;
34
35 public class PluginStatusBLTest {
36
37
38     @Mock
39     private ConfigurationManager mockedConfigurationManager;
40
41     @Before
42     public void setUp() {
43         openMocks(this);
44     }
45
46     @Test
47     public void validateBean() {
48         assertThat(PluginStatusBL.class,  allOf(
49                 hasValidBeanConstructor()
50         ));
51     }
52     @Test(expected = InvalidArgumentException.class)
53     public void validateGetPluginsListWithNoConfigurationWillThrowException() {
54         ConfigurationManager.setTestInstance(mockedConfigurationManager);
55         when(mockedConfigurationManager.getPluginsConfiguration()).thenReturn(null);
56         PluginStatusBL pluginStatusBL = new PluginStatusBL();
57
58         pluginStatusBL.getPluginsList();
59     }
60     @Test(expected = InvalidArgumentException.class)
61     public void validateGetPluginAvailabilityWithNoConfigurationWillThrowException() {
62         ConfigurationManager.setTestInstance(mockedConfigurationManager);
63         when(mockedConfigurationManager.getPluginsConfiguration()).thenReturn(null);
64         PluginStatusBL pluginStatusBL = new PluginStatusBL();
65
66         pluginStatusBL.getPluginAvailability("testPlugin");
67     }
68 }