// Path: src/main/java/org/killbill/billing/plugin/meter/timeline/sources/SourceSamplesForTimestamp.java
// @SuppressWarnings("unchecked")
// public class SourceSamplesForTimestamp {
// 
//     private static final String KEY_SOURCE = "H";
//     private static final String KEY_CATEGORY = "V";
//     private static final String KEY_TIMESTAMP = "T";
//     private static final String KEY_SAMPLES = "S";
// 
//     private final Integer sourceId;
//     private final String category;
//     private final DateTime timestamp;
//     // A map from sample id to sample value for that timestamp
//     private final Map<Integer, ScalarSample> samples;
// 
//     public SourceSamplesForTimestamp(final int sourceId, final String category, final DateTime timestamp) {
//         this(sourceId, category, timestamp, new HashMap<Integer, ScalarSample>());
//     }
// 
//     @JsonCreator
//     public SourceSamplesForTimestamp(@JsonProperty(KEY_SOURCE) final Integer sourceId, @JsonProperty(KEY_CATEGORY) final String category,
//                                      @JsonProperty(KEY_TIMESTAMP) final DateTime timestamp, @JsonProperty(KEY_SAMPLES) final Map<Integer, ScalarSample> samples) {
//         this.sourceId = sourceId;
//         this.category = category;
//         this.timestamp = timestamp;
//         this.samples = samples;
//     }
// 
//     public int getSourceId() {
//         return sourceId;
//     }
// 
//     public String getCategory() {
//         return category;
//     }
// 
//     public DateTime getTimestamp() {
//         return timestamp;
//     }
// 
//     public Map<Integer, ScalarSample> getSamples() {
//         return samples;
//     }
// 
//     @Override
//     public String toString() {
//         final StringBuilder sb = new StringBuilder();
//         sb.append("SourceSamplesForTimestamp");
//         sb.append("{category='").append(category).append('\'');
//         sb.append(", sourceId=").append(sourceId);
//         sb.append(", timestamp=").append(timestamp);
//         sb.append(", samples=").append(samples);
//         sb.append('}');
// 
//         return sb.toString();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
// 
//         final SourceSamplesForTimestamp that = (SourceSamplesForTimestamp) o;
// 
//         if (category != null ? !category.equals(that.category) : that.category != null) {
//             return false;
//         }
//         if (samples != null ? !samples.equals(that.samples) : that.samples != null) {
//             return false;
//         }
//         if (sourceId != null ? !sourceId.equals(that.sourceId) : that.sourceId != null) {
//             return false;
//         }
//         if (timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null) {
//             return false;
//         }
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = sourceId != null ? sourceId.hashCode() : 0;
//         result = 31 * result + (category != null ? category.hashCode() : 0);
//         result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0);
//         result = 31 * result + (samples != null ? samples.hashCode() : 0);
//         return result;
//     }
// 
//     @JsonValue
//     public Map<String, Object> toMap() {
//         return ImmutableMap.of(KEY_SOURCE, sourceId, KEY_CATEGORY, category, KEY_TIMESTAMP, timestamp, KEY_SAMPLES, samples);
//     }
// }


import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.killbill.billing.plugin.meter.MeterTestSuiteNoDB;
import org.killbill.billing.plugin.meter.timeline.sources.SourceSamplesForTimestamp;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
/*
 * Copyright 2010-2014 Ning, Inc.
 * Copyright 2014 The Billing Project, LLC
 *
 * Ning licenses this file to you 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 org.killbill.billing.plugin.meter.timeline.persistent;




public class TestReplayer extends MeterTestSuiteNoDB {

    private static final File basePath = new File(System.getProperty("java.io.tmpdir"), "TestReplayer-" + System.currentTimeMillis());

    private static final class MockReplayer extends Replayer {

        private final List<File> expectedFiles;
        private int seen = 0;

        public MockReplayer(final String path, final List<File> expectedFiles) {
            super(path);
            this.expectedFiles = expectedFiles;
        }

        @Override
// Path: src/main/java/org/killbill/billing/plugin/meter/timeline/sources/SourceSamplesForTimestamp.java
// @SuppressWarnings("unchecked")
// public class SourceSamplesForTimestamp {
// 
//     private static final String KEY_SOURCE = "H";
//     private static final String KEY_CATEGORY = "V";
//     private static final String KEY_TIMESTAMP = "T";
//     private static final String KEY_SAMPLES = "S";
// 
//     private final Integer sourceId;
//     private final String category;
//     private final DateTime timestamp;
//     // A map from sample id to sample value for that timestamp
//     private final Map<Integer, ScalarSample> samples;
// 
//     public SourceSamplesForTimestamp(final int sourceId, final String category, final DateTime timestamp) {
//         this(sourceId, category, timestamp, new HashMap<Integer, ScalarSample>());
//     }
// 
//     @JsonCreator
//     public SourceSamplesForTimestamp(@JsonProperty(KEY_SOURCE) final Integer sourceId, @JsonProperty(KEY_CATEGORY) final String category,
//                                      @JsonProperty(KEY_TIMESTAMP) final DateTime timestamp, @JsonProperty(KEY_SAMPLES) final Map<Integer, ScalarSample> samples) {
//         this.sourceId = sourceId;
//         this.category = category;
//         this.timestamp = timestamp;
//         this.samples = samples;
//     }
// 
//     public int getSourceId() {
//         return sourceId;
//     }
// 
//     public String getCategory() {
//         return category;
//     }
// 
//     public DateTime getTimestamp() {
//         return timestamp;
//     }
// 
//     public Map<Integer, ScalarSample> getSamples() {
//         return samples;
//     }
// 
//     @Override
//     public String toString() {
//         final StringBuilder sb = new StringBuilder();
//         sb.append("SourceSamplesForTimestamp");
//         sb.append("{category='").append(category).append('\'');
//         sb.append(", sourceId=").append(sourceId);
//         sb.append(", timestamp=").append(timestamp);
//         sb.append(", samples=").append(samples);
//         sb.append('}');
// 
//         return sb.toString();
//     }
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) {
//             return true;
//         }
//         if (o == null || getClass() != o.getClass()) {
//             return false;
//         }
// 
//         final SourceSamplesForTimestamp that = (SourceSamplesForTimestamp) o;
// 
//         if (category != null ? !category.equals(that.category) : that.category != null) {
//             return false;
//         }
//         if (samples != null ? !samples.equals(that.samples) : that.samples != null) {
//             return false;
//         }
//         if (sourceId != null ? !sourceId.equals(that.sourceId) : that.sourceId != null) {
//             return false;
//         }
//         if (timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null) {
//             return false;
//         }
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = sourceId != null ? sourceId.hashCode() : 0;
//         result = 31 * result + (category != null ? category.hashCode() : 0);
//         result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0);
//         result = 31 * result + (samples != null ? samples.hashCode() : 0);
//         return result;
//     }
// 
//     @JsonValue
//     public Map<String, Object> toMap() {
//         return ImmutableMap.of(KEY_SOURCE, sourceId, KEY_CATEGORY, category, KEY_TIMESTAMP, timestamp, KEY_SAMPLES, samples);
//     }
// }


// Path: src/test/java/org/killbill/billing/plugin/meter/timeline/persistent/TestReplayer.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.killbill.billing.plugin.meter.MeterTestSuiteNoDB;
import org.killbill.billing.plugin.meter.timeline.sources.SourceSamplesForTimestamp;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

/*
 * Copyright 2010-2014 Ning, Inc.
 * Copyright 2014 The Billing Project, LLC
 *
 * Ning licenses this file to you 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 org.killbill.billing.plugin.meter.timeline.persistent;




public class TestReplayer extends MeterTestSuiteNoDB {

    private static final File basePath = new File(System.getProperty("java.io.tmpdir"), "TestReplayer-" + System.currentTimeMillis());

    private static final class MockReplayer extends Replayer {

        private final List<File> expectedFiles;
        private int seen = 0;

        public MockReplayer(final String path, final List<File> expectedFiles) {
            super(path);
            this.expectedFiles = expectedFiles;
        }

        @Override
        public void read(final File file, final Function<SourceSamplesForTimestamp, Void> fn) throws IOException {