/*
 * Copyright 2019, TeamDev. 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 io.spine.server.dispatch.given;

import io.spine.base.EventMessage;
import io.spine.base.RejectionMessage;
import io.spine.core.Event;
import io.spine.core.RejectionEventContext;
import io.spine.server.dispatch.DispatchOutcomeHandlerTest;
import io.spine.server.dispatch.given.event.DispatchCreated;
import io.spine.testing.TestValues;
import io.spine.testing.server.TestEventFactory;

import static io.spine.protobuf.TypeConverter.toAny;

public final class Given {

    public static final Id ID = Id.newBuilder()
                                  .setId(TestValues.randomString())
                                  .build();

    public static final TestEventFactory eventFactory =
            TestEventFactory.newInstance(toAny(Given.class.getSimpleName()),
                                         DispatchOutcomeHandlerTest.class);

    private Given() {
    }

    public static RejectionMessage cannotCreateDispatch() {
        return DispatchRejections.CannotCreateDispatch
                .newBuilder()
                .setId(ID)
                .build();
    }

    public static EventMessage dispatchCreated() {
        return DispatchCreated
                .newBuilder()
                .setId(ID)
                .build();
    }

    public static Event rejectionEvent() {
        RejectionEventContext rejectionContext = RejectionEventContext
                .newBuilder()
                .setStacktrace("at package.name.Class.method(Class.java:42)")
                .build();
        return eventFactory.createRejectionEvent(cannotCreateDispatch(), null, rejectionContext);
    }

    public static Event event() {
        return eventFactory.createEvent(dispatchCreated());
    }
}

@@ -1314,16 +1314,84 @@
 reated;%0A
+import io.spine.server.dispatch.given.rejection.DispatchRejections;%0A
 import i

Fix package