/*
 * Copyright 2020, 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.server.model;

import com.google.common.collect.ImmutableSet;
import io.spine.server.model.given.external.TestCommander;
import io.spine.server.model.given.external.TestReactor;
import io.spine.server.model.given.external.TestSubscriber;
import io.spine.server.type.EventClass;
import io.spine.test.model.external.ExtProjectCreated;
import io.spine.test.model.external.ExtProjectStarted;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;

@DisplayName("`External` attribute can be declared")
class ExternalAttributeTest {

    @Nested
    @DisplayName("for `@Subscribe` methods")
    class Subscribe extends Suite {

        Subscribe() {
            super(new TestSubscriber().externalEventClasses());
        }
    }

    @Nested
    @DisplayName("for `@React` methods")
    class React extends Suite {

        React() {
            super(new TestReactor().externalEventClasses());
        }
    }

    @Nested
    @DisplayName("for `@Command` methods")
    class Command extends Suite {

        Command() {
            super(new TestCommander().externalEvents());
        }
    }

    @SuppressWarnings("AbstractClassWithoutAbstractMethods") // Makes JUnit ignore this class.
    abstract static class Suite {

        private final ImmutableSet<EventClass> externalEventClasses;

        Suite(ImmutableSet<EventClass> externalEventClasses) {
            this.externalEventClasses = checkNotNull(externalEventClasses);
        }

        @Test
        @DisplayName("via param annotation")
        void annotation() {
            assertThat(externalEventClasses)
                    .contains(EventClass.from(ExtProjectCreated.class));
        }

        @Test
        @DisplayName("via annotation attribute")
        void attribute() {
            assertThat(externalEventClasses)
                    .contains(EventClass.from(ExtProjectStarted.class));
        }
    }
}

@@ -1666,17 +1666,16 @@
 me(%22
-%60
 External
 %60 at
@@ -1674,19 +1674,23 @@
 rnal
-%60 attribute
+ method handler
  can
@@ -1765,19 +1765,20 @@
 ayName(%22
-for
+with
  %60@Subsc
@@ -1782,24 +1782,16 @@
 bscribe%60
- methods
 %22)%0A    c
@@ -1955,19 +1955,20 @@
 ayName(%22
-for
+with
  %60@React
@@ -1968,24 +1968,16 @@
 %60@React%60
- methods
 %22)%0A    c
@@ -2130,19 +2130,20 @@
 ayName(%22
-for
+with
  %60@Comma
@@ -2149,16 +2149,8 @@
 and%60
- methods
 %22)%0A 

Rephrase test names