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

import io.spine.client.TestActorRequestFactory;
import io.spine.core.Command;
import io.spine.core.CommandClass;
import io.spine.core.CommandEnvelope;
import io.spine.core.MessageEnvelopeShould;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * @author Alexander Yevsyukov
 */
public class CommandEnvelopeShould extends MessageEnvelopeShould<Command,
        CommandEnvelope,
                                                                 CommandClass> {

    private final TestActorRequestFactory requestFactory =
            TestActorRequestFactory.newInstance(CommandEnvelopeShould.class);

    @Test
    public void obtain_command_context() {
        final Command command = outerObject();
        final CommandEnvelope envelope = toEnvelope(command);
        assertEquals(command.getContext(), envelope.getCommandContext());
    }

    @Override
    protected Command outerObject() {
        return requestFactory.generateCommand();
    }

    @Override
    protected CommandEnvelope toEnvelope(Command obj) {
        return CommandEnvelope.of(obj);
    }

    @Override
    protected CommandClass getMessageClass(Command obj) {
        return CommandClass.of(obj);
    }
}

@@ -1376,16 +1376,24 @@
 peShould
+%0A       
  extends
@@ -1423,24 +1423,16 @@
 Command,
-%0A       
  Command
@@ -1444,73 +1444,8 @@
 ope,
-%0A                                                                
  Com
@@ -1831,32 +1831,319 @@
 text());%0A    %7D%0A%0A
+    @Test%0A    public void obtain_actor_context() %7B%0A        final Command command = outerObject();%0A        final CommandEnvelope envelope = toEnvelope(command);%0A%0A        assertEquals(command.getContext()%0A                            .getActorContext(), envelope.getActorContext());%0A    %7D%0A%0A
     @Override%0A  

Test obtaining actor context