/*
 * 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.io;

import org.junit.Test;

import static org.junit.Assert.assertNotNull;
import static org.spine3.test.Tests.assertHasPrivateParameterlessCtor;

/**
 * @author Alex Tymchenko
 */
public class StreamObserversShould {

    @Test
    public void have_utility_ctor() {
        assertHasPrivateParameterlessCtor(StreamObservers.class);
    }

    @Test
    public void return_non_null_empty_observer() {
        assertNotNull(StreamObservers.noOpObserver());
    }
}

@@ -1044,69 +1044,306 @@
 ort 
-org.junit.Test;%0A%0Aimport static org.junit.Assert.assertNotNull
+io.grpc.stub.StreamObserver;%0Aimport org.junit.Test;%0Aimport org.mockito.ArgumentMatchers;%0A%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.never;%0Aimport static org.mockito.Mockito.times;%0Aimport static org.mockito.Mockito.verify
 ;%0Aim
@@ -1726,11 +1726,799 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void create_proper_error_forwarding_observer() %7B%0A        @SuppressWarnings(%22unchecked%22)  // to make the mock creation look simpler.%0A        final StreamObserver%3CObject%3E delegate = mock(StreamObserver.class);%0A%0A        final StreamObserver%3CObject%3E forwardingInstance = StreamObservers.forwardErrorsOnly(%0A                delegate);%0A%0A        forwardingInstance.onNext(new Object());%0A        forwardingInstance.onCompleted();%0A        final RuntimeException errorToForward = new RuntimeException(%22Sample exception%22);%0A        forwardingInstance.onError(errorToForward);%0A%0A        verify(delegate, times(1)).onError(ArgumentMatchers.eq(errorToForward));%0A        verify(delegate, never()).onNext(ArgumentMatchers.any());%0A        verify(delegate, never()).onCompleted();%0A    %7D
 %0A%7D%0A

Test error-forwarding `StreamObserver`.