// Path: src/main/java/mtsar/api/AnswerAggregation.java
// @FreeBuilder
// @XmlRootElement
// @JsonDeserialize(builder = AnswerAggregation.Builder.class)
// public interface AnswerAggregation {
//     String TYPE_DEFAULT = "aggregation";
//     String TYPE_EMPTY = "empty";
// 
//     static AnswerAggregation empty(Task task) {
//         return new Builder().setType(TYPE_EMPTY).setTask(task).build();
//     }
// 
//     @JsonProperty
//     String getType();
// 
//     @JsonProperty
//     Task getTask();
// 
//     @JsonProperty
//     List<String> getAnswers();
// 
//     @JsonPOJOBuilder(withPrefix = "set")
//     class Builder extends AnswerAggregation_Builder {
//         public Builder() {
//             setType(TYPE_DEFAULT);
//         }
//     }
// }
// 
// Path: src/main/java/mtsar/api/Task.java
// @FreeBuilder
// @XmlRootElement
// @JsonDeserialize(builder = Task.Builder.class)
// public interface Task {
//     @Nullable
//     @JsonProperty
//     Integer getId();
// 
//     @JsonProperty
//     String getStage();
// 
//     @JsonProperty
//     Timestamp getDateTime();
// 
//     @JsonProperty
//     List<String> getTags();
// 
//     @JsonIgnore
//     Map<String, String> getMetadata();
// 
//     @JsonProperty
//     String getType();
// 
//     @JsonProperty
//     String getDescription();
// 
//     @JsonProperty
//     List<String> getAnswers();
// 
//     @JsonIgnore
//     String getTagsTextArray();
// 
//     @JsonIgnore
//     String getMetadataJSON();
// 
//     @JsonIgnore
//     String getAnswersTextArray();
// 
//     @JsonPOJOBuilder(withPrefix = "set")
//     class Builder extends Task_Builder {
//         public Builder() {
//             setDateTime(DateTimeUtils.now());
//         }
// 
//         public Builder setMetadata(String json) {
//             return setMetadataJSON(json).putAllMetadata(PostgresUtils.parseJSONString(json));
//         }
// 
//         public Task build() {
//             setTagsTextArray(PostgresUtils.buildArrayString(getTags()));
//             setMetadataJSON(PostgresUtils.buildJSONString(getMetadata()));
//             setAnswersTextArray(PostgresUtils.buildArrayString(getAnswers()));
//             return super.build();
//         }
//     }
// }
// 
// Path: src/main/java/mtsar/processors/AnswerAggregator.java
// public interface AnswerAggregator {
//     /**
//      * Given a collection of tasks, an aggregator maps these tasks to the aggregated answers.
//      *
//      * @param tasks tasks.
//      * @return Aggregated answers.
//      */
//     @Nonnull
//     Map<Integer, AnswerAggregation> aggregate(@Nonnull Collection<Task> tasks);
// 
//     /**
//      * Given a task, an aggregator returns either an aggregated answer, or nothing.
//      * This is an alias for the method accepting the task collection.
//      *
//      * @param task task.
//      * @return Aggregated answer.
//      */
//     @Nonnull
//     default Optional<AnswerAggregation> aggregate(@Nonnull Task task) {
//         final Map<Integer, AnswerAggregation> aggregations = aggregate(Collections.singletonList(task));
//         if (aggregations.isEmpty()) return Optional.empty();
//         return Optional.of(aggregations.get(task.getId()));
//     }
// }
// 
// Path: src/test/java/mtsar/TestHelper.java
// public static <T> T fixture(String filename, Class<T> valueType) {
//     try {
//         return JSON.readValue(FixtureHelpers.fixture("fixtures/" + filename), valueType);
//     } catch (IOException e) {
//         throw new RuntimeException(e);
//     }
// }


import mtsar.api.AnswerAggregation;
import mtsar.api.Task;
import mtsar.processors.AnswerAggregator;
import org.junit.Test;
import java.util.Optional;
import static mtsar.TestHelper.fixture;
import static org.assertj.core.api.Assertions.assertThat;
/*
 * Copyright 2015 Dmitry Ustalov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package mtsar.processors.answer;




public class EmptyAggregatorTest {
    private static final Task task = fixture("task1.json", Task.class);
    private static final AnswerAggregator aggregator = new EmptyAggregator();

    @Test
    public void testEmptyCase() {
// Path: src/main/java/mtsar/api/AnswerAggregation.java
// @FreeBuilder
// @XmlRootElement
// @JsonDeserialize(builder = AnswerAggregation.Builder.class)
// public interface AnswerAggregation {
//     String TYPE_DEFAULT = "aggregation";
//     String TYPE_EMPTY = "empty";
// 
//     static AnswerAggregation empty(Task task) {
//         return new Builder().setType(TYPE_EMPTY).setTask(task).build();
//     }
// 
//     @JsonProperty
//     String getType();
// 
//     @JsonProperty
//     Task getTask();
// 
//     @JsonProperty
//     List<String> getAnswers();
// 
//     @JsonPOJOBuilder(withPrefix = "set")
//     class Builder extends AnswerAggregation_Builder {
//         public Builder() {
//             setType(TYPE_DEFAULT);
//         }
//     }
// }
// 
// Path: src/main/java/mtsar/api/Task.java
// @FreeBuilder
// @XmlRootElement
// @JsonDeserialize(builder = Task.Builder.class)
// public interface Task {
//     @Nullable
//     @JsonProperty
//     Integer getId();
// 
//     @JsonProperty
//     String getStage();
// 
//     @JsonProperty
//     Timestamp getDateTime();
// 
//     @JsonProperty
//     List<String> getTags();
// 
//     @JsonIgnore
//     Map<String, String> getMetadata();
// 
//     @JsonProperty
//     String getType();
// 
//     @JsonProperty
//     String getDescription();
// 
//     @JsonProperty
//     List<String> getAnswers();
// 
//     @JsonIgnore
//     String getTagsTextArray();
// 
//     @JsonIgnore
//     String getMetadataJSON();
// 
//     @JsonIgnore
//     String getAnswersTextArray();
// 
//     @JsonPOJOBuilder(withPrefix = "set")
//     class Builder extends Task_Builder {
//         public Builder() {
//             setDateTime(DateTimeUtils.now());
//         }
// 
//         public Builder setMetadata(String json) {
//             return setMetadataJSON(json).putAllMetadata(PostgresUtils.parseJSONString(json));
//         }
// 
//         public Task build() {
//             setTagsTextArray(PostgresUtils.buildArrayString(getTags()));
//             setMetadataJSON(PostgresUtils.buildJSONString(getMetadata()));
//             setAnswersTextArray(PostgresUtils.buildArrayString(getAnswers()));
//             return super.build();
//         }
//     }
// }
// 
// Path: src/main/java/mtsar/processors/AnswerAggregator.java
// public interface AnswerAggregator {
//     /**
//      * Given a collection of tasks, an aggregator maps these tasks to the aggregated answers.
//      *
//      * @param tasks tasks.
//      * @return Aggregated answers.
//      */
//     @Nonnull
//     Map<Integer, AnswerAggregation> aggregate(@Nonnull Collection<Task> tasks);
// 
//     /**
//      * Given a task, an aggregator returns either an aggregated answer, or nothing.
//      * This is an alias for the method accepting the task collection.
//      *
//      * @param task task.
//      * @return Aggregated answer.
//      */
//     @Nonnull
//     default Optional<AnswerAggregation> aggregate(@Nonnull Task task) {
//         final Map<Integer, AnswerAggregation> aggregations = aggregate(Collections.singletonList(task));
//         if (aggregations.isEmpty()) return Optional.empty();
//         return Optional.of(aggregations.get(task.getId()));
//     }
// }
// 
// Path: src/test/java/mtsar/TestHelper.java
// public static <T> T fixture(String filename, Class<T> valueType) {
//     try {
//         return JSON.readValue(FixtureHelpers.fixture("fixtures/" + filename), valueType);
//     } catch (IOException e) {
//         throw new RuntimeException(e);
//     }
// }


// Path: src/test/java/mtsar/processors/answer/EmptyAggregatorTest.java
import mtsar.api.AnswerAggregation;
import mtsar.api.Task;
import mtsar.processors.AnswerAggregator;
import org.junit.Test;
import java.util.Optional;
import static mtsar.TestHelper.fixture;
import static org.assertj.core.api.Assertions.assertThat;

/*
 * Copyright 2015 Dmitry Ustalov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package mtsar.processors.answer;




public class EmptyAggregatorTest {
    private static final Task task = fixture("task1.json", Task.class);
    private static final AnswerAggregator aggregator = new EmptyAggregator();

    @Test
    public void testEmptyCase() {
        final Optional<AnswerAggregation> winner = aggregator.aggregate(task);