Fix unit test with @PrepareForTest annotation
[appc.git] / appc-core / appc-common-bundle / src / test / java / org / onap / appc / cache / impl / MetadataCacheFactoryTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * ================================================================================
9  * Modificiations (C) 2019 Ericsson
10  * =============================================================================
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  * 
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  * 
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  * 
23  * ============LICENSE_END=========================================================
24  */
25
26 package org.onap.appc.cache.impl;
27
28 import org.junit.Assert;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.powermock.core.classloader.annotations.PrepareForTest;
32 import org.powermock.modules.junit4.PowerMockRunner;
33 import org.powermock.reflect.Whitebox;
34
35 @RunWith(PowerMockRunner.class)
36 @PrepareForTest(MetadataCacheImpl.class)
37 public class MetadataCacheFactoryTest {
38     @Test
39     public void testConstructor() throws Exception {
40         Whitebox.invokeConstructor(MetadataCacheFactory.class);
41     }
42
43     @Test
44     public void testGetInstance() throws Exception {
45         Assert.assertTrue("Should not return null", MetadataCacheFactory.getInstance() != null);
46         Assert.assertEquals("Should always return the same object",
47                 MetadataCacheFactory.getInstance(), MetadataCacheFactory.getInstance());
48     }
49 }