Skip to content

Commit

Permalink
test severity enum too
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcormie committed Nov 12, 2024
1 parent 82a2ce2 commit 82598ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,10 @@ private static List<ChannelTraceEvent> toChannelTraceEvents(List<Event> events)
return Collections.unmodifiableList(channelTraceEvents);
}

private static Severity toSeverity(Event.Severity severity) {
static Severity toSeverity(Event.Severity severity) {
if (severity == null) {
return Severity.CT_UNKNOWN;
}
switch (severity) {
case CT_INFO:
return Severity.CT_INFO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,16 @@ public void toServerRef() {
assertEquals(serverRef, ChannelzProtoUtil.toServerRef(server));
}

@Test
public void toSeverity() {
for (Severity severity : Severity.values()) {
assertEquals(
severity.name(),
ChannelzProtoUtil.toSeverity(severity).name()); // OK because test isn't proguarded.
}
assertEquals(ChannelTraceEvent.Severity.CT_UNKNOWN, ChannelzProtoUtil.toSeverity(null));
}

@Test
public void toSocketRef() {
assertEquals(socketRef, ChannelzProtoUtil.toSocketRef(socket));
Expand Down

0 comments on commit 82598ac

Please sign in to comment.