Class TerminalEvent
An immutable value with static factories, one per event kind. Every factory and IllegalArgumentException naming the member, so a producer
finds its bug where it is written. toContractMap() produces the wire form, and fromMap(Map) is
its strict inverse.
A seq() of
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe final status of a run.static enumThe final status of a step.static enumThe event kinds.static enumThe level of a note.static enumThe state of a step that has not ended.static enumThe status of a test. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum length of one serialized event.static final intThe maximum length of a failure message.static final intThe maximum length of a suite or test name.static final intThe maximum length of a note text.static final longThe largest integer a JSON number can carry exactly.static final intThe maximum length of a step title.static final intThe maximum length of a stack trace. -
Method Summary
Modifier and TypeMethodDescriptionstatic TerminalEventdone(TerminalEvent.DoneStatus status) Creates adone event.static TerminalEventend(String id, TerminalEvent.EndStatus status) Creates anend event.booleanstatic TerminalEventBuilds an event from its wire form.inthashCode()kind()Returns the event kind.static TerminalEventnote(TerminalEvent.Level level, String text) Creates anote event.static TerminalEventCreates areplace event.longseq()Returns the sequence number.static TerminalEventCreates astep event.static TerminalEventCreates asuite placeholder event.static TerminalEventCreates atest event.Returns the event in its wire form.toString()validate()Checks that the serialized event fits inMAX_EVENT_CHARS.withExit(int exit) Sets the process exit code of anend event.Sets the link of anote event.withMs(long ms) Sets the duration of anend ortest event.Sets the failure message of atest event.withN(int n) Sets the display ordinal of astep event.withRawOffset(long offset) Sets the raw byte offset of astep ,suite ortest event.withSeq(long seq) Returns a copy with the sequence number set.withState(TerminalEvent.StepState state) Sets the state of astep event.Sets the step anote belongs under.Sets the stack trace of atest event.
-
Field Details
-
MAX_EVENT_CHARS
The maximum length of one serialized event.- See Also:
-
MAX_TITLE
The maximum length of a step title.- See Also:
-
MAX_NAME
The maximum length of a suite or test name.- See Also:
-
MAX_MSG
The maximum length of a failure message.- See Also:
-
MAX_TRACE
The maximum length of a stack trace.- See Also:
-
MAX_NOTE
The maximum length of a note text.- See Also:
-
MAX_SAFE_INT
The largest integer a JSON number can carry exactly.- See Also:
-
-
Method Details
-
step
Creates astep event.- Parameters:
id- The step id. Must match^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$ .title- The step title, 1-200 chars.- Returns:
- A new event.
-
end
Creates anend event.- Parameters:
id- The id of a known step.status- The final status.- Returns:
- A new event.
-
suite
public static TerminalEvent suite(String step, String fw, String suite, int pass, int fail, int skip) Creates asuite placeholder event.- Parameters:
step- The id of a known step.fw- The test framework key.suite- The suite name, 1-512 chars.pass- The pass count, 0-1,000,000,000.fail- The fail count, 0-1,000,000,000.skip- The skip count, 0-1,000,000,000.- Returns:
- A new event.
-
test
public static TerminalEvent test(String step, String fw, String suite, String name, TerminalEvent.TestStatus status) Creates atest event.- Parameters:
step- The id of a known step.fw- The test framework key.suite- The suite name, 1-512 chars.name- The test name, 1-512 chars.status- The test status.- Returns:
- A new event.
-
replace
Creates areplace event.- Parameters:
step- The id of a known step.- Returns:
- A new event.
-
note
Creates anote event.- Parameters:
level- The level.text- The plain text, 1-1,000 chars.- Returns:
- A new event.
-
done
Creates adone event.- Parameters:
status- The final run status.- Returns:
- A new event.
-
withN
Sets the display ordinal of astep event.- Parameters:
n- The ordinal, 1-9999.- Returns:
- A copy with the member set.
-
withState
Sets the state of astep event.- Parameters:
state- The state.- Returns:
- A copy with the member set.
-
withRawOffset
Sets the raw byte offset of astep ,suite ortest event.The 0-based offset into the raw output log of the start of the line that produced the event; a terminal view scrolls to it.
- Parameters:
offset- The offset, 0 to 9007199254740991.- Returns:
- A copy with the member set.
-
withMs
Sets the duration of anend ortest event.- Parameters:
ms- The duration in milliseconds, 0 to 9007199254740991.- Returns:
- A copy with the member set.
-
withExit
Sets the process exit code of anend event.- Parameters:
exit- The exit code.- Returns:
- A copy with the member set.
-
withMsg
Sets the failure message of atest event.- Parameters:
msg- The message, at most 2,000 chars.- Returns:
- A copy with the member set.
-
withTrace
Sets the stack trace of atest event.- Parameters:
trace- The trace, at most 8,000 chars.- Returns:
- A copy with the member set.
-
withHref
Sets the link of anote event.- Parameters:
href- An absolute http(s) URL or a same-origin path.- Returns:
- A copy with the member set.
-
withStep
Sets the step anote belongs under.- Parameters:
step- A step id.- Returns:
- A copy with the member set.
-
withSeq
Returns a copy with the sequence number set.- Parameters:
seq- The sequence number, 1 to 9007199254740991, or 0 for unassigned.- Returns:
- A copy.
-
kind
Returns the event kind.- Returns:
- The kind.
-
seq
Returns the sequence number.- Returns:
- The sequence number, or
0 when unassigned.
-
toContractMap
Returns the event in its wire form.The map is ordered (
ev ,seq when assigned, then the members in contract order) and omits unset optional members. A fresh map is returned on every call.- Returns:
- The wire map.
-
validate
Checks that the serialized event fits inMAX_EVENT_CHARS.- Returns:
- This object.
- Throws:
IllegalArgumentException- If it does not.
-
fromMap
Builds an event from its wire form.The strict inverse of
toContractMap(). Unknown members are ignored; an unknownev or a malformed known member throws.- Parameters:
map- The wire map.- Returns:
- A new event.
- Throws:
IllegalArgumentException- If the map is not a valid event.
-
equals
-
hashCode
-
toString
-