// Path: GroundControl/groundcontrol/src/main/java/com/bottlerocketstudios/groundcontrol/executor/IdSequence.java
// public class IdSequence {
// 
//     private static final long FIRST_ID = 1;
// 
//     //Object is used for a synchronize lock to prevent other Threads from getting the same ID.
//     @SuppressWarnings("FieldCanBeLocal")
//     private final String mLock = "IdSequenceLock";
//     private long mLastId;
// 
//     public IdSequence() {
//         mLastId = FIRST_ID;
//     }
// 
//     public long getNext() {
//         long nextId;
//         synchronized (mLock) {
//             if (mLastId < Long.MAX_VALUE) {
//                 nextId = mLastId + 1;
//             } else {
//                 nextId = FIRST_ID;
//             }
//             mLastId = nextId;
//         }
//         return nextId;
//     }
// 
// }
// 
// Path: GroundControl/groundcontrol/src/main/java/com/bottlerocketstudios/groundcontrol/executor/Job.java
// public class Job {
//     private final long mId;
//     private JobPriority mPriority;
//     private final Runnable mRunnable;
//     private final long mMaximumExecutionTimeMs;
//     private JobExecutionListener mJobExecutionListener;
// 
//     private volatile int mHashCode;
// 
//     public Job(long id, Runnable runnable, long maximumExecutionTimeMs, JobPriority jobPriority) {
//         mId = id;
//         mRunnable = runnable;
//         mPriority = jobPriority;
//         mMaximumExecutionTimeMs = maximumExecutionTimeMs;
//     }
// 
//     public Job(long id, Runnable runnable, long maximumExecutionTimeMs) {
//         this(id, runnable, maximumExecutionTimeMs, JobPriority.NORMAL);
//     }
// 
//     public JobPriority getPriority() {
//         return mPriority;
//     }
// 
//     public void setPriority(JobPriority priority) {
//         mPriority = priority;
//     }
// 
//     public Runnable getRunnable() {
//         return mRunnable;
//     }
// 
//     public long getId() {
//         return mId;
//     }
// 
//     public long getMaximumExecutionTimeMs() {
//         return mMaximumExecutionTimeMs;
//     }
// 
//     public void setJobExecutionListener(JobExecutionListener jobExecutionListener) {
//         mJobExecutionListener = jobExecutionListener;
//     }
// 
//     public void notifyJobExecuted() {
//         if (mJobExecutionListener != null) {
//             mJobExecutionListener.onJobExecuted(this);
//         }
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (o instanceof Job) {
//             return this.getId() == ((Job) o).getId();
//         } else if (o instanceof RunningJob) {
//             return this.getId() == ((RunningJob) o).getJobId();
//         }
//         return super.equals(o);
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = mHashCode;
//         if (result == 0) {
//             result = (new HashBuilder()).addHashLong(getId()).build();
//             mHashCode = result;
//         }
//         return result;
//     }
// }
// 
// Path: GroundControl/groundcontrol/src/main/java/com/bottlerocketstudios/groundcontrol/executor/JobPriority.java
// public enum JobPriority {
//     IMMEDIATE,
//     HIGH,
//     NORMAL,
//     LOW
// }


import android.util.Log;
import com.bottlerocketstudios.groundcontrol.executor.IdSequence;
import com.bottlerocketstudios.groundcontrol.executor.Job;
import com.bottlerocketstudios.groundcontrol.executor.JobPriority;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/*
 * Copyright (c) 2016. Bottle Rocket LLC
 * 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 com.bottlerocketstudios.groundcontrol.test.executor;




public class JobUtils {

    public static List<Job> createRandomJobs(IdSequence idSequence, int jobCount, JobPriority priority, long minimumRunnableTimeMs, int maxRunnableDeviationMs, long maxProcessingTime) {
        List<Job> jobList = new ArrayList<>(jobCount);
        for (int i = 0; i < jobCount; i++) {
            Job job = new Job(idSequence.getNext(), new JunkRunnable(minimumRunnableTimeMs, maxRunnableDeviationMs), maxProcessingTime);
            job.setPriority(priority);
            jobList.add(job);
        }
// Path: GroundControl/groundcontrol/src/main/java/com/bottlerocketstudios/groundcontrol/executor/IdSequence.java
// public class IdSequence {
// 
//     private static final long FIRST_ID = 1;
// 
//     //Object is used for a synchronize lock to prevent other Threads from getting the same ID.
//     @SuppressWarnings("FieldCanBeLocal")
//     private final String mLock = "IdSequenceLock";
//     private long mLastId;
// 
//     public IdSequence() {
//         mLastId = FIRST_ID;
//     }
// 
//     public long getNext() {
//         long nextId;
//         synchronized (mLock) {
//             if (mLastId < Long.MAX_VALUE) {
//                 nextId = mLastId + 1;
//             } else {
//                 nextId = FIRST_ID;
//             }
//             mLastId = nextId;
//         }
//         return nextId;
//     }
// 
// }
// 
// Path: GroundControl/groundcontrol/src/main/java/com/bottlerocketstudios/groundcontrol/executor/Job.java
// public class Job {
//     private final long mId;
//     private JobPriority mPriority;
//     private final Runnable mRunnable;
//     private final long mMaximumExecutionTimeMs;
//     private JobExecutionListener mJobExecutionListener;
// 
//     private volatile int mHashCode;
// 
//     public Job(long id, Runnable runnable, long maximumExecutionTimeMs, JobPriority jobPriority) {
//         mId = id;
//         mRunnable = runnable;
//         mPriority = jobPriority;
//         mMaximumExecutionTimeMs = maximumExecutionTimeMs;
//     }
// 
//     public Job(long id, Runnable runnable, long maximumExecutionTimeMs) {
//         this(id, runnable, maximumExecutionTimeMs, JobPriority.NORMAL);
//     }
// 
//     public JobPriority getPriority() {
//         return mPriority;
//     }
// 
//     public void setPriority(JobPriority priority) {
//         mPriority = priority;
//     }
// 
//     public Runnable getRunnable() {
//         return mRunnable;
//     }
// 
//     public long getId() {
//         return mId;
//     }
// 
//     public long getMaximumExecutionTimeMs() {
//         return mMaximumExecutionTimeMs;
//     }
// 
//     public void setJobExecutionListener(JobExecutionListener jobExecutionListener) {
//         mJobExecutionListener = jobExecutionListener;
//     }
// 
//     public void notifyJobExecuted() {
//         if (mJobExecutionListener != null) {
//             mJobExecutionListener.onJobExecuted(this);
//         }
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (o instanceof Job) {
//             return this.getId() == ((Job) o).getId();
//         } else if (o instanceof RunningJob) {
//             return this.getId() == ((RunningJob) o).getJobId();
//         }
//         return super.equals(o);
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = mHashCode;
//         if (result == 0) {
//             result = (new HashBuilder()).addHashLong(getId()).build();
//             mHashCode = result;
//         }
//         return result;
//     }
// }
// 
// Path: GroundControl/groundcontrol/src/main/java/com/bottlerocketstudios/groundcontrol/executor/JobPriority.java
// public enum JobPriority {
//     IMMEDIATE,
//     HIGH,
//     NORMAL,
//     LOW
// }


// Path: GroundControl/groundcontrol/src/androidTest/java/com/bottlerocketstudios/groundcontrol/test/executor/JobUtils.java
import android.util.Log;
import com.bottlerocketstudios.groundcontrol.executor.IdSequence;
import com.bottlerocketstudios.groundcontrol.executor.Job;
import com.bottlerocketstudios.groundcontrol.executor.JobPriority;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/*
 * Copyright (c) 2016. Bottle Rocket LLC
 * 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 com.bottlerocketstudios.groundcontrol.test.executor;




public class JobUtils {

    public static List<Job> createRandomJobs(IdSequence idSequence, int jobCount, JobPriority priority, long minimumRunnableTimeMs, int maxRunnableDeviationMs, long maxProcessingTime) {
        List<Job> jobList = new ArrayList<>(jobCount);
        for (int i = 0; i < jobCount; i++) {
            Job job = new Job(idSequence.getNext(), new JunkRunnable(minimumRunnableTimeMs, maxRunnableDeviationMs), maxProcessingTime);
            job.setPriority(priority);
            jobList.add(job);
        }
        return jobList;