/*
 * Copyright 2016, 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 org.spine3.examples.todolist.LabelColor;
import org.spine3.examples.todolist.LabelDetails;
import org.spine3.examples.todolist.LabelList;
import org.spine3.examples.todolist.TaskDetails;
import org.spine3.examples.todolist.TaskId;
import org.spine3.examples.todolist.TaskLabelId;
import org.spine3.examples.todolist.TaskPriority;
import org.spine3.server.event.enrich.EventEnricher;

import java.util.function.Function;

import static org.spine3.examples.todolist.testdata.TestEventFactory.LABEL_ID;

/**
 * Provides event enricher for test needs.
 *
 * @author Illia Shepilov
 */
public class TestEventEnricherFactory {

    public static final String LABEL_TITLE = "title";
    private static final LabelDetails LABEL_DETAILS = LabelDetails.newBuilder()
                                                                  .setTitle(LABEL_TITLE)
                                                                  .setColor(LabelColor.BLUE)
                                                                  .build();
    private static final TaskDetails TASK_DETAILS = TaskDetails.newBuilder()
                                                               .setDescription(LABEL_TITLE)
                                                               .setPriority(TaskPriority.LOW)
                                                               .build();

    private TestEventEnricherFactory() {
    }

    private static final Function<TaskLabelId, LabelDetails> LABEL_ID_TO_LABEL_DETAILS = labelId -> LABEL_DETAILS;

    private static final Function<TaskId, TaskDetails> TASK_ID_TO_TASK_DETAILS = taskId -> TASK_DETAILS;

    private static final Function<TaskId, LabelList> TASK_ID_TO_LABEL_ID_LIST = taskId -> LabelList.newBuilder()
                                                                                                   .addLabelId(LABEL_ID)
                                                                                                   .build();

    /**
     * Provides a pre-configured {@link EventEnricher} event instance.
     *
     * @return {@link EventEnricher}
     */
    public static EventEnricher eventEnricherInstance() {
        final EventEnricher result = EventEnricher.newBuilder()
                                                  .addFieldEnrichment(TaskLabelId.class,
                                                                      LabelDetails.class,
                                                                      LABEL_ID_TO_LABEL_DETAILS::apply)
                                                  .addFieldEnrichment(TaskId.class,
                                                                      TaskDetails.class,
                                                                      TASK_ID_TO_TASK_DETAILS::apply)
                                                  .addFieldEnrichment(TaskId.class,
                                                                      LabelList.class,
                                                                      TASK_ID_TO_LABEL_ID_LIST::apply)
                                                  .build();
        return result;
    }
}

@@ -1193,24 +1193,26 @@
 dolist.Label
+Id
 List;%0Aimport
@@ -2731,24 +2731,26 @@
 askId, Label
+Id
 List%3E TASK_I
@@ -2779,22 +2779,36 @@
 askId -%3E
+%0A           
  Label
+Id
 List.new
@@ -2844,182 +2844,30 @@
     
-                                                                            .addLabelId(LABEL_ID)%0A                                                                            
+.addLabelId(LABEL_ID)%0A
     
@@ -3866,16 +3866,18 @@
    Label
+Id
 List.cla

Renamed LabelList to LabelIdList