/*
 * Copyright 2018, 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.system.server;

import io.spine.client.QueryFactory;
import io.spine.server.aggregate.Aggregate;
import io.spine.testing.client.TestActorRequestFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

/**
 * @author Dmytro Dashenkov
 */
@DisplayName("MirrorRepository should")
class MirrorRepositoryTest {

    private MirrorRepository repository;
    private QueryFactory queries;

    @BeforeEach
    void setUp() {
        repository = new MirrorRepository();
        queries = TestActorRequestFactory.newInstance(MirrorRepositoryTest.class).query();
    }

    @Nested
    @DisplayName("on an aggregate query")
    class ExecuteQueries {

        @Nested
        @DisplayName("for a known type")
        class Known {

            @Test
            @DisplayName("find all instances")
            void includeAll() {

            }
        }

        @Test
        @DisplayName("for an unknown type")
        void unknown() {

        }
    }

    private void prepareAggreagtes(Aggregate<?, ?, ?>... aggregates) {

    }
}

@@ -1050,36 +1050,175 @@
 ort 
-io.spine.client.QueryFactory
+com.google.protobuf.Any;%0Aimport com.google.protobuf.Timestamp;%0Aimport io.spine.client.Query;%0Aimport io.spine.client.QueryFactory;%0Aimport io.spine.server.BoundedContext
 ;%0Aim
@@ -1471,16 +1471,227 @@
 .Test;%0A%0A
+import java.util.Iterator;%0A%0Aimport static io.spine.system.server.SystemBoundedContexts.systemOf;%0Aimport static org.junit.jupiter.api.Assertions.assertFalse;%0Aimport static org.junit.jupiter.api.Assertions.fail;%0A%0A
 /**%0A * @
@@ -1911,42 +1911,317 @@
     
-repository = new MirrorRepository(
+BoundedContext domainContext = BoundedContext.newBuilder().build();%0A        BoundedContext systemContext = systemOf(domainContext);%0A        repository = (MirrorRepository) systemContext%0A                .findRepository(Mirror.class)%0A                .orElseGet(() -%3E fail(%22MirrorRepository must be registered.%22)
 );%0A 
@@ -2681,24 +2681,185 @@
 unknown() %7B%0A
+            Query query = queries.all(Timestamp.class);%0A%0A            Iterator%3CAny%3E result = repository.execute(query);%0A            assertFalse(result.hasNext());
 %0A        %7D%0A 

Add a test for an unknown type query.