This repository was archived by the owner on Jul 10, 2024. It is now read-only.
forked from dstendardi/snowplow-java-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackerTest.java
More file actions
209 lines (152 loc) · 6.38 KB
/
Copy pathTrackerTest.java
File metadata and controls
209 lines (152 loc) · 6.38 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package com.snowplowanalytics.snowplow.tracker;
import com.snowplowanalytics.snowplow.tracker.emitter.BufferOption;
import com.snowplowanalytics.snowplow.tracker.emitter.Emitter;
import com.snowplowanalytics.snowplow.tracker.emitter.HttpMethod;
import com.snowplowanalytics.snowplow.tracker.emitter.RequestMethod;
import com.snowplowanalytics.snowplow.tracker.payload.SchemaPayload;
import org.junit.Test;
import java.util.*;
import static org.junit.Assert.assertEquals;
public class TrackerTest {
private static String TESTURL = "d3rkrsqld9gmqf.cloudfront.net";
@Test
public void testDefaultPlatform() throws Exception {
Emitter emitter = new Emitter(TESTURL, HttpMethod.POST);
Subject subject = new Subject();
Tracker tracker = new Tracker(emitter, subject, "AF003", "cloudfront", false);
assertEquals(DevicePlatform.Desktop, tracker.getPlatform());
}
@Test
public void testSetPlatform() throws Exception {
Emitter emitter = new Emitter(TESTURL, HttpMethod.POST);
Subject subject = new Subject();
Tracker tracker = new Tracker(emitter, subject, "AF003", "cloudfront", false);
tracker.setPlatform(DevicePlatform.ConnectedTV);
assertEquals(DevicePlatform.ConnectedTV, tracker.getPlatform());
}
@Test
public void testSetSubject() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("Etc/UTC"));
Emitter emitter = new Emitter(TESTURL, HttpMethod.POST);
Subject s1 = new Subject();
Tracker tracker = new Tracker(emitter, s1, "AF003", "cloudfront", false);
Subject s2 = new Subject();
s2.setColorDepth(24);
tracker.setSubject(s2);
Map<String, String> subjectPairs = new HashMap<String, String>();
subjectPairs.put("tz", "Etc/UTC");
subjectPairs.put("cd", "24");
assertEquals(subjectPairs, tracker.getSubject().getSubject());
}
@Test
public void testSetSchema() throws Exception {
}
@Test
public void testTrackPageView() throws Exception {
}
@Test
public void testTrackPageView1() throws Exception {
}
@Test
public void testTrackPageView2() throws Exception {
}
@Test
public void testTrackPageView3() throws Exception {
Emitter emitter = new Emitter(TESTURL, HttpMethod.POST);
Subject subject = new Subject();
subject.setViewPort(320, 480);
Tracker tracker = new Tracker(emitter, subject, "AF003", "cloudfront", false);
emitter.setRequestMethod(RequestMethod.Asynchronous);
SchemaPayload context = new SchemaPayload();
Map<String, String> someContext = new HashMap<String, String>();
someContext.put("someContextKey", "testTrackPageView3");
context.setSchema("iglu:com.snowplowanalytics.snowplow/example/jsonschema/1-0-0");
context.setData(someContext);
ArrayList<SchemaPayload> contextList = new ArrayList<SchemaPayload>();
contextList.add(context);
tracker.trackPageView("www.mypage.com", "My Page", "www.me.com", contextList);
emitter.flushBuffer();
}
@Test
public void testTrackStructuredEvent() throws Exception {
}
@Test
public void testTrackStructuredEvent1() throws Exception {
}
@Test
public void testTrackStructuredEvent2() throws Exception {
}
@Test
public void testTrackStructuredEvent3() throws Exception {
}
@Test
public void testTrackUnstructuredEvent() throws Exception {
}
@Test
public void testTrackUnstructuredEvent1() throws Exception {
}
@Test
public void testTrackUnstructuredEvent2() throws Exception {
}
@Test
public void testTrackUnstructuredEvent3() throws Exception {
}
@Test
public void testTrackEcommerceTransactionItem() throws Exception {
}
@Test
public void testTrackEcommerceTransaction() throws Exception {
Emitter emitter = new Emitter(TESTURL, HttpMethod.POST);
Tracker tracker = new Tracker(emitter, "AF003", "cloudfront", false);
emitter.setRequestMethod(RequestMethod.Asynchronous);
SchemaPayload context = new SchemaPayload();
Map<String, String> someContext = new HashMap<String, String>();
someContext.put("someContextKey", "testTrackPageView2");
context.setSchema("iglu:com.snowplowanalytics.snowplow/example/jsonschema/1-0-0");
context.setData(someContext);
ArrayList<SchemaPayload> contextList = new ArrayList<SchemaPayload>();
contextList.add(context);
TransactionItem transactionItem = new TransactionItem("order-8", "no_sku",
34.0, 1, "Big Order", "Food", "USD", contextList);
LinkedList<TransactionItem> transactionItemLinkedList = new LinkedList<TransactionItem>();
transactionItemLinkedList.add(transactionItem);
tracker.trackEcommerceTransaction("order-7", 25.0, "no_affiliate", 0.0, 0.0, "Dover",
"Delaware", "US", "USD", transactionItemLinkedList);
emitter.flushBuffer();
}
@Test
public void testTrackEcommerceTransaction1() throws Exception {
}
@Test
public void testTrackEcommerceTransaction2() throws Exception {
}
@Test
public void testTrackEcommerceTransaction3() throws Exception {
}
@Test
public void testTrackScreenView() throws Exception {
Emitter emitter = new Emitter(TESTURL, HttpMethod.POST);
Subject subject = new Subject();
subject.setViewPort(320, 480);
Tracker tracker = new Tracker(emitter, subject, "AF003", "cloudfront", false);
emitter.setRequestMethod(RequestMethod.Asynchronous);
emitter.setBufferOption(BufferOption.Instant);
SchemaPayload context = new SchemaPayload();
Map<String, String> someContext = new HashMap<String, String>();
someContext.put("someContextKey", "testTrackPageView2");
context.setSchema("iglu:com.snowplowanalytics.snowplow/example/jsonschema/1-0-0");
context.setData(someContext);
ArrayList<SchemaPayload> contextList = new ArrayList<SchemaPayload>();
contextList.add(context);
tracker.trackScreenView(null, "screen_1", contextList, 0);
}
@Test
public void testTrackScreenView1() throws Exception {
}
@Test
public void testTrackScreenView2() throws Exception {
}
@Test
public void testTrackScreenView3() throws Exception {
}
}