forked from PingPlusPlus/pingpp-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebhookTest.java
More file actions
64 lines (50 loc) · 1.96 KB
/
WebhookTest.java
File metadata and controls
64 lines (50 loc) · 1.96 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
package com.pingplusplus;
import com.pingplusplus.model.*;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/*
* @author Afon, @date 17-03-28
*/
public class WebhookTest extends PingppTestBase {
/**
* 解析 webhooks 消息 (withdrawal)
*/
@Test
public void testWebhooksParseWithdrawal() {
String webhookData = PingppTestData.getWithdrawalWebhooksData();
PingppObject obj = Webhooks.getObject(webhookData);
assertTrue("object should be an instance of Withdrawal", obj instanceof Withdrawal);
assertEquals("object should be withdrawal", "withdrawal", ((Withdrawal) obj).getObject());
}
/**
* 解析 webhooks 消息 (recharge)
*/
@Test
public void testWebhooksParseRecharge() {
String webhookData = PingppTestData.getRechargeSucceededEventData();
PingppObject obj = Webhooks.getObject(webhookData);
assertTrue("object should be an instance of Recharge", obj instanceof Recharge);
assertEquals("object should be recharge", "recharge", ((Recharge) obj).getObject());
}
/**
* 解析 webhooks 消息 (order)
*/
@Test
public void testWebhooksParseOrder() {
String webhookData = PingppTestData.getOrderSucceededEventData();
PingppObject obj = Webhooks.getObject(webhookData);
assertTrue("object should be an instance of Order", obj instanceof Order);
assertEquals("object should be order", "order", ((Order) obj).getObject());
}
/**
* 解析 webhooks 消息 (agreement)
*/
@Test
public void testWebhooksParseAgreement() {
String webhookData = PingppTestData.getAgreementEventData();
PingppObject obj = Webhooks.getObject(webhookData);
assertTrue("object should be an instance of Agreement", obj instanceof Agreement);
assertEquals("object should be agreement", "agreement", ((Agreement) obj).getObject());
}
}