Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4877d40e221d403b04a3476a1f96f8eaf6af9687 (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
/*******************************************************************************
 * Copyright (c) 2014 Tasktop Technologies 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:
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.tasks.ui.editors;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;

import org.eclipse.mylyn.internal.tasks.ui.editors.BooleanAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.DoubleAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.IntegerAttributeEditor;
import org.eclipse.mylyn.internal.tasks.ui.editors.LongAttributeEditor;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class AttributeEditorFactoryTest {

	@Rule
	public ExpectedException thrown = ExpectedException.none();

	private final TaskData data = new TaskData(mock(TaskAttributeMapper.class), "kind", "url", "id");

	private final AttributeEditorFactory factory = new AttributeEditorFactory(mock(TaskDataModel.class),
			new TaskRepository("kind", "url"));

	@Test
	public void createBooleanAttributeEditor() {
		AbstractAttributeEditor editor = factory.createEditor(TaskAttribute.TYPE_BOOLEAN, data.getRoot());
		assertEquals(BooleanAttributeEditor.class, editor.getClass());
	}

	@Test
	public void createDoubleAttributeEditor() {
		AbstractAttributeEditor editor = factory.createEditor(TaskAttribute.TYPE_DOUBLE, data.getRoot());
		assertEquals(DoubleAttributeEditor.class, editor.getClass());
	}

	@Test
	public void createLongAttributeEditor() {
		AbstractAttributeEditor editor = factory.createEditor(TaskAttribute.TYPE_LONG, data.getRoot());
		assertEquals(LongAttributeEditor.class, editor.getClass());
	}

	@Test
	public void createIntegerAttributeEditor() {
		AbstractAttributeEditor editor = factory.createEditor(TaskAttribute.TYPE_INTEGER, data.getRoot());
		assertEquals(IntegerAttributeEditor.class, editor.getClass());
	}

	@Test
	public void createAttributeEditorForUnknownType() {
		thrown.expect(IllegalArgumentException.class);
		factory.createEditor("unknown type", data.getRoot());
	}

}

Back to the top