-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathRegistrationContextTest.java
More file actions
39 lines (31 loc) · 1.48 KB
/
RegistrationContextTest.java
File metadata and controls
39 lines (31 loc) · 1.48 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
package com.digitalsanctuary.spring.user.registration;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@DisplayName("RegistrationContext Tests")
class RegistrationContextTest {
@Test
@DisplayName("Should reject null source in RegistrationContext")
void shouldRejectNullSource() {
assertThatThrownBy(() -> new RegistrationContext("user@example.com", null, null))
.isInstanceOf(NullPointerException.class)
.hasMessageContaining("source must not be null");
}
@Test
@DisplayName("Should accept valid context with all fields")
void shouldAcceptValidContext() {
RegistrationContext context = new RegistrationContext("user@example.com", RegistrationSource.OAUTH2, "google");
assertThat(context.email()).isEqualTo("user@example.com");
assertThat(context.source()).isEqualTo(RegistrationSource.OAUTH2);
assertThat(context.providerName()).isEqualTo("google");
}
@Test
@DisplayName("Should accept null email and null providerName")
void shouldAcceptNullEmailAndProvider() {
RegistrationContext context = new RegistrationContext(null, RegistrationSource.FORM, null);
assertThat(context.email()).isNull();
assertThat(context.source()).isEqualTo(RegistrationSource.FORM);
assertThat(context.providerName()).isNull();
}
}