package com.novoda.downloadmanager;

import android.support.annotation.Nullable;

class InternalDownloadBatchStatusFixtures {

    private DownloadBatchTitle downloadBatchTitle = DownloadBatchTitleFixtures.aDownloadBatchTitle().build();
    private int percentageDownloaded = 10;
    private long bytesDownloaded = 100;
    private long bytesTotalSize = 1000;
    private DownloadBatchId downloadBatchId = DownloadBatchIdFixtures.aDownloadBatchId().build();
    private DownloadBatchStatus.Status status = DownloadBatchStatus.Status.QUEUED;
    private DownloadError.Error downloadErrorType = null;

    static InternalDownloadBatchStatusFixtures anInternalDownloadsBatchStatus() {
        return new InternalDownloadBatchStatusFixtures();
    }

    InternalDownloadBatchStatusFixtures withDownloadBatchTitle(DownloadBatchTitle downloadBatchTitle) {
        this.downloadBatchTitle = downloadBatchTitle;
        return this;
    }

    InternalDownloadBatchStatusFixtures withPercentageDownloaded(int percentageDownloaded) {
        this.percentageDownloaded = percentageDownloaded;
        return this;
    }

    InternalDownloadBatchStatusFixtures withBytesDownloaded(long bytesDownloaded) {
        this.bytesDownloaded = bytesDownloaded;
        return this;
    }

    InternalDownloadBatchStatusFixtures withBytesTotalSize(long bytesTotalSize) {
        this.bytesTotalSize = bytesTotalSize;
        return this;
    }

    InternalDownloadBatchStatusFixtures withDownloadBatchId(DownloadBatchId downloadBatchId) {
        this.downloadBatchId = downloadBatchId;
        return this;
    }

    InternalDownloadBatchStatusFixtures withStatus(DownloadBatchStatus.Status status) {
        this.status = status;
        return this;
    }

    InternalDownloadBatchStatusFixtures withDownloadErrorType(DownloadError.Error downloadErrorType) {
        this.downloadErrorType = downloadErrorType;
        return this;
    }

    InternalDownloadBatchStatus build() {
        return new InternalDownloadBatchStatus() {

            @Override
            public DownloadBatchTitle getDownloadBatchTitle() {
                return downloadBatchTitle;
            }

            @Override
            public int percentageDownloaded() {
                return percentageDownloaded;
            }

            @Override
            public long bytesDownloaded() {
                return bytesDownloaded;
            }

            @Override
            public long bytesTotalSize() {
                return bytesTotalSize;
            }

            @Override
            public DownloadBatchId getDownloadBatchId() {
                return downloadBatchId;
            }

            @Override
            public Status status() {
                return status;
            }

            @Nullable
            @Override
            public DownloadError.Error getDownloadErrorType() {
                return downloadErrorType;
            }

            @Override
            public void update(long currentBytesDownloaded, long totalBatchSizeBytes) {
                // do nothing.
            }

            @Override
            public void markAsDownloading(DownloadsBatchStatusPersistence persistence) {
                // do nothing.
            }

            @Override
            public void markAsPaused(DownloadsBatchStatusPersistence persistence) {
                // do nothing.
            }

            @Override
            public void markAsQueued(DownloadsBatchStatusPersistence persistence) {
                // do nothing.
            }

            @Override
            public void markForDeletion() {
                // do nothing.
            }

            @Override
            public void markAsError(DownloadError downloadError, DownloadsBatchStatusPersistence persistence) {
                // do nothing.
            }

            @Override
            public void markAsDownloaded(DownloadsBatchStatusPersistence persistence) {
                // do nothing.
            }
        };
    }
}

@@ -3213,38 +3213,124 @@
             
-// do nothing.
+status = Status.DOWNLOADING;%0A                persistence.updateStatusAsync(downloadBatchId, status);
 %0A           
@@ -3451,38 +3451,119 @@
             
-// do nothing.
+status = Status.PAUSED;%0A                persistence.updateStatusAsync(downloadBatchId, status);
 %0A           
@@ -3684,38 +3684,119 @@
             
-// do nothing.
+status = Status.QUEUED;%0A                persistence.updateStatusAsync(downloadBatchId, status);
 %0A           
@@ -3877,38 +3877,49 @@
             
-// do nothing.
+status = Status.DELETION;
 %0A           
@@ -4068,38 +4068,177 @@
             
-// do nothing.
+status = Status.ERROR;%0A                downloadErrorType = downloadError.error();%0A                persistence.updateStatusAsync(downloadBatchId, status);
 %0A           
@@ -4363,38 +4363,123 @@
             
-// do nothing.
+status = Status.DOWNLOADED;%0A                persistence.updateStatusAsync(downloadBatchId, status);
 %0A           

Update InternalDownloadBatchStatusFixtures to include more appropriate logic.