e6540fcf39e0e9298719d93108058a45ba7beffc
[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 package org.onap.usecaseui.server.service.impl; 
17
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;
29
30 import javax.annotation.Resource;
31 import java.util.Date;
32
33 /** 
34 * PerformanceInformationServiceImpl Tester. 
35
36 * @author <Authors name> 
37 * @since <pre> 8, 2018</pre>
38 * @version 1.0 
39 */
40 @RunWith(SpringJUnit4ClassRunner.class)
41 @SpringBootTest(classes = UsecaseuiServerApplication.class)
42 @WebAppConfiguration
43 public class PerformanceInformationServiceImplTest {
44     @Resource(name = "PerformanceInformationService")
45     PerformanceInformationService performanceInformationService;
46 @Before
47 public void before() throws Exception { 
48
49
50 @After
51 public void after() throws Exception { 
52
53
54 /** 
55
56 * Method: savePerformanceInformation(PerformanceInformation performanceInformation) 
57
58 */ 
59 @Test
60 public void testSavePerformanceInformation() throws Exception { 
61 //TODO: Test goes here...
62
63     PerformanceInformation a = new PerformanceInformation();
64
65     a.setEventId("123");
66     a.setName("SGS.UeUnreachable");
67     a.setValue("40");
68     a.setCreateTime(DateUtils.now());
69     a.setUpdateTime(DateUtils.now());
70     System.out.println(performanceInformationService.savePerformanceInformation(a));
71
72
73
74 /** 
75
76 * Method: updatePerformanceInformation(PerformanceInformation performanceInformation) 
77
78 */ 
79 @Test
80 public void testUpdatePerformanceInformation() throws Exception { 
81 //TODO: Test goes here...
82
83     PerformanceInformation a = new PerformanceInformation();
84     a.setEventId("110");
85     a.setName("efw");
86     a.setValue("fko11");
87     a.setUpdateTime(DateUtils.now());
88     a.setCreateTime(DateUtils.now());
89     System.out.println(performanceInformationService.updatePerformanceInformation(a));
90
91
92 /** 
93
94 * Method: getAllCount(PerformanceInformation performanceInformation, int currentPage, int pageSize) 
95
96 */ 
97 @Test
98 public void testGetAllCount() throws Exception { 
99 //TODO: Test goes here...
100
101     PerformanceInformation performanceInformation = new PerformanceInformation();
102     performanceInformation.setName("vnf_a_3");
103
104
105     performanceInformationService.getAllCount(performanceInformation,0,12);
106
107
108
109 /** 
110
111 * Method: queryPerformanceInformation(PerformanceInformation performanceInformation, int currentPage, int pageSize) 
112
113 */ 
114 @Test
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()));
121
122
123 /** 
124
125 * Method: queryId(String[] id) 
126
127 */ 
128 @Test
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()));
133
134
135 /** 
136
137 * Method: queryDateBetween(String eventId, Date startDate, Date endDate) 
138
139 */ 
140 @Test
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"));
144
145
146 /** 
147
148 * Method: queryDateBetween(String resourceId, String name, String startTime, String endTime) 
149
150 */ 
151 @Test
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"));
155
156
157
158 /** 
159
160 * Method: queryMaxValueByBetweenDate(String sourceId, String name, String startTime, String endTime) 
161
162 */ 
163 @Test
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));
167
168
169
170
171