Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f99a71fd61cc4416f3070981452bdf1e7071b06e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/******************************************************************************
 *  Copyright (c) 2011 GitHub Inc.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *  Contributors:
 *    Kevin Sawicki (GitHub Inc.) - initial API and implementation
 *****************************************************************************/
package org.eclipse.egit.github.core.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.util.ArrayList;

import org.eclipse.egit.github.core.Commit;
import org.eclipse.egit.github.core.CommitUser;
import org.eclipse.egit.github.core.Tree;
import org.junit.Test;

/**
 * Unit tests of {@link Commit}
 */
public class CommitTest {

	/**
	 * Test default state of commit
	 */
	@Test
	public void defaultState() {
		Commit commit = new Commit();
		assertNull(commit.getAuthor());
		assertNull(commit.getCommitter());
		assertNull(commit.getMessage());
		assertNull(commit.getParents());
		assertNull(commit.getSha());
		assertNull(commit.getTree());
		assertNull(commit.getUrl());
	}

	/**
	 * Test updating commit fields
	 */
	@Test
	public void updateFields() {
		Commit commit = new Commit();
		CommitUser author = new CommitUser().setName("Art Thor");
		assertEquals(author, commit.setAuthor(author).getAuthor());
		CommitUser committer = new CommitUser().setName("Comb Mitter");
		assertEquals(committer, commit.setCommitter(committer).getCommitter());
		assertEquals("commit message", commit.setMessage("commit message")
				.getMessage());
		assertEquals(new ArrayList<Commit>(),
				commit.setParents(new ArrayList<Commit>()).getParents());
		assertEquals("abcdef", commit.setSha("abcdef").getSha());
		Tree tree = new Tree();
		tree.setSha("12345");
		assertEquals(tree, commit.setTree(tree).getTree());
		assertEquals("url", commit.setUrl("url").getUrl());
	}
}

Back to the top