/*
 * 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.examples.todolist.testdata;

import com.google.common.collect.Maps;
import com.google.protobuf.Any;
import com.google.protobuf.Timestamp;
import org.spine3.base.CommandContext;
import org.spine3.base.Commands;
import org.spine3.base.Enrichments;
import org.spine3.base.EventContext;
import org.spine3.base.EventId;
import org.spine3.base.Events;
import org.spine3.examples.todolist.c.enrichments.DetailsEnrichment;
import org.spine3.examples.todolist.LabelColor;
import org.spine3.examples.todolist.LabelDetails;
import org.spine3.protobuf.AnyPacker;
import org.spine3.users.UserId;

import java.util.Map;

import static org.spine3.base.Identifiers.newUuid;
import static org.spine3.protobuf.Timestamps.getCurrentTime;
import static org.spine3.protobuf.Values.newStringValue;
import static org.spine3.test.Tests.newUserId;

/**
 * Provides event context instances for test needs.
 *
 * @author Illia Shepilov
 */
public class TestEventContextFactory {

    private static final String TITLE = "label title";
    private static final LabelColor COLOR = LabelColor.GREEN;
    private static final String ENRICHMENT_BY_LABEL_ID = "spine.examples.todolist.LabelDetailsByLabelIdEnrichment";
    private static final Any AGGREGATE_ID = AnyPacker.pack(newStringValue(newUuid()));

    private TestEventContextFactory() {
    }

    /**
     * Provides a new {@link EventContext} instance.
     *
     * <p> Created event context contains Enrichments.
     * <p> Enrichments contains label details by task ID and by label ID enrichments.
     *
     * @return {@link EventContext} instance
     */
    public static EventContext eventContextInstance() {
        final Enrichments enrichments = createEnrichments();
        final Timestamp now = getCurrentTime();
        final UserId userId = newUserId(newUuid());
        final CommandContext commandContext =
                TestCommandContextFactory.createCommandContext(userId, Commands.generateId(), now);
        final EventId eventId = Events.generateId();
        final EventContext.Builder builder = EventContext.newBuilder()
                                                         .setEnrichments(enrichments)
                                                         .setEventId(eventId)
                                                         .setCommandContext(commandContext)
                                                         .setProducerId(AGGREGATE_ID)
                                                         .setTimestamp(now);
        return builder.build();
    }

    private static Enrichments createEnrichments() {
        final LabelDetails.Builder labelDetails = LabelDetails.newBuilder()
                                                              .setTitle(TITLE)
                                                              .setColor(COLOR);
        final DetailsEnrichment labelDetailsEnrichment = DetailsEnrichment.newBuilder()
                                                                          .setLabelDetails(labelDetails)
                                                                          .build();
        final Map<String, Any> enrichmentsMap = Maps.newHashMap();
        enrichmentsMap.put(ENRICHMENT_BY_LABEL_ID, AnyPacker.pack(labelDetailsEnrichment));
        final Enrichments result = Enrichments.newBuilder()
                                              .putAllMap(enrichmentsMap)
                                              .build();
        return result;
    }
}

@@ -1062,47 +1062,8 @@
 a;%0A%0A
-import com.google.common.collect.Maps;%0A
 impo
@@ -1090,16 +1090,16 @@
 uf.Any;%0A
+
 import c
@@ -1204,44 +1204,8 @@
 ds;%0A
-import org.spine3.base.Enrichments;%0A
 impo
@@ -1304,175 +1304,8 @@
 ts;%0A
-import org.spine3.examples.todolist.c.enrichments.DetailsEnrichment;%0Aimport org.spine3.examples.todolist.LabelColor;%0Aimport org.spine3.examples.todolist.LabelDetails;%0A
 impo
@@ -1375,31 +1375,8 @@
 d;%0A%0A
-import java.util.Map;%0A%0A
 impo
@@ -1422,16 +1422,116 @@
 ewUuid;%0A
+import static org.spine3.examples.todolist.testdata.TestCommandContextFactory.createCommandContext;%0A
 import s
@@ -1821,241 +1821,8 @@
  %7B%0A%0A
-    private static final String TITLE = %22label title%22;%0A    private static final LabelColor COLOR = LabelColor.GREEN;%0A    private static final String ENRICHMENT_BY_LABEL_ID = %22spine.examples.todolist.LabelDetailsByLabelIdEnrichment%22;%0A
     
@@ -2281,69 +2281,8 @@
 ) %7B%0A
-        final Enrichments enrichments = createEnrichments();%0A
     
@@ -2426,51 +2426,9 @@
 xt =
-%0A                TestCommandContextFactory.
+ 
 crea
@@ -2609,94 +2609,8 @@
 r()%0A
-                                                         .setEnrichments(enrichments)%0A
     
@@ -2950,942 +2950,43 @@
     
-return builder.build();%0A    %7D%0A%0A    private static Enrichments createEnrichments() %7B%0A        final LabelDetails.Builder labelDetails = LabelDetails.newBuilder()%0A                                                              .setTitle(TITLE)%0A                                                              .setColor(COLOR);%0A        final DetailsEnrichment labelDetailsEnrichment = DetailsEnrichment.newBuilder()%0A                                                                          .setLabelDetails(labelDetails)%0A                                                                          .build();%0A        final Map%3CString, Any%3E enrichmentsMap = Maps.newHashMap();%0A        enrichmentsMap.put(ENRICHMENT_BY_LABEL_ID, AnyPacker.pack(labelDetailsEnrichment));%0A        final Enrichments result = Enrichments.newBuilder()%0A                                              .putAllMap(enrichmentsMap)%0A                                              
+final EventContext result = builder
 .bui

Remove useless method.