-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEventsTest.java
More file actions
70 lines (59 loc) · 2.45 KB
/
EventsTest.java
File metadata and controls
70 lines (59 loc) · 2.45 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
package com.seam.api.events;
import com.seam.api.Seam;
import com.seam.api.TestUtils;
import com.seam.api.TestUtils.FakeSeamStartedResponse;
import com.seam.api.resources.events.requests.EventsGetRequest;
import com.seam.api.resources.events.requests.EventsListRequest;
import com.seam.api.types.Event;
import java.util.List;
import java.util.Optional;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
public final class EventsTest {
private static final String SINCE = "2021-01-01T00:00:00.000Z";
private static final String FAKE_UUID = "00000000-0000-0000-0000-000000000000";
private static Seam seam;
private static Process p;
@BeforeAll
public static void beforeAll() {
FakeSeamStartedResponse response = TestUtils.startFakeSeam();
seam = response.seam;
p = response.process;
}
@AfterAll
public static void afterAll() {
p.destroyForcibly();
}
// Fake Seam does not serve events endpoints
// @Test
public void test_events() {
List<Event> events =
seam.events().list(EventsListRequest.builder().since(SINCE).build());
Event connectedEvent = events.stream()
.filter(event -> event.getEventType().equals("device.connected"))
.findFirst()
.get();
Event eventById = seam.events()
.get(EventsGetRequest.builder()
.eventId(connectedEvent.getEventId())
.build())
.get();
Assertions.assertThat(eventById.getEventId()).isEqualTo(connectedEvent.getEventId());
Event eventByType = seam.events()
.get(EventsGetRequest.builder()
.eventType(connectedEvent.getEventType())
.build())
.get();
Assertions.assertThat(eventByType.getEventType()).isEqualTo(connectedEvent.getEventType());
Event eventByDeviceId = seam.events()
.get(EventsGetRequest.builder()
.deviceId(connectedEvent.getDeviceId())
.build())
.get();
Assertions.assertThat(eventByDeviceId.getDeviceId()).isEqualTo(connectedEvent.getDeviceId());
Optional<Event> emptyEvent =
seam.events().get(EventsGetRequest.builder().eventId(FAKE_UUID).build());
Assertions.assertThat(emptyEvent).isEmpty();
}
}