Skip to content

Commit bb7400a

Browse files
committed
test: adopt functional tests to new API
1 parent 389673b commit bb7400a

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

examples/src/main/java/com/fingerprint/example/FunctionalTests.java

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void main(String... args) {
1919
String FPJS_REQUEST_ID_TO_UPDATE = System.getenv("FPJS_REQUEST_ID_TO_UPDATE");
2020
String FPJS_VISITOR_ID_TO_DELETE = System.getenv("FPJS_VISITOR_ID_TO_DELETE");
2121
String FPJS_VISITOR_ID = "";
22-
String FPJS_REQUEST_ID = "";
22+
String FPJS_EVENT_ID = "";
2323

2424
// Create a new instance of the API client
2525
ApiClient client = Configuration.getDefaultApiClient(FPJS_API_SECRET, FPJS_API_REGION != null ? FPJS_API_REGION : "us");
@@ -30,17 +30,18 @@ public static void main(String... args) {
3030

3131
// Search events
3232
try {
33-
final SearchEventsResponse events = api.searchEvents(2, new FingerprintApi.SearchEventsOptionalParams()
33+
final EventSearch events = api.searchEvents(new FingerprintApi.SearchEventsOptionalParams()
34+
.setLimit(2)
3435
.setStart(start)
3536
.setEnd(end)
3637
);
3738
if (events.getEvents().isEmpty()) {
3839
System.err.println("FingerprintApi.searchEvents: is empty");
3940
System.exit(1);
4041
}
41-
Identification firstEventIdentificationData = events.getEvents().get(0).getProducts().getIdentification().getData();
42-
FPJS_VISITOR_ID = firstEventIdentificationData.getVisitorId();
43-
FPJS_REQUEST_ID = firstEventIdentificationData.getRequestId();
42+
Event firstEvent = events.getEvents().get(0);
43+
FPJS_VISITOR_ID = firstEvent.getIdentification().getVisitorId();
44+
FPJS_EVENT_ID = firstEvent.getEventId();
4445
System.out.println(events.getEvents());
4546
} catch (ApiException e) {
4647
System.err.println("Exception when calling FingerprintApi.searchEvents:" + e.getMessage());
@@ -49,30 +50,21 @@ public static void main(String... args) {
4950

5051
// Get identification event
5152
try {
52-
final EventsGetResponse event = api.getEvent(FPJS_REQUEST_ID);
53+
final Event event = api.getEvent(FPJS_EVENT_ID);
5354
System.out.println(event);
5455
} catch (ApiException e) {
5556
System.err.println("Exception when calling FingerprintApi.getEvent:" + e.getMessage());
5657
System.exit(1);
5758
}
5859

59-
// Get visitor history
60-
try {
61-
final VisitorsGetResponse visits = api.getVisits(FPJS_VISITOR_ID, null, null, null, null, null);
62-
System.out.println(visits);
63-
} catch (ApiException e) {
64-
System.err.println("Exception when calling FingerprintApi.getEvent:" + e.getMessage());
65-
System.exit(1);
66-
}
67-
6860
// Update identification event
6961

7062
if (FPJS_REQUEST_ID_TO_UPDATE != null) {
7163
try {
7264
final HashMap<String, Object> tags = new HashMap() {{
7365
put("timestamp", new Timestamp(new Date().getTime()));
7466
}};
75-
api.updateEvent(FPJS_REQUEST_ID_TO_UPDATE, new EventsUpdateRequest().tag(tags));
67+
api.updateEvent(FPJS_REQUEST_ID_TO_UPDATE, new EventUpdate().tags(tags));
7668
} catch (ApiException e) {
7769
System.err.println("Exception when calling FingerprintApi.updateEvent:" + e.getMessage());
7870
System.exit(1);
@@ -92,7 +84,8 @@ public static void main(String... args) {
9284

9385
// Check that old events are still match expected format
9486
try {
95-
final SearchEventsResponse oldEvents = api.searchEvents(2, new FingerprintApi.SearchEventsOptionalParams()
87+
final EventSearch oldEvents = api.searchEvents(new FingerprintApi.SearchEventsOptionalParams()
88+
.setLimit(2)
9689
.setStart(start)
9790
.setEnd(end)
9891
.setReverse(true)
@@ -101,17 +94,16 @@ public static void main(String... args) {
10194
System.err.println("FingerprintApi.searchEvents: is empty for old events");
10295
System.exit(1);
10396
}
104-
Identification oldEventIdentificationData = oldEvents.getEvents().get(0).getProducts().getIdentification().getData();
105-
String FPJS_OLD_VISITOR_ID = oldEventIdentificationData.getVisitorId();
106-
String FPJS_OLD_REQUEST_ID = oldEventIdentificationData.getRequestId();
97+
Event oldEvent = oldEvents.getEvents().get(0);
98+
String FPJS_OLD_VISITOR_ID = oldEvent.getIdentification().getVisitorId();
99+
String FPJS_OLD_EVENT_ID = oldEvent.getEventId();
107100

108-
if (FPJS_VISITOR_ID.equals(FPJS_OLD_VISITOR_ID) || FPJS_REQUEST_ID.equals(FPJS_OLD_REQUEST_ID)) {
101+
if (FPJS_VISITOR_ID.equals(FPJS_OLD_VISITOR_ID) || FPJS_EVENT_ID.equals(FPJS_OLD_EVENT_ID)) {
109102
System.err.println("Old events are identical to new");
110103
System.exit(1);
111104
}
112105

113-
api.getEvent(FPJS_OLD_REQUEST_ID);
114-
api.getVisits(FPJS_OLD_VISITOR_ID, null, null, null, null, null);
106+
api.getEvent(FPJS_OLD_EVENT_ID);
115107
System.out.println("Old events are good");
116108
} catch (ApiException e) {
117109
System.err.println("Exception when trying to read old data:" + e.getMessage());

examples/src/main/java/com/fingerprint/example/SealedResults.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.fingerprint.example;
22

33
import com.fingerprint.Sealed;
4-
import com.fingerprint.model.EventsGetResponse;
4+
import com.fingerprint.model.Event;
55

66
import java.util.Base64;
77

@@ -10,7 +10,7 @@ public static void main(String... args) throws Exception {
1010
String SEALED_RESULT = System.getenv("BASE64_SEALED_RESULT");
1111
String SEALED_KEY = System.getenv("BASE64_KEY");
1212

13-
final EventsGetResponse event = Sealed.unsealEventResponse(
13+
final Event event = Sealed.unsealEventResponse(
1414
Base64.getDecoder().decode(SEALED_RESULT),
1515
new Sealed.DecryptionKey[]{
1616
new Sealed.DecryptionKey(

0 commit comments

Comments
 (0)