Search in sources :

Example 16 with GitCommit

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

the class CommitUtilsTest method testGetAuthorDate.

/**
 * Test parsing author date from commit
 */
@Test
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) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 17 with GitCommit

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

the class CommitUtilsTest method testAbbreviate.

/**
 * Test commit SHA-1 abbreviation
 */
@Test
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) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 18 with GitCommit

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

the class CommitUtilsTest method testGetAuthor.

/**
 * Test parsing author from commit
 */
@Test
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) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Aggregations

GitCommit (com.meisolsson.githubsdk.model.git.GitCommit)18 GitUser (com.meisolsson.githubsdk.model.git.GitUser)9 Commit (com.meisolsson.githubsdk.model.Commit)6 User (com.meisolsson.githubsdk.model.User)6 SmallTest (androidx.test.filters.SmallTest)5 PushPayload (com.meisolsson.githubsdk.model.payload.PushPayload)5 Test (org.junit.Test)5 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)3 Repository (com.meisolsson.githubsdk.model.Repository)3 GitComment (com.meisolsson.githubsdk.model.git.GitComment)3 CommitCommentPayload (com.meisolsson.githubsdk.model.payload.CommitCommentPayload)3 DownloadPayload (com.meisolsson.githubsdk.model.payload.DownloadPayload)3 FollowPayload (com.meisolsson.githubsdk.model.payload.FollowPayload)3 ForkPayload (com.meisolsson.githubsdk.model.payload.ForkPayload)3 GollumPayload (com.meisolsson.githubsdk.model.payload.GollumPayload)3 IssueCommentPayload (com.meisolsson.githubsdk.model.payload.IssueCommentPayload)3 IssuesPayload (com.meisolsson.githubsdk.model.payload.IssuesPayload)3 PullRequestPayload (com.meisolsson.githubsdk.model.payload.PullRequestPayload)3 ReleasePayload (com.meisolsson.githubsdk.model.payload.ReleasePayload)3 List (java.util.List)3