-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHealthOutcomeTest.java
More file actions
50 lines (41 loc) · 1.3 KB
/
Copy pathHealthOutcomeTest.java
File metadata and controls
50 lines (41 loc) · 1.3 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
package com.retailsvc.http;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Test;
class HealthOutcomeTest {
@Test
void exposesDependencies() {
HealthOutcome o = new HealthOutcome(List.of(new Dependency("jdbc", true)));
assertThat(o.dependencies()).containsExactly(new Dependency("jdbc", true));
}
@Test
void coercesNullDependenciesToEmpty() {
HealthOutcome o = new HealthOutcome(null);
assertThat(o.dependencies()).isEmpty();
}
@Test
void copiesDependencyListDefensively() {
List<Dependency> mutable = new ArrayList<>();
mutable.add(new Dependency("jdbc", true));
HealthOutcome o = new HealthOutcome(mutable);
mutable.clear();
assertThat(o.dependencies()).hasSize(1);
}
@Test
void emptyDependenciesIsUp() {
assertThat(new HealthOutcome(List.of()).up()).isTrue();
}
@Test
void upWhenAllDependenciesUp() {
HealthOutcome o =
new HealthOutcome(List.of(new Dependency("jdbc", true), new Dependency("redis", true)));
assertThat(o.up()).isTrue();
}
@Test
void downWhenAnyDependencyDown() {
HealthOutcome o =
new HealthOutcome(List.of(new Dependency("jdbc", true), new Dependency("redis", false)));
assertThat(o.up()).isFalse();
}
}