File tree Expand file tree Collapse file tree
main/java/com/retailsvc/http
test/java/com/retailsvc/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .retailsvc .http ;
2+
3+ import java .util .Objects ;
4+
5+ /**
6+ * A single dependency entry within a {@link HealthOutcome}.
7+ *
8+ * @param id stable identifier of the dependency (e.g. {@code "jdbc"})
9+ * @param status free-form status; {@code "Up"} (case-insensitive) is treated as healthy by {@link
10+ * HealthOutcome#isUp()}; any other value is treated as unhealthy
11+ */
12+ public record Dependency (String id , String status ) {
13+ public Dependency {
14+ Objects .requireNonNull (id , "id" );
15+ Objects .requireNonNull (status , "status" );
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ package com .retailsvc .http ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+ import static org .assertj .core .api .Assertions .assertThatNullPointerException ;
5+
6+ import org .junit .jupiter .api .Test ;
7+
8+ class DependencyTest {
9+
10+ @ Test
11+ void holdsIdAndStatus () {
12+ Dependency d = new Dependency ("jdbc" , "Up" );
13+ assertThat (d .id ()).isEqualTo ("jdbc" );
14+ assertThat (d .status ()).isEqualTo ("Up" );
15+ }
16+
17+ @ Test
18+ void rejectsNullId () {
19+ assertThatNullPointerException ()
20+ .isThrownBy (() -> new Dependency (null , "Up" ))
21+ .withMessageContaining ("id" );
22+ }
23+
24+ @ Test
25+ void rejectsNullStatus () {
26+ assertThatNullPointerException ()
27+ .isThrownBy (() -> new Dependency ("jdbc" , null ))
28+ .withMessageContaining ("status" );
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments