// Path: src/main/java/org/codelibs/fess/suggest/exception/SuggesterException.java
// public class SuggesterException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public SuggesterException(final String msg) {
//         super(msg);
//     }
// 
//     public SuggesterException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public SuggesterException(final String msg, final Throwable cause) {
//         super(msg, cause);
//     }
// }
// 
// Path: src/main/java/org/codelibs/fess/suggest/request/suggest/SuggestResponse.java
// public class SuggestResponse implements Response {
//     protected final String index;
// 
//     protected final long tookMs;
// 
//     protected final List<String> words;
// 
//     protected final int num;
// 
//     protected final long total;
// 
//     protected final List<SuggestItem> items;
// 
//     public SuggestResponse(final String index, final long tookMs, final List<String> words, final long total,
//             final List<SuggestItem> items) {
//         this.index = index;
//         this.tookMs = tookMs;
//         this.words = words;
//         this.num = words.size();
//         this.total = total;
//         this.items = items;
//     }
// 
//     public String getIndex() {
//         return index;
//     }
// 
//     public long getTookMs() {
//         return tookMs;
//     }
// 
//     public List<String> getWords() {
//         return words;
//     }
// 
//     public int getNum() {
//         return num;
//     }
// 
//     public long getTotal() {
//         return total;
//     }
// 
//     public List<SuggestItem> getItems() {
//         return items;
//     }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.codelibs.fess.suggest.exception.SuggesterException;
import org.codelibs.fess.suggest.request.suggest.SuggestResponse;
import org.junit.Test;
            deferred.resolve(new SuggestResponse("", 0, Collections.emptyList(), 0, null));
        });
        th.start();

        SuggestResponse response = deferred.promise().getResponse(10, TimeUnit.SECONDS);
        assertEquals(0, response.getNum());
    }

    @Test
    public void test_getResponseAfterResolve() throws Exception {
        final Deferred<SuggestResponse> deferred = new Deferred<>();

        Thread th = new Thread(() -> {
            deferred.resolve(new SuggestResponse("", 0, Collections.emptyList(), 0, null));
        });
        th.start();

        Thread.sleep(1000);
        SuggestResponse response = deferred.promise().getResponse(10, TimeUnit.SECONDS);
        assertEquals(0, response.getNum());
    }

    @Test
    public void test_getResponseWithException() throws Exception {
        final Deferred<SuggestResponse> deferred = new Deferred<>();

        Thread th = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ignore) {}
// Path: src/main/java/org/codelibs/fess/suggest/exception/SuggesterException.java
// public class SuggesterException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public SuggesterException(final String msg) {
//         super(msg);
//     }
// 
//     public SuggesterException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public SuggesterException(final String msg, final Throwable cause) {
//         super(msg, cause);
//     }
// }
// 
// Path: src/main/java/org/codelibs/fess/suggest/request/suggest/SuggestResponse.java
// public class SuggestResponse implements Response {
//     protected final String index;
// 
//     protected final long tookMs;
// 
//     protected final List<String> words;
// 
//     protected final int num;
// 
//     protected final long total;
// 
//     protected final List<SuggestItem> items;
// 
//     public SuggestResponse(final String index, final long tookMs, final List<String> words, final long total,
//             final List<SuggestItem> items) {
//         this.index = index;
//         this.tookMs = tookMs;
//         this.words = words;
//         this.num = words.size();
//         this.total = total;
//         this.items = items;
//     }
// 
//     public String getIndex() {
//         return index;
//     }
// 
//     public long getTookMs() {
//         return tookMs;
//     }
// 
//     public List<String> getWords() {
//         return words;
//     }
// 
//     public int getNum() {
//         return num;
//     }
// 
//     public long getTotal() {
//         return total;
//     }
// 
//     public List<SuggestItem> getItems() {
//         return items;
//     }
// }


// Path: src/test/java/org/codelibs/fess/suggest/concurrent/DeferredTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.codelibs.fess.suggest.exception.SuggesterException;
import org.codelibs.fess.suggest.request.suggest.SuggestResponse;
import org.junit.Test;

            deferred.resolve(new SuggestResponse("", 0, Collections.emptyList(), 0, null));
        });
        th.start();

        SuggestResponse response = deferred.promise().getResponse(10, TimeUnit.SECONDS);
        assertEquals(0, response.getNum());
    }

    @Test
    public void test_getResponseAfterResolve() throws Exception {
        final Deferred<SuggestResponse> deferred = new Deferred<>();

        Thread th = new Thread(() -> {
            deferred.resolve(new SuggestResponse("", 0, Collections.emptyList(), 0, null));
        });
        th.start();

        Thread.sleep(1000);
        SuggestResponse response = deferred.promise().getResponse(10, TimeUnit.SECONDS);
        assertEquals(0, response.getNum());
    }

    @Test
    public void test_getResponseWithException() throws Exception {
        final Deferred<SuggestResponse> deferred = new Deferred<>();

        Thread th = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ignore) {}
            deferred.reject(new SuggesterException("test"));