34a944ad909db7fc3c8ba868e7a9aef14a6230b8
[usecase-ui/server.git] /
1 /*
2  * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.usecaseui.server.service.impl;
18
19 import org.junit.Test; 
20 import org.junit.Before; 
21 import org.junit.After;
22 import org.junit.runner.RunWith;
23 import org.onap.usecaseui.server.UsecaseuiServerApplication;
24 import org.onap.usecaseui.server.bean.PerformanceInformation;
25 import org.onap.usecaseui.server.service.PerformanceInformationService;
26 import org.onap.usecaseui.server.util.DateUtils;
27 import org.springframework.boot.test.context.SpringBootTest;
28 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
29 import org.springframework.test.context.web.WebAppConfiguration;
30
31 import javax.annotation.Resource;
32 import java.text.SimpleDateFormat;
33 import java.util.Date;
34
35 import static org.mockito.Mockito.mock;
36
37 /** 
38 * PerformanceInformationServiceImpl Tester. 
39
40 * @author <Authors name> 
41 * @since <pre> 8, 2018</pre>
42 * @version 1.0 
43 */
44 @RunWith(SpringJUnit4ClassRunner.class)
45 @SpringBootTest(classes = UsecaseuiServerApplication.class)
46 @WebAppConfiguration
47 public class PerformanceInformationServiceImplTest {
48     /*@Resource(name = "PerformanceInformationService")
49     PerformanceInformationService performanceInformationService;*/
50     PerformanceInformationServiceImpl service;
51 @Before
52 public void before() throws Exception {
53     service = mock(PerformanceInformationServiceImpl.class);
54
55
56 @After
57 public void after() throws Exception { 
58
59
60 /** 
61
62 * Method: savePerformanceInformation(PerformanceInformation performanceInformation) 
63
64 */ 
65 @Test
66 public void testSavePerformanceInformation() throws Exception { 
67 //TODO: Test goes here...
68
69     PerformanceInformation a = new PerformanceInformation();
70
71     a.setEventId("123");
72     a.setName("SGS.UeUnreachable");
73     a.setValue("40");
74     a.setCreateTime(DateUtils.now());
75     a.setUpdateTime(DateUtils.now());
76     service.savePerformanceInformation(a);
77
78
79
80 /** 
81
82 * Method: updatePerformanceInformation(PerformanceInformation performanceInformation) 
83
84 */ 
85 @Test
86 public void testUpdatePerformanceInformation() throws Exception { 
87 //TODO: Test goes here...
88
89     PerformanceInformation a = new PerformanceInformation();
90     a.setEventId("110");
91     a.setName("efw");
92     a.setValue("fko11");
93     a.setUpdateTime(DateUtils.now());
94     a.setCreateTime(DateUtils.now());
95     service.updatePerformanceInformation(a);
96
97
98 /** 
99
100 * Method: getAllCount(PerformanceInformation performanceInformation, int currentPage, int pageSize) 
101
102 */ 
103 @Test
104 public void testGetAllCount() throws Exception { 
105 //TODO: Test goes here...
106
107     PerformanceInformation performanceInformation = new PerformanceInformation();
108     performanceInformation.setName("vnf_a_3");
109
110
111     service.getAllCount(performanceInformation,0,12);
112
113
114
115 /** 
116
117 * Method: queryPerformanceInformation(PerformanceInformation performanceInformation, int currentPage, int pageSize) 
118
119 */ 
120 @Test
121 public void testQueryPerformanceInformation() throws Exception { 
122 //TODO: Test goes here...
123     PerformanceInformation a = new PerformanceInformation();
124     // a.setEventId("2202");
125     service.queryPerformanceInformation(a, 1, 100);
126            // .getList().forEach(al -> System.out.println(al.getValue()));
127
128
129 /** 
130
131 * Method: queryId(String[] id) 
132
133 */ 
134 @Test
135 public void testQueryId() throws Exception { 
136 //TODO: Test goes here...
137     service.queryId(new String[]{"2202"});
138           //  .forEach(ai -> System.out.println(ai.getCreateTime()));
139
140
141 /** 
142
143 * Method: queryDateBetween(String eventId, Date startDate, Date endDate) 
144
145 */ 
146 @Test
147 public void testQueryDateBetweenForEventIdStartDateEndDate() throws Exception { 
148 //TODO: Test goes here...
149     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
150     String star = "2017-11-15 06:30:00";
151     String end="2017-11-15 14:45:10";
152     Date stard = sdf.parse(star);
153     Date endd = sdf.parse(end);
154     service.queryDateBetween("1101ZTHX1MMEGJM1W1",stard,endd);
155
156
157 /** 
158
159 * Method: queryDateBetween(String resourceId, String name, String startTime, String endTime) 
160
161 */ 
162 @Test
163 public void testQueryDateBetweenForResourceIdNameStartTimeEndTime() throws Exception { 
164 //TODO: Test goes here...
165     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
166     String star = "2017-11-15 06:30:00";
167     String end="2017-11-15 14:45:10";
168     Date stard = sdf.parse(star);
169     Date endd = sdf.parse(end);
170     service.queryDateBetween("1101ZTHX1MMEGJM1W1",stard,endd);
171
172
173
174 /** 
175
176 * Method: queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime) 
177
178 */ 
179 @Test
180 public void testQueryMaxValueByBetweenDate() throws Exception { 
181 //TODO: Test goes here...
182     service.queryDateBetween("2202", DateUtils.stringToDate("2017-10-15 01:00:00"), DateUtils.stringToDate("2017-10-15 02:00:00")).forEach(p -> System.out.println(p));
183
184
185
186
187