Skip to content

Commit

Permalink
[Java] Added ErrorLogReader.hasErrors().
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Jul 30, 2018
1 parent fbf69ae commit dd87fab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Expand Up @@ -27,6 +27,17 @@
*/
public class ErrorLogReader
{
/**
* Has the error buffer any recorded errors?
*
* @param buffer containing the {@link DistinctErrorLog}.
* @return true if there is at least one error.
*/
public static boolean hasErrors(final AtomicBuffer buffer)
{
return 0 != buffer.getIntVolatile(LENGTH_OFFSET);
}

/**
* Read all the errors in a log since the creation of the log.
*
Expand Down
Expand Up @@ -119,9 +119,12 @@ public void shouldReadOneObservationSinceTimestamp()

when(clock.time()).thenReturn(timestampOne).thenReturn(timestampTwo);

assertFalse(ErrorLogReader.hasErrors(buffer));

log.record(errorOne);
log.record(errorTwo);

assertTrue(ErrorLogReader.hasErrors(buffer));
assertThat(ErrorLogReader.read(buffer, consumer, timestampTwo), is(1));

verify(consumer).accept(eq(1), eq(timestampTwo), eq(timestampTwo), any(String.class));
Expand Down

0 comments on commit dd87fab

Please sign in to comment.