DeviceControllerTest.java
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.glsx.modules.notify.controller;
import com.glsx.modules.notify.factory.PushType;
import com.glsx.modules.notify.model.BaseRequest;
import com.glsx.modules.notify.model.param.NotifyReqParam;
import com.glsx.modules.notify.push.BroadCastService;
import com.glsx.modules.notify.service.CarHomePushService;
import com.glsx.modules.notify.service.PushService;
import com.glsx.plat.core.web.R;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@Slf4j
public class DeviceControllerTest {
@Autowired
private CarHomePushService pushService;
@Test
public void testPush_android_notify() {
try {
NotifyReqParam pushRequest = new NotifyReqParam();
//推送平台参数
//pushRequest.setPlatformType(PushType.YOUMENG.getCode());
pushRequest.setDeviceType("ANDROID");
//推送别名参数
pushRequest.setAlias("91712432");
//通知参数
pushRequest.setTitle("消息推送测试标题");
pushRequest.setBody("内容test");
BaseRequest baseRequest = new BaseRequest();
BeanUtils.copyProperties(pushRequest,baseRequest);
if (baseRequest.getDeviceType().equals("ANDROID")){
baseRequest.setPlatformType(PushType.YOUMENG.getCode());
}
if (baseRequest.getDeviceType().equals("iOS")){
baseRequest.setPlatformType(PushType.ALIYUN.getCode());
}
R r = pushService.pushNotify(baseRequest);
log.info("fzpush===android==="+r);
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Test
public void testPush_ios_notify() {
try {
NotifyReqParam pushRequest = new NotifyReqParam();
//推送平台参数
//pushRequest.setPlatformType(PushType.ALIYUN.getCode());
pushRequest.setDeviceType("iOS");
//推送别名参数
pushRequest.setAlias("com.glsx.aicar.push");
//通知参数
pushRequest.setTitle("这是消息推送测试标题");
pushRequest.setBody("这是内容test");
BaseRequest baseRequest = new BaseRequest();
BeanUtils.copyProperties(pushRequest,baseRequest);
if (baseRequest.getDeviceType().equals("ANDROID")){
baseRequest.setPlatformType(PushType.YOUMENG.getCode());
}
if (baseRequest.getDeviceType().equals("iOS")){
baseRequest.setPlatformType(PushType.ALIYUN.getCode());
}
R r = pushService.pushNotify(baseRequest);
log.info("fzpush===ios==="+r);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}