Skip to main content
summaryrefslogtreecommitdiffstats
blob: b1a52c5502c799dc7414889a764b88862da4f977 (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
/******************************************************************************
 *  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.Collections;
import java.util.Date;

import org.eclipse.egit.github.core.Application;
import org.eclipse.egit.github.core.Authorization;
import org.junit.Test;

/**
 * Unit tests of {@link Authorization}
 */
public class AuthorizationTest {

	/**
	 * Test default state of authorization
	 */
	@Test
	public void defaultState() {
		Authorization auth = new Authorization();
		assertNull(auth.getApp());
		assertNull(auth.getCreatedAt());
		assertEquals(0, auth.getId());
		assertNull(auth.getScopes());
		assertNull(auth.getToken());
		assertNull(auth.getUpdatedAt());
		assertNull(auth.getUrl());
	}

	/**
	 * Test updating application fields
	 */
	@Test
	public void updateFields() {
		Authorization auth = new Authorization();
		Application app = new Application();
		assertEquals(app, auth.setApp(app).getApp());
		assertEquals(new Date(2500), auth.setCreatedAt(new Date(2500))
				.getCreatedAt());
		assertEquals(123, auth.setId(123).getId());
		assertEquals(Collections.singletonList("repo"),
				auth.setScopes(Collections.singletonList("repo")).getScopes());
		assertEquals("token", auth.setToken("token").getToken());
		assertEquals(new Date(8000), auth.setUpdatedAt(new Date(8000))
				.getUpdatedAt());
		assertEquals("url", auth.setUrl("url").getUrl());
	}
}

Back to the top