@@ -0,0 +1,3127 @@
+/*%0A * Copyright 2018, TeamDev. All rights reserved.%0A *%0A * Redistribution and use in source and/or binary forms, with or without%0A * modification, must retain the above copyright notice and the following%0A * disclaimer.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A * %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR%0A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT%0A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT%0A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,%0A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY%0A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A */%0A%0Apackage io.spine.server.entity;%0A%0Aimport io.spine.core.Event;%0Aimport org.junit.jupiter.api.DisplayName;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport java.util.Optional;%0A%0Aimport static org.junit.jupiter.api.Assertions.assertFalse;%0Aimport static org.junit.jupiter.api.Assertions.assertTrue;%0Aimport static org.mockito.ArgumentMatchers.any;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.spy;%0Aimport static org.mockito.Mockito.verifyZeroInteractions;%0Aimport static org.mockito.Mockito.when;%0A%0A/**%0A * @author Dmytro Dashenkov%0A */%0A@DisplayName(%22CompositeEventFilter should%22)%0Aclass CompositeEventFilterTest %7B%0A%0A    @Test%0A    @DisplayName(%22accept any given event if no filters are provided%22)%0A    void acceptIfEmpty() %7B%0A        CompositeEventFilter emptyFilter = CompositeEventFilter%0A                .newBuilder()%0A                .build();%0A        Optional%3CEvent%3E filtered = emptyFilter.filter(Event.getDefaultInstance());%0A        assertTrue(filtered.isPresent());%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22accept the given event if all filter accept%22)%0A    void acceptIfAllAccept() %7B%0A        CompositeEventFilter filter = CompositeEventFilter%0A                .newBuilder()%0A                .add(Optional::of)%0A                .add(Optional::of)%0A                .build();%0A        Event event = Event.getDefaultInstance();%0A        Optional%3CEvent%3E filtered = filter.filter(event);%0A        assertTrue(filtered.isPresent());%0A    %7D%0A%0A    @Test%0A    @DisplayName(%22not accept an event is one filter not accepts%22)%0A    void rejectIfOneRejects() %7B%0A        EventFilter spyFilter = mock(EventFilter.class);%0A        when(spyFilter.filter(any(Event.class)))%0A                .thenReturn(Optional.of(Event.getDefaultInstance()));%0A        CompositeEventFilter filter = CompositeEventFilter%0A                .newBuilder()%0A                .add(anyEvent -%3E Optional.empty())%0A                .add(spyFilter)%0A                .build();%0A        Event event = Event.getDefaultInstance();%0A        Optional%3CEvent%3E filtered = filter.filter(event);%0A        assertFalse(filtered.isPresent());%0A        verifyZeroInteractions(spyFilter);%0A    %7D%0A%7D%0A

Add tests for `CompositeEventFilter`.