/*
 * Copyright 2020, 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.core;

import io.spine.server.event.EventFactory;
import io.spine.server.type.EventEnvelope;
import io.spine.server.type.given.GivenEvent;
import io.spine.testing.core.given.GivenUserId;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static com.google.common.truth.Truth.assertThat;
import static io.spine.protobuf.AnyPacker.pack;
import static io.spine.server.event.EventFactory.on;

/**
 * Extra tests for {@link Signal}s.
 *
 * <p>The main test suite for {@code Signal}s is located in the {@code core} module. This test suite
 * only hosts tests which rely on the components from the {@code server} module.
 */
@DisplayName("`Signal` also should")
class SignalTest {

    @Test
    @DisplayName("produce correct origin")
    void produceOrigin() {
        Event originalEvent = GivenEvent.arbitrary();
        UserId producerEntityId = GivenUserId.generated();
        EventFactory factory = on(EventEnvelope.of(originalEvent), pack(producerEntityId));
        Event derivativeEvent = factory.createEvent(GivenEvent.message(), null);
        Origin origin = derivativeEvent.getContext().getPastMessage();
        assertThat(origin.getMessage())
                .isEqualTo(originalEvent.messageId());
        assertThat(origin.hasGrandOrigin())
                .isFalse();
    }
}

@@ -1030,16 +1030,53 @@
 .core;%0A%0A
+import io.spine.base.CommandMessage;%0A
 import i
@@ -1247,16 +1247,46 @@
 UserId;%0A
+import io.spine.type.TypeUrl;%0A
 import o
@@ -2335,36 +2335,348 @@
 ));%0A        
-assertThat(o
+Origin grandOrigin = origin.getGrandOrigin();%0A        TypeUrl grandOriginType = TypeUrl.parse(grandOrigin.getMessage()%0A                                                           .getTypeUrl());%0A        assertThat(grandOriginType.toJavaClass())%0A                .isAssignableTo(CommandMessage.class);%0A        assertThat(grandO
 rigin.hasGra

Fix the test