2 * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.usecaseui.server.service.impl;
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;
31 import javax.annotation.Resource;
32 import java.text.SimpleDateFormat;
33 import java.util.Date;
35 import static org.mockito.Mockito.mock;
38 * PerformanceInformationServiceImpl Tester.
40 * @author <Authors name>
41 * @since <pre> 8, 2018</pre>
44 @RunWith(SpringJUnit4ClassRunner.class)
45 @SpringBootTest(classes = UsecaseuiServerApplication.class)
47 public class PerformanceInformationServiceImplTest {
48 /*@Resource(name = "PerformanceInformationService")
49 PerformanceInformationService performanceInformationService;*/
50 PerformanceInformationServiceImpl service;
52 public void before() throws Exception {
53 service = mock(PerformanceInformationServiceImpl.class);
57 public void after() throws Exception {
62 * Method: savePerformanceInformation(PerformanceInformation performanceInformation)
66 public void testSavePerformanceInformation() throws Exception {
67 //TODO: Test goes here...
69 PerformanceInformation a = new PerformanceInformation();
72 a.setName("SGS.UeUnreachable");
74 a.setCreateTime(DateUtils.now());
75 a.setUpdateTime(DateUtils.now());
76 service.savePerformanceInformation(a);
82 * Method: updatePerformanceInformation(PerformanceInformation performanceInformation)
86 public void testUpdatePerformanceInformation() throws Exception {
87 //TODO: Test goes here...
89 PerformanceInformation a = new PerformanceInformation();
93 a.setUpdateTime(DateUtils.now());
94 a.setCreateTime(DateUtils.now());
95 service.updatePerformanceInformation(a);
100 * Method: getAllCount(PerformanceInformation performanceInformation, int currentPage, int pageSize)
104 public void testGetAllCount() throws Exception {
105 //TODO: Test goes here...
107 PerformanceInformation performanceInformation = new PerformanceInformation();
108 performanceInformation.setName("vnf_a_3");
111 service.getAllCount(performanceInformation,0,12);
117 * Method: queryPerformanceInformation(PerformanceInformation performanceInformation, int currentPage, int pageSize)
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()));
131 * Method: queryId(String[] id)
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()));
143 * Method: queryDateBetween(String eventId, Date startDate, Date endDate)
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);
159 * Method: queryDateBetween(String resourceId, String name, String startTime, String endTime)
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);
176 * Method: queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime)
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));