forked from segmentio/analytics-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPayloadGenerator.java
More file actions
76 lines (60 loc) · 1.97 KB
/
Copy pathPayloadGenerator.java
File metadata and controls
76 lines (60 loc) · 1.97 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
package com.github.segmentio;
import java.util.Iterator;
import org.joda.time.DateTime;
import com.github.segmentio.models.Alias;
import com.github.segmentio.models.BasePayload;
import com.github.segmentio.models.Context;
import com.github.segmentio.models.EventProperties;
import com.github.segmentio.models.Identify;
import com.github.segmentio.models.Props;
import com.github.segmentio.models.Providers;
import com.github.segmentio.models.Track;
import com.github.segmentio.models.Traits;
public class PayloadGenerator implements Iterable<BasePayload> {
public static BasePayload[] CASES = new BasePayload[] {
new Identify("ilya@segment.io",
new Traits().put("name", "Achilles")
.put("email", "achilles@segment.io")
.put("subscriptionPlan", "Premium")
.put("friendCount", 29)
.put("company", new Props()
.put("name", "Company, inc.")),
new DateTime(),
new Context().setIp("192.168.1.1"), null),
new Track("ilya@segment.io", "Played a Song",
new EventProperties().put("name", "Achilles")
.put("revenue", 39.95)
.put("shippingMethod", "2-day"),
new DateTime(),
new Context()
.setIp("192.168.1.1")
.setProviders(new Providers()
.setDefault(true)
.setEnabled("Mixpanel", false)
.setEnabled("KISSMetrics", true)
.setEnabled("Google Analytics", true)
), null),
new Alias("from", "ilya@segment.io",
new DateTime(),
new Context()
.setProviders(new Providers()
.setDefault(true)
.setEnabled("Mixpanel", false)
.setEnabled("KISSMetrics", true)
), null),
};
public Iterator<BasePayload> iterator() {
return new Iterator<BasePayload>() {
public boolean hasNext() {
return true;
}
public BasePayload next() {
int index = (int)Math.floor(Math.random() * CASES.length);
return CASES[index];
}
public void remove() {
// do nothing
}
};
}
}