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.
16 package org.onap.usecaseui.server.service.impl;
18 import org.junit.Test;
19 import org.junit.Before;
20 import org.junit.After;
21 import org.junit.runner.RunWith;
22 import org.onap.usecaseui.server.UsecaseuiServerApplication;
23 import org.onap.usecaseui.server.bean.PerformanceInformation;
24 import org.onap.usecaseui.server.service.PerformanceInformationService;
25 import org.onap.usecaseui.server.util.DateUtils;
26 import org.springframework.boot.test.context.SpringBootTest;
27 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
28 import org.springframework.test.context.web.WebAppConfiguration;
30 import javax.annotation.Resource;
31 import java.util.Date;
34 * PerformanceInformationServiceImpl Tester.
36 * @author <Authors name>
37 * @since <pre> 8, 2018</pre>
40 @RunWith(SpringJUnit4ClassRunner.class)
41 @SpringBootTest(classes = UsecaseuiServerApplication.class)
43 public class PerformanceInformationServiceImplTest {
44 @Resource(name = "PerformanceInformationService")
45 PerformanceInformationService performanceInformationService;
47 public void before() throws Exception {
51 public void after() throws Exception {
56 * Method: savePerformanceInformation(PerformanceInformation performanceInformation)
60 public void testSavePerformanceInformation() throws Exception {
61 //TODO: Test goes here...
63 PerformanceInformation a = new PerformanceInformation();
66 a.setName("SGS.UeUnreachable");
68 a.setCreateTime(DateUtils.now());
69 a.setUpdateTime(DateUtils.now());
70 System.out.println(performanceInformationService.savePerformanceInformation(a));
76 * Method: updatePerformanceInformation(PerformanceInformation performanceInformation)
80 public void testUpdatePerformanceInformation() throws Exception {
81 //TODO: Test goes here...
83 PerformanceInformation a = new PerformanceInformation();
87 a.setUpdateTime(DateUtils.now());
88 a.setCreateTime(DateUtils.now());
89 System.out.println(performanceInformationService.updatePerformanceInformation(a));
94 * Method: getAllCount(PerformanceInformation performanceInformation, int currentPage, int pageSize)
98 public void testGetAllCount() throws Exception {
99 //TODO: Test goes here...
101 PerformanceInformation performanceInformation = new PerformanceInformation();
102 performanceInformation.setName("vnf_a_3");
105 performanceInformationService.getAllCount(performanceInformation,0,12);
111 * Method: queryPerformanceInformation(PerformanceInformation performanceInformation, int currentPage, int pageSize)
115 public void testQueryPerformanceInformation() throws Exception {
116 //TODO: Test goes here...
117 PerformanceInformation a = new PerformanceInformation();
118 // a.setEventId("2202");
119 performanceInformationService.queryPerformanceInformation(a, 1, 100)
120 .getList().forEach(al -> System.out.println(al.getValue()));
125 * Method: queryId(String[] id)
129 public void testQueryId() throws Exception {
130 //TODO: Test goes here...
131 performanceInformationService.queryId(new String[]{"2202"})
132 .forEach(ai -> System.out.println(ai.getCreateTime()));
137 * Method: queryDateBetween(String eventId, Date startDate, Date endDate)
141 public void testQueryDateBetweenForEventIdStartDateEndDate() throws Exception {
142 //TODO: Test goes here...
143 performanceInformationService.queryDateBetween("1101ZTHX1MMEGJM1W1",new Date("2017-11-15 06:30:00"),new Date("2017-11-15 14:45:10"));
148 * Method: queryDateBetween(String resourceId, String name, String startTime, String endTime)
152 public void testQueryDateBetweenForResourceIdNameStartTimeEndTime() throws Exception {
153 //TODO: Test goes here...
154 performanceInformationService.queryDateBetween("1101ZTHX1MMEGJM1W1",new Date("2017-11-15 06:30:00"),new Date("2017-11-15 14:45:10"));
160 * Method: queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime)
164 public void testQueryMaxValueByBetweenDate() throws Exception {
165 //TODO: Test goes here...
166 performanceInformationService.queryDateBetween("2202", DateUtils.stringToDate("2017-10-15 01:00:00"), DateUtils.stringToDate("2017-10-15 02:00:00")).forEach(p -> System.out.println(p));