// Path: berserker-commons/src/main/java/io/smartcat/berserker/api/DataSource.java
// public interface DataSource<T> {
// 
//     /**
//      * Returns true if data source can provide next value, otherwise false.
//      *
//      * @param time Relative time in nanoseconds from starting load generator. Time can be used for implementing time
//      *            dependent data source which can then return data with time stamps and/or data influenced by time in
//      *            any other way.
//      * @return True if data source can provide next value, otherwise false.
//      */
//     boolean hasNext(long time);
// 
//     /**
//      * Returns next value from this data source.
//      *
//      * @param time Relative time in nanoseconds from starting load generator. Time can be used for implementing time
//      *            dependent data source which can then return data with time stamps and/or data influenced by time in
//      *            any other way.
//      * @return Next value from this data source.
//      */
//     T getNext(long time);
// }
// 
// Path: berserker-core/src/main/java/io/smartcat/berserker/datasource/RandomIntDataSource.java
// public class RandomIntDataSource implements DataSource<Integer> {
// 
//     private final Iterator<Integer> it = new SplittableRandom().ints().iterator();
// 
//     @Override
//     public boolean hasNext(long time) {
//         return true;
//     }
// 
//     @Override
//     public Integer getNext(long time) {
//         return it.next();
//     }
// }
// 
// Path: berserker-core/src/main/java/io/smartcat/berserker/rategenerator/ConstantRateGenerator.java
// public class ConstantRateGenerator implements RateGenerator {
// 
//     private final double perSecondRate;
// 
//     /**
//      * Constructs rate generator with specified <code>perSecondRate</code>.
//      *
//      * @param perSecondRate Rate of the rate generator per second, must be positive number.
//      */
//     public ConstantRateGenerator(double perSecondRate) {
//         if (perSecondRate <= 0) {
//             throw new IllegalArgumentException("Rate must be positive number.");
//         }
//         this.perSecondRate = perSecondRate;
//     }
// 
//     @Override
//     public double getRate(long time) {
//         return perSecondRate;
//     }
// }


import java.util.concurrent.atomic.AtomicLong;
import org.junit.Assert;
import org.junit.Test;
import io.smartcat.berserker.api.DataSource;
import io.smartcat.berserker.datasource.RandomIntDataSource;
import io.smartcat.berserker.rategenerator.ConstantRateGenerator;
package io.smartcat.berserker;




public class LoadGeneratorTest {

    private static final long DEFAULT_TEST_TIMEOUT = 3000;

    @Test(timeout = DEFAULT_TEST_TIMEOUT)
    public void loadGenerator_should_be_terminated_when_terminate_signal_is_sent() {
        // GIVEN
// Path: berserker-commons/src/main/java/io/smartcat/berserker/api/DataSource.java
// public interface DataSource<T> {
// 
//     /**
//      * Returns true if data source can provide next value, otherwise false.
//      *
//      * @param time Relative time in nanoseconds from starting load generator. Time can be used for implementing time
//      *            dependent data source which can then return data with time stamps and/or data influenced by time in
//      *            any other way.
//      * @return True if data source can provide next value, otherwise false.
//      */
//     boolean hasNext(long time);
// 
//     /**
//      * Returns next value from this data source.
//      *
//      * @param time Relative time in nanoseconds from starting load generator. Time can be used for implementing time
//      *            dependent data source which can then return data with time stamps and/or data influenced by time in
//      *            any other way.
//      * @return Next value from this data source.
//      */
//     T getNext(long time);
// }
// 
// Path: berserker-core/src/main/java/io/smartcat/berserker/datasource/RandomIntDataSource.java
// public class RandomIntDataSource implements DataSource<Integer> {
// 
//     private final Iterator<Integer> it = new SplittableRandom().ints().iterator();
// 
//     @Override
//     public boolean hasNext(long time) {
//         return true;
//     }
// 
//     @Override
//     public Integer getNext(long time) {
//         return it.next();
//     }
// }
// 
// Path: berserker-core/src/main/java/io/smartcat/berserker/rategenerator/ConstantRateGenerator.java
// public class ConstantRateGenerator implements RateGenerator {
// 
//     private final double perSecondRate;
// 
//     /**
//      * Constructs rate generator with specified <code>perSecondRate</code>.
//      *
//      * @param perSecondRate Rate of the rate generator per second, must be positive number.
//      */
//     public ConstantRateGenerator(double perSecondRate) {
//         if (perSecondRate <= 0) {
//             throw new IllegalArgumentException("Rate must be positive number.");
//         }
//         this.perSecondRate = perSecondRate;
//     }
// 
//     @Override
//     public double getRate(long time) {
//         return perSecondRate;
//     }
// }


// Path: berserker-core/src/test/java/io/smartcat/berserker/LoadGeneratorTest.java
import java.util.concurrent.atomic.AtomicLong;
import org.junit.Assert;
import org.junit.Test;
import io.smartcat.berserker.api.DataSource;
import io.smartcat.berserker.datasource.RandomIntDataSource;
import io.smartcat.berserker.rategenerator.ConstantRateGenerator;

package io.smartcat.berserker;




public class LoadGeneratorTest {

    private static final long DEFAULT_TEST_TIMEOUT = 3000;

    @Test(timeout = DEFAULT_TEST_TIMEOUT)
    public void loadGenerator_should_be_terminated_when_terminate_signal_is_sent() {
        // GIVEN
        LoadGenerator<Integer> loadGenerator = new LoadGenerator<>(new RandomIntDataSource(),