package com.atlassian.bitbucket.internal.integration.jira;

import org.junit.Test;

import static com.atlassian.bitbucket.internal.integration.jira.SimpleJiraIssue.maybeCreate;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;

public class SimpleJiraIssueTest {

    @SuppressWarnings("ConstantConditions")
    @Test
    public void testCompareTo() throws Exception {
        assertThat(maybeCreate("FOO-1", "url1").compareTo(maybeCreate("FOO-1", "url2")), equalTo(0));
        assertThat(maybeCreate("FOO-1", "url1").compareTo(maybeCreate("FOO-2", "url2")), lessThan(0));
        assertThat(maybeCreate("FOO-2", "url1").compareTo(maybeCreate("FOO-1", "url2")), greaterThan(0));
        assertThat(maybeCreate("FOO-2", "url1").compareTo(maybeCreate("FOO-2", "url2")), equalTo(0));
        assertThat(maybeCreate("FOO-2", "url1").compareTo(maybeCreate("BAR-2", "url2")), greaterThan(0));
        assertThat(maybeCreate("FOO-1", "url1").compareTo(maybeCreate("BAR-2", "url2")), greaterThan(0));
        assertThat(maybeCreate("FOO-2", "url1").compareTo(maybeCreate("BAR-1", "url2")), greaterThan(0));
    }
}
