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

import com.google.protobuf.StringValue;
import io.spine.core.Command;
import io.spine.core.Event;
import io.spine.core.MessageId;
import io.spine.server.entity.rejection.StandardRejections;
import io.spine.test.aggregate.ProjectId;
import io.spine.test.aggregate.command.AggCreateProject;
import io.spine.testing.client.TestActorRequestFactory;
import io.spine.testing.server.TestEventFactory;
import io.spine.type.TypeUrl;

import static io.spine.base.Identifier.newUuid;
import static io.spine.protobuf.AnyPacker.pack;

public final class CoreMixinsTestEnv {

    /**
     * Prevents instantiation of this class.
     */
    private CoreMixinsTestEnv() {
    }

    public static MessageId messageId() {
        Event event = event();
        return MessageId
                .newBuilder()
                .setId(pack(event.getId()))
                .setTypeUrl(TypeUrl.of(event)
                                   .value())
                .setVersion(event.getContext()
                                 .getVersion())
                .build();
    }

    public static Command command() {
        TestActorRequestFactory factory = new TestActorRequestFactory(CoreMixinsTestEnv.class);
        ProjectId projectId = ProjectId.newBuilder()
                                       .setId(newUuid())
                                       .build();
        AggCreateProject cmdMessage = AggCreateProject.newBuilder()
                                                      .setProjectId(projectId)
                                                      .setName("A Project")
                                                      .build();
        return factory.createCommand(cmdMessage);
    }

    public static Event event() {
        TestEventFactory factory = TestEventFactory.newInstance(CoreMixinsTestEnv.class);
        StandardRejections.EntityAlreadyDeleted msg = StandardRejections.EntityAlreadyDeleted
                .newBuilder()
                .setEntityId(
                        pack(StringValue.of("deleted-entity-id")))
                .build();
        return factory.createEvent(msg);
    }
}

@@ -1251,59 +1251,13 @@
 est.
-aggregate.ProjectId;%0Aimport io.spine.test.aggregate
+mixin
 .com
@@ -1261,19 +1261,21 @@
 command.
-Agg
+Mixin
 CreatePr
@@ -2193,170 +2193,13 @@
     
-ProjectId projectId = ProjectId.newBuilder()%0A                                       .setId(newUuid())%0A                                       .build();%0A        Agg
+Mixin
 Crea
@@ -2225,11 +2225,13 @@
 e = 
-Agg
+Mixin
 Crea
@@ -2303,24 +2303,26 @@
             
+  
 .setProjectI
@@ -2327,19 +2327,32 @@
 tId(
-projectId)%0A
+newUuid().hashCode())%0A  
     
@@ -2423,16 +2423,18 @@
 oject%22)%0A
+  
         

Use test-specific command.