Search in sources :

Example 11 with Commit

use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.

the class CommitUtilsTest method testAbbreviate.

/**
     * Test commit SHA-1 abbreviation
     */
public void testAbbreviate() {
    assertNull(CommitUtils.abbreviate((GitCommit) null));
    assertNull(CommitUtils.abbreviate((Commit) null));
    assertNull(CommitUtils.abbreviate((String) null));
    assertEquals("", CommitUtils.abbreviate(""));
    assertEquals("a", CommitUtils.abbreviate("a"));
    assertEquals("abcdefghij", CommitUtils.abbreviate("abcdefghijk"));
    GitCommit gitCommit = GitCommit.builder().sha("abc").build();
    assertEquals("abc", CommitUtils.abbreviate(gitCommit));
    Commit commit = Commit.builder().sha("abcd").build();
    assertEquals("abcd", CommitUtils.abbreviate(commit));
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit)

Example 12 with Commit

use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.

the class CommitUtilsTest method testGetAuthorDate.

/**
     * Test parsing author date from commit
     */
public void testGetAuthorDate() {
    Commit commit = Commit.builder().build();
    assertNull(CommitUtils.getAuthorDate(commit));
    GitCommit rawCommit = GitCommit.builder().build();
    commit = commit.toBuilder().commit(rawCommit).build();
    assertNull(CommitUtils.getAuthorDate(commit));
    GitUser user = GitUser.builder().build();
    rawCommit = rawCommit.toBuilder().author(user).build();
    commit = commit.toBuilder().commit(rawCommit).build();
    assertNull(CommitUtils.getAuthorDate(commit));
    user = user.toBuilder().date(new Date(12000)).build();
    rawCommit = rawCommit.toBuilder().author(user).build();
    commit = commit.toBuilder().commit(rawCommit).build();
    assertEquals(new Date(12000), CommitUtils.getAuthorDate(commit));
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) Date(java.util.Date) GitUser(com.meisolsson.githubsdk.model.git.GitUser)

Example 13 with Commit

use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.

the class CommitUtilsTest method testGetAuthor.

/**
     * Test parsing author from commit
     */
public void testGetAuthor() {
    Commit commit = Commit.builder().build();
    assertNull(CommitUtils.getAuthor(commit));
    GitCommit rawCommit = GitCommit.builder().build();
    commit = commit.toBuilder().commit(rawCommit).build();
    assertNull(CommitUtils.getAuthor(commit));
    GitUser user = GitUser.builder().build();
    rawCommit = rawCommit.toBuilder().author(user).build();
    commit = commit.toBuilder().commit(rawCommit).build();
    assertNull(CommitUtils.getAuthor(commit));
    user = user.toBuilder().name("u1").build();
    rawCommit = rawCommit.toBuilder().author(user).build();
    commit = commit.toBuilder().commit(rawCommit).build();
    assertEquals("u1", CommitUtils.getAuthor(commit));
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) GitCommit(com.meisolsson.githubsdk.model.git.GitCommit) GitUser(com.meisolsson.githubsdk.model.git.GitUser)

Example 14 with Commit

use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.

the class FullCommitTest method testSingleCommentSingleFile.

/**
     * Test commit with one file and one commit comment
     */
public void testSingleCommentSingleFile() {
    GitHubFile file = GitHubFile.builder().filename("a.txt").build();
    GitComment comment = GitComment.builder().build();
    Commit commit = Commit.builder().files(Collections.singletonList(file)).build();
    FullCommit full = new FullCommit(commit, Collections.singletonList(comment));
    assertFalse(full.isEmpty());
    assertEquals(comment, full.get(0));
    assertEquals(1, full.getFiles().size());
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) FullCommit(com.github.pockethub.android.core.commit.FullCommit) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile) FullCommit(com.github.pockethub.android.core.commit.FullCommit) GitComment(com.meisolsson.githubsdk.model.git.GitComment)

Example 15 with Commit

use of com.meisolsson.githubsdk.model.Commit in project PocketHub by pockethub.

the class FullCommitTest method testNoCommentsSingleFile.

/**
     * Test commit with no comments and one file
     */
public void testNoCommentsSingleFile() {
    GitHubFile file = GitHubFile.builder().filename("a.txt").build();
    Commit commit = Commit.builder().files(Collections.singletonList(file)).build();
    FullCommit full = new FullCommit(commit);
    assertTrue(full.isEmpty());
    assertEquals(1, full.getFiles().size());
}
Also used : Commit(com.meisolsson.githubsdk.model.Commit) FullCommit(com.github.pockethub.android.core.commit.FullCommit) GitHubFile(com.meisolsson.githubsdk.model.GitHubFile) FullCommit(com.github.pockethub.android.core.commit.FullCommit)

Aggregations

Commit (com.meisolsson.githubsdk.model.Commit)16 GitCommit (com.meisolsson.githubsdk.model.git.GitCommit)7 FullCommit (com.github.pockethub.android.core.commit.FullCommit)6 GitHubFile (com.meisolsson.githubsdk.model.GitHubFile)5 GitComment (com.meisolsson.githubsdk.model.git.GitComment)5 GitUser (com.meisolsson.githubsdk.model.git.GitUser)4 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 Date (java.util.Date)2 LayoutInflater (android.view.LayoutInflater)1 ImageView (android.widget.ImageView)1 StyledText (com.github.pockethub.android.ui.StyledText)1 RepositoryCommentService (com.meisolsson.githubsdk.service.repositories.RepositoryCommentService)1 IOException (java.io.IOException)1