forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPNConfigurationTest.java
More file actions
55 lines (43 loc) · 1.89 KB
/
Copy pathPNConfigurationTest.java
File metadata and controls
55 lines (43 loc) · 1.89 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
package com.pubnub.api;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class PNConfigurationTest {
@Test
void should_set_uuid_creating_PNConfiguration() throws PubNubException {
String userId01value = "userId01";
PNConfiguration pnConfiguration = new PNConfiguration(new UserId(userId01value));
assertEquals(userId01value, pnConfiguration.getUserId().getValue());
}
@Test
void can_setUserId() throws PubNubException {
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("userId01"));
UserId newUserId = new UserId("newUserId");
pnConfiguration.setUserId(newUserId);
assertEquals(newUserId.getValue(), pnConfiguration.getUserId().getValue());
}
@Test
void can_getUserId() throws PubNubException {
String userId01value = "userId01";
PNConfiguration pnConfiguration = new PNConfiguration(new UserId(userId01value));
UserId retrievedUserId = pnConfiguration.getUserId();
assertEquals(userId01value, retrievedUserId.getValue());
}
@Test
void can_reset_userId_to_non_empty_string() throws PubNubException {
PNConfiguration pnConfiguration = new PNConfiguration(new UserId("userId01"));
String newUserIdValue = "newUserId";
pnConfiguration.setUserId(new UserId(newUserIdValue));
assertEquals(newUserIdValue, pnConfiguration.getUserId().getValue());
}
@Test
void should_throw_exception_when_userIdValue_is_empty_string() {
Assertions.assertThrows(PubNubRuntimeException.class, () -> new PNConfiguration(new UserId("")));
}
@Test
void should_throw_exception_when_userIdValue_is_null_string() {
Assertions.assertThrows(PubNubRuntimeException.class, () -> {
new PNConfiguration(new UserId(null));
});
}
}