Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 37e3937490d6bb7a7e7670c21f21f2d199b61d3f (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
64
65
66
/******************************************************************************
 *  Copyright (c) 2012, 2015 GitHub Inc. and others.
 *  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.Date;

import org.eclipse.egit.github.core.CommitStatus;
import org.eclipse.egit.github.core.User;
import org.junit.Test;

/**
 * Unit tests of {@link CommitStatus}
 */
public class CommitStatusTest {

	/**
	 * Test default state of commit status
	 */
	@Test
	public void defaultState() {
		CommitStatus status = new CommitStatus();
		assertNull(status.getCreatedAt());
		assertNull(status.getCreator());
		assertNull(status.getContext());
		assertNull(status.getDescription());
		assertEquals(0, status.getId());
		assertNull(status.getState());
		assertNull(status.getTargetUrl());
		assertNull(status.getUpdatedAt());
		assertNull(status.getUrl());
		assertNull(status.getContext());
	}

	/**
	 * Test updating commit status fields
	 */
	@Test
	public void updateFields() {
		CommitStatus status = new CommitStatus();
		assertEquals(new Date(1234), status.setCreatedAt(new Date(1234))
				.getCreatedAt());
		User creator = new User().setId(1);
		assertEquals(creator, status.setCreator(creator).getCreator());
		assertEquals("con/text", status.setContext("con/text").getContext());
		assertEquals("desc", status.setDescription("desc").getDescription());
		assertEquals(40, status.setId(40).getId());
		assertEquals("success", status.setState("success").getState());
		assertEquals("targetUrl", status.setTargetUrl("targetUrl")
				.getTargetUrl());
		assertEquals(new Date(5678), status.setUpdatedAt(new Date(5678))
				.getUpdatedAt());
		assertEquals("url", status.setUrl("url").getUrl());
		assertEquals("context", status.setContext("context").getContext());
	}
}

Back to the top