<commit_before>package com.novoda.downloadmanager.lib;

import android.app.DownloadManager;

import org.junit.Test;

import static org.fest.assertions.api.Assertions.assertThat;

public class DownloadsStatusTest {

    @Test
    public void whenVisibilityIsCompletedThenNotificationIsToBeDisplayed() {
        boolean toBeDisplayed = DownloadsStatus.isNotificationToBeDisplayed(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        assertThat(toBeDisplayed).isTrue();
    }

    @Test
    public void whenVisibilityIsOnlyCompletionThenNotificationIsToBeDisplayed() {
        boolean toBeDisplayed = DownloadsStatus.isNotificationToBeDisplayed(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION);
        assertThat(toBeDisplayed).isTrue();
    }

    @Test
    public void whenVisibilityIsHiddenThenNotificationIsNotBeDisplayed() {
        boolean toBeDisplayed = DownloadsStatus.isNotificationToBeDisplayed(DownloadManager.Request.VISIBILITY_HIDDEN);
        assertThat(toBeDisplayed).isFalse();
    }

    @Test
    public void whenStatusIs490ThenStatusIsCancelled() {
        boolean isCancelled = DownloadsStatus.isStatusCancelled(490);
        assertThat(isCancelled).isTrue();
    }

    @Test
    public void whenStatusIs4xxThenStatusIsClientError() {
        for (int i = 400; i < 500; i++) {
            assertThat(DownloadsStatus.isStatusClientError(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusClientError(399)).isFalse();
        assertThat(DownloadsStatus.isStatusClientError(500)).isFalse();
    }

    @Test
    public void whenStatusIs4xxOr5xxxThenStatusIsError() {
        for (int i = 400; i < 600; i++) {
            assertThat(DownloadsStatus.isStatusError(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusError(399)).isFalse();
        assertThat(DownloadsStatus.isStatusError(700)).isFalse();
    }

    @Test
    public void whenStatusIs198ThenStatusIsInsufficientSpace() {
        boolean isInsufficientSpace = DownloadsStatus.isStatusCancelled(490);
        assertThat(isInsufficientSpace).isTrue();
    }

    @Test
    public void whenStatusIs5xxThenStatusIsServerError() {
        for (int i = 500; i < 600; i++) {
            assertThat(DownloadsStatus.isStatusServerError(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusServerError(499)).isFalse();
        assertThat(DownloadsStatus.isStatusServerError(600)).isFalse();
    }

    @Test
    public void whenStatusIs1xxThenStatusIsInformational() {
        for (int i = 100; i < 200; i++) {
            assertThat(DownloadsStatus.isStatusInformational(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusInformational(99)).isFalse();
        assertThat(DownloadsStatus.isStatusInformational(200)).isFalse();
    }

    @Test
    public void whenStatusIs2xxThenStatusIsSuccess() {
        for (int i = 200; i < 300; i++) {
            assertThat(DownloadsStatus.isStatusSuccess(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusSuccess(199)).isFalse();
        assertThat(DownloadsStatus.isStatusSuccess(300)).isFalse();
    }

    @Test
    public void whenStatusIs2xxThenStatusIsCompleted() {
        for (int i = 200; i < 300; i++) {
            assertThat(DownloadsStatus.isStatusCompleted(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusSuccess(199)).isFalse();
        assertThat(DownloadsStatus.isStatusSuccess(300)).isFalse();
    }

    @Test
    public void whenStatusIs4xxAnd5xxButNot490ThenStatusIsCompleted() {
        for (int i = 400; i < 600; i++) {
            if (i == 490) {
                assertThat(DownloadsStatus.isStatusCompleted(i)).isFalse();
            } else {
                assertThat(DownloadsStatus.isStatusCompleted(i)).isTrue();
            }
        }

        assertThat(DownloadsStatus.isStatusSuccess(399)).isFalse();
        assertThat(DownloadsStatus.isStatusSuccess(600)).isFalse();
    }

}<commit_msg>Added tests for the two new statuses from master<commit_after>package com.novoda.downloadmanager.lib;

import android.app.DownloadManager;

import org.junit.Test;

import static org.fest.assertions.api.Assertions.assertThat;

public class DownloadsStatusTest {

    @Test
    public void whenVisibilityIsCompletedThenNotificationIsToBeDisplayed() {
        boolean toBeDisplayed = DownloadsStatus.isNotificationToBeDisplayed(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        assertThat(toBeDisplayed).isTrue();
    }

    @Test
    public void whenVisibilityIsOnlyCompletionThenNotificationIsToBeDisplayed() {
        boolean toBeDisplayed = DownloadsStatus.isNotificationToBeDisplayed(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION);
        assertThat(toBeDisplayed).isTrue();
    }

    @Test
    public void whenVisibilityIsHiddenThenNotificationIsNotBeDisplayed() {
        boolean toBeDisplayed = DownloadsStatus.isNotificationToBeDisplayed(DownloadManager.Request.VISIBILITY_HIDDEN);
        assertThat(toBeDisplayed).isFalse();
    }

    @Test
    public void whenStatusIs490ThenStatusIsCancelled() {
        boolean isCancelled = DownloadsStatus.isStatusCancelled(490);
        assertThat(isCancelled).isTrue();
    }

    @Test
    public void whenStatusIs4xxThenStatusIsClientError() {
        for (int i = 400; i < 500; i++) {
            assertThat(DownloadsStatus.isStatusClientError(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusClientError(399)).isFalse();
        assertThat(DownloadsStatus.isStatusClientError(500)).isFalse();
    }

    @Test
    public void whenStatusIs4xxOr5xxxThenStatusIsError() {
        for (int i = 400; i < 600; i++) {
            assertThat(DownloadsStatus.isStatusError(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusError(399)).isFalse();
        assertThat(DownloadsStatus.isStatusError(700)).isFalse();
    }

    @Test
    public void whenStatusIs198ThenStatusIsInsufficientSpace() {
        boolean isInsufficientSpace = DownloadsStatus.isStatusCancelled(490);
        assertThat(isInsufficientSpace).isTrue();
    }

    @Test
    public void whenStatusIs5xxThenStatusIsServerError() {
        for (int i = 500; i < 600; i++) {
            assertThat(DownloadsStatus.isStatusServerError(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusServerError(499)).isFalse();
        assertThat(DownloadsStatus.isStatusServerError(600)).isFalse();
    }

    @Test
    public void whenStatusIs1xxThenStatusIsInformational() {
        for (int i = 100; i < 200; i++) {
            assertThat(DownloadsStatus.isStatusInformational(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusInformational(99)).isFalse();
        assertThat(DownloadsStatus.isStatusInformational(200)).isFalse();
    }

    @Test
    public void whenStatusIs2xxThenStatusIsSuccess() {
        for (int i = 200; i < 300; i++) {
            assertThat(DownloadsStatus.isStatusSuccess(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusSuccess(199)).isFalse();
        assertThat(DownloadsStatus.isStatusSuccess(300)).isFalse();
    }

    @Test
    public void whenStatusIs2xxThenStatusIsCompleted() {
        for (int i = 200; i < 300; i++) {
            assertThat(DownloadsStatus.isStatusCompleted(i)).isTrue();
        }

        assertThat(DownloadsStatus.isStatusSuccess(199)).isFalse();
        assertThat(DownloadsStatus.isStatusSuccess(300)).isFalse();
    }

    @Test
    public void whenStatusIs4xxAnd5xxButNot490ThenStatusIsCompleted() {
        for (int i = 400; i < 600; i++) {
            if (i == 490) {
                assertThat(DownloadsStatus.isStatusCompleted(i)).isFalse();
            } else {
                assertThat(DownloadsStatus.isStatusCompleted(i)).isTrue();
            }
        }

        assertThat(DownloadsStatus.isStatusSuccess(399)).isFalse();
        assertThat(DownloadsStatus.isStatusSuccess(600)).isFalse();
    }

    @Test
    public void whenStatusIs189ThenStatusIsSubmitted() {
        boolean isStatusSubmitted = DownloadsStatus.isStatusSubmitted(189);
        assertThat(isStatusSubmitted).isTrue();
    }

    @Test
    public void whenStatusIs192ThenStatusIsRunning() {
        boolean isStatusRunning = DownloadsStatus.isStatusRunning(192);
        assertThat(isStatusRunning).isTrue();
    }

}
{'fraction_non_alphanumeric': 0.10371609511291671, 'fraction_numerical': 0.027721352610825666, 'mean_word_length': 3.41222983658408, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 68, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3838063', 'n_tokens_mistral': 2532, 'n_tokens_neox': 2356, 'n_words': 334}