Add unit test cases
[dmaap/messagerouter/messageservice.git] / src / test / java / com / att / nsa / dmaap / filemonitor / ServicePropertiesMapTest.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP Policy Engine\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 package com.att.nsa.dmaap.filemonitor;\r
22 \r
23 import static org.junit.Assert.*;\r
24 \r
25 import java.io.File;\r
26 import java.io.FileNotFoundException;\r
27 import java.nio.file.Path;\r
28 import java.nio.file.Paths;\r
29 import java.util.HashMap;\r
30 \r
31 import org.junit.After;\r
32 import org.junit.Before;\r
33 import org.junit.Test;\r
34 import org.junit.runner.RunWith;\r
35 import org.mockito.InjectMocks;\r
36 import org.mockito.Mock;\r
37 import org.powermock.api.mockito.PowerMockito;\r
38 import org.powermock.modules.junit4.PowerMockRunner;\r
39 \r
40 import com.fasterxml.jackson.core.type.TypeReference;\r
41 import com.fasterxml.jackson.databind.ObjectMapper;\r
42 \r
43 @RunWith(PowerMockRunner.class)\r
44 public class ServicePropertiesMapTest {\r
45 \r
46         @InjectMocks\r
47         ServicePropertiesMap map;\r
48 \r
49 \r
50         @Before\r
51         public void setUp() throws Exception {\r
52         }\r
53 \r
54         @After\r
55         public void tearDown() throws Exception {\r
56         }\r
57 \r
58         @Test\r
59         public void testRefresh() {\r
60 \r
61                 try {\r
62                         map.refresh(new File(":/file"));\r
63                 } catch (Exception e) {\r
64                         e.printStackTrace();\r
65                 }\r
66 \r
67                 assertTrue(true);\r
68 \r
69         }\r
70 \r
71         @Test()\r
72         public void testRefreshJsonFile() throws Exception {\r
73                 Path resourceDirectory = Paths.get("src/test/resources");\r
74                         map.refresh(new File(resourceDirectory+"\\"+"test.json"));\r
75                         assertTrue(true);\r
76         }\r
77         \r
78         @Test\r
79         public void testRefreshPropsFile() throws Exception {\r
80                 Path resourceDirectory = Paths.get("src/test/resources");\r
81                         map.refresh(new File(resourceDirectory+"\\"+"test.properties"));\r
82                         assertTrue(true);\r
83         }\r
84 \r
85         @Test\r
86         public void testGetProperty() {\r
87 \r
88                 try {\r
89                         map.getProperty("filename", "propertykey");\r
90                 } catch (Exception e) {\r
91                         e.printStackTrace();\r
92                 }\r
93 \r
94                 assertTrue(true);\r
95         }\r
96 \r
97         @Test\r
98         public void testGetProperties() {\r
99 \r
100                 try {\r
101                         map.getProperties("filename");\r
102                 } catch (Exception e) {\r
103                         e.printStackTrace();\r
104                 }\r
105 \r
106                 assertTrue(true);\r
107 \r
108         }\r
109 \r
110         @Test\r
111         public void testIfNullThenEmpty() {\r
112 \r
113                 try {\r
114                         map.getProperties("filename");\r
115                 } catch (Exception e) {\r
116                         e.printStackTrace();\r
117                 }\r
118 \r
119                 assertTrue(true);\r
120 \r
121         }\r
122 \r
123 }