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

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static io.spine.examples.todolist.action.Action.getShortcutFormat;
import static io.spine.examples.todolist.action.Action.getShortcutNameSeparator;
import static java.lang.String.format;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
 * @author Dmytro Grankin
 */
@DisplayName("Action should")
class ActionTest {

    private static final String ACTION_NAME = "action";
    private static final Shortcut SHORTCUT = new Shortcut("s");
    private static final Action action = new ActionImpl(ACTION_NAME, SHORTCUT);

    @Test
    @DisplayName("not allow null or empty name")
    void notAllowEmptyStrings() {
        final String emptyString = "";
        assertThrows(IllegalArgumentException.class, () -> new ActionImpl(emptyString, SHORTCUT));
        assertThrows(IllegalArgumentException.class, () -> new ActionImpl(null, SHORTCUT));
    }

    @Test
    @DisplayName("consider an action with same shortcut equal")
    void overrideEqualsAndHashCode() {
        final Action firstAction = action;
        final String differentName = action.getName() + "difference";
        final Action secondAction = new ActionImpl(differentName, action.getShortcut());
        assertEquals(firstAction, secondAction);
        assertEquals(firstAction.hashCode(), secondAction.hashCode());
    }

    @Test
    @DisplayName("override `toString`")
    void overrideToString() {
        final String formattedShortcut = format(getShortcutFormat(), SHORTCUT.getValue());
        final String expectedString = formattedShortcut + getShortcutNameSeparator() + ACTION_NAME;
        assertEquals(expectedString, action.toString());
    }

    private static class ActionImpl extends Action {

        private ActionImpl(String name, Shortcut shortcut) {
            super(name, shortcut);
        }

        @Override
        public void execute() {
        }
    }
}

@@ -1698,26 +1698,24 @@
 n = new 
+An
 Action
-Impl
 (ACTION_
@@ -1927,26 +1927,24 @@
  -%3E new 
+An
 Action
-Impl
 (emptySt
@@ -2024,26 +2024,24 @@
  -%3E new 
+An
 Action
-Impl
 (null, S
@@ -2324,26 +2324,24 @@
 n = new 
+An
 Action
-Impl
 (differe
@@ -2858,26 +2858,24 @@
 c class 
+An
 Action
-Impl
  extends
@@ -2905,18 +2905,16 @@
 ate 
+An
 Action
-Impl
 (Str

Improve name of the class used in the test