@Test
public void verifyOnlyNonExistingAndNonEmptyNoteArePersisted()
{

    // Given
    ArgumentCaptor<List<String>> argument = ArgumentCaptor.forClass( List.class );
    final List<Note> notes = rnd.randomObjects( Note.class, 5, "newNote" );
    final List<Note> emptyNotes = rnd.randomObjects( Note.class, 3, "newNote", "value" );
    final List<Note> existingNotes = rnd.randomObjects( Note.class, 2, "newNote" );
    event.setNotes( newArrayList( concat( notes, emptyNotes, existingNotes ) ) );
    // When
    when( commentService.filterExistingNotes( argument.capture() ) ).thenReturn(
            notes.stream().map( Note::getNote ).collect( Collectors.toList() ) );
    this.hook.validateEvent( mock( ValidationErrorReporter.class ), event );
    // Then
    assertThat( event.getNotes(), hasSize( 5 ) );
    List<String> value = argument.getValue();
    // make sure that the filterExistingNotes was called only with uid belonging to notes with text
    assertThat( value, containsInAnyOrder( newArrayList( concat( notes, existingNotes ) ).stream()
        .map( Note::getNote ).toArray() ) );
}