Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a7f8b1f68af850b5c7abebbb452cf39a7405f01c (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
67
68
69
70
71
72
73
/******************************************************************************
 *  Copyright (c) 2012 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.Arrays;
import java.util.Date;
import java.util.List;

import org.eclipse.egit.github.core.SearchIssue;
import org.junit.Test;

/**
 * Unit tests of {@link SearchIssue}
 */
public class SearchIssueTest {

	/**
	 * Test default state of search issue
	 */
	@Test
	public void defaultState() {
		SearchIssue issue = new SearchIssue();
		assertNull(issue.getBody());
		assertNull(issue.getCreatedAt());
		assertNull(issue.getGravatarId());
		assertNull(issue.getHtmlUrl());
		assertNull(issue.getLabels());
		assertEquals(0, issue.getComments());
		assertEquals(0, issue.getPosition());
		assertNull(issue.getState());
		assertNull(issue.getTitle());
		assertNull(issue.getUpdatedAt());
		assertNull(issue.getUser());
		assertEquals(0, issue.getVotes());
		assertEquals(0, issue.getNumber());
	}

	/**
	 * Test updating search issue fields
	 */
	@Test
	public void updateFields() {
		SearchIssue issue = new SearchIssue();
		assertEquals("body", issue.setBody("body").getBody());
		assertEquals(new Date(1234), issue.setCreatedAt(new Date(1234))
				.getCreatedAt());
		assertEquals("gravatar", issue.setGravatarId("gravatar")
				.getGravatarId());
		assertEquals("html", issue.setHtmlUrl("html").getHtmlUrl());
		List<String> labels = Arrays.asList("a", "b");
		assertEquals(labels, issue.setLabels(labels).getLabels());
		assertEquals(5, issue.setComments(5).getComments());
		assertEquals(6, issue.setPosition(6).getPosition());
		assertEquals("open", issue.setState("open").getState());
		assertEquals("title", issue.setTitle("title").getTitle());
		assertEquals(new Date(2345), issue.setUpdatedAt(new Date(2345))
				.getUpdatedAt());
		assertEquals("defunkt", issue.setUser("defunkt").getUser());
		assertEquals(10, issue.setVotes(10).getVotes());
		assertEquals(500, issue.setNumber(500).getNumber());
	}
}

Back to the top