/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.spine3.server.event;

import com.google.common.testing.NullPointerTester;
import org.junit.Test;
import org.spine3.base.Event;

/**
 * @author Dmytro Dashenkov
 */
public class MatchesStreamQueryShould {

    @Test
    public void not_accept_nulls() {
        final MatchesStreamQuery predicate = new MatchesStreamQuery(
                EventStreamQuery.getDefaultInstance());

        new NullPointerTester()
                .setDefault(Event.class, Event.getDefaultInstance())
                .testAllPublicInstanceMethods(predicate);
    }
}

@@ -1096,16 +1096,52 @@
 Tester;%0A
+import com.google.protobuf.Message;%0A
 import o
@@ -1189,422 +1189,3281 @@
 nt;%0A
-%0A/**%0A * @author Dmytro Dashenkov%0A */%0Apublic class MatchesStreamQueryShould %7B%0A%0A    @Test%0A    public void not_accept_nulls() %7B%0A        final MatchesStreamQuery predicate = new MatchesStreamQuery(%0A                EventStreamQuery.getDefaultInstance());%0A%0A        new NullPointerTester()%0A                .setDefault(Event.class, Event.getDefaultInstance())%0A                .testAllPublicInstanceMethods(predicate);%0A    %7D
+import org.spine3.base.FieldFilter;%0Aimport org.spine3.base.Identifiers;%0Aimport org.spine3.protobuf.AnyPacker;%0Aimport org.spine3.test.TestEventFactory;%0Aimport org.spine3.test.event.ProjectCreated;%0Aimport org.spine3.test.event.ProjectId;%0A%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.spine3.test.TestEventFactory.newInstance;%0A%0A/**%0A * @author Dmytro Dashenkov%0A */%0Apublic class MatchesStreamQueryShould %7B%0A%0A    private static final String FIELD_NAME = %22spine.test.event.ProjectCreated.projectId%22;%0A%0A    private static final TestEventFactory eventFactory =%0A            newInstance(MatchesStreamQueryShould.class);%0A%0A    @Test%0A    public void not_accept_nulls() %7B%0A        final MatchesStreamQuery predicate = new MatchesStreamQuery(%0A                EventStreamQuery.getDefaultInstance());%0A%0A        new NullPointerTester()%0A                .setDefault(Event.class, Event.getDefaultInstance())%0A                .testAllPublicInstanceMethods(predicate);%0A    %7D%0A%0A    @Test%0A    public void match_proper_records() %7B%0A        final ProjectId properField = ProjectId.newBuilder()%0A                                               .setId(Identifiers.newUuid())%0A                                               .build();%0A        final ProjectCreated eventMsg = ProjectCreated.newBuilder()%0A                                                      .setProjectId(properField)%0A                                                      .build();%0A        final Event event = eventFactory.createEvent(eventMsg);%0A        final MatchesStreamQuery predicate = eventWith(FIELD_NAME, properField);%0A        assertTrue(predicate.apply(event));%0A    %7D%0A%0A    @Test%0A    public void not_match_improper_records() %7B%0A        final ProjectId properField = ProjectId.newBuilder()%0A                                               .setId(Identifiers.newUuid())%0A                                               .build();%0A        final ProjectId improperField = ProjectId.getDefaultInstance();%0A        final ProjectCreated eventMsg = ProjectCreated.newBuilder()%0A                                                      .setProjectId(improperField)%0A                                                      .build();%0A        final Event event = eventFactory.createEvent(eventMsg);%0A        final MatchesStreamQuery predicate = eventWith(FIELD_NAME, properField);%0A        assertFalse(predicate.apply(event));%0A    %7D%0A%0A    private static MatchesStreamQuery eventWith(String fieldPath, Message field) %7B%0A        final FieldFilter filter = FieldFilter.newBuilder()%0A                                              .setFieldPath(fieldPath)%0A                                              .addValue(AnyPacker.pack(field))%0A                                              .build();%0A        final EventFilter eventFilter = EventFilter.newBuilder()%0A                                                   .addEventFieldFilter(filter)%0A                                                   .build();%0A        final EventStreamQuery query = EventStreamQuery.newBuilder()%0A                                                       .addFilter(eventFilter)%0A                                                       .build();%0A        final MatchesStreamQuery predicate = new MatchesStreamQuery(query);%0A        return predicate;%0A    %7D%0A
 %0A%7D%0A

Add some tests for the `MatchesStreamQuery`.