forked from intercom/intercom-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdminsTest.java
More file actions
94 lines (80 loc) · 2.82 KB
/
Copy pathAdminsTest.java
File metadata and controls
94 lines (80 loc) · 2.82 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
package com.intercom.api.integration;
import com.intercom.api.Intercom;
import com.intercom.api.resources.admins.requests.ConfigureAwayAdminRequest;
import com.intercom.api.resources.admins.requests.FindAdminRequest;
import com.intercom.api.resources.admins.requests.ListAllActivityLogsRequest;
import com.intercom.api.resources.admins.types.Admin;
import com.intercom.api.types.ActivityLogList;
import com.intercom.api.types.AdminList;
import com.intercom.api.utils.TestClientFactory;
import java.time.LocalDate;
import java.time.ZoneOffset;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class AdminsTest {
private Intercom client;
private String adminId;
@BeforeEach
public void before() {
// arrange
client = TestClientFactory.create();
adminId = client.admins().list().getAdmins().get(0).getId();
}
@Test
public void testList() {
// act
AdminList response = client.admins().list();
// assert
Assertions.assertNotNull(response);
}
@Test
public void testFind() {
// act
Admin response =
client.admins().find(FindAdminRequest.builder().adminId(adminId).build());
// assert
Assertions.assertNotNull(response);
}
@Test
public void testListAllActivityLogs() {
// act
ActivityLogList response = client.admins()
.listAllActivityLogs(ListAllActivityLogsRequest.builder()
.createdAtAfter(LocalDate.parse("2021-12-12")
.atStartOfDay()
.toInstant(ZoneOffset.UTC)
.toString())
.createdAtBefore(LocalDate.parse("2022-01-01")
.atStartOfDay()
.toInstant(ZoneOffset.UTC)
.toString())
.build());
// assert
Assertions.assertNotNull(response);
}
@Test
public void testAwayOn() {
// act
Admin response = client.admins()
.away(ConfigureAwayAdminRequest.builder()
.adminId(adminId)
.awayModeEnabled(true)
.awayModeReassign(true)
.build());
// assert
Assertions.assertNotNull(response);
}
@Test
public void testAwayOff() {
// act
Admin response = client.admins()
.away(ConfigureAwayAdminRequest.builder()
.adminId(adminId)
.awayModeEnabled(false)
.awayModeReassign(false)
.build());
// assert
Assertions.assertNotNull(response);
}
}