blob: 8c0c8859e846f0cba2f9123add1396c0fd48a18e (
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
|
/*******************************************************************************
* Copyright (c) 2013 Red Hat 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:
* Neil Guzman - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.rpm.createrepo.tree.tests;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoTreeCategory;
import org.junit.Test;
/**
* Test the CreaterepoTreeCategory class.
*/
public class CreaterepoTreeCategoryTest {
private static final String CATEGORY_NAME = "test"; //$NON-NLS-1$
private static final String TAG1 = "tag1"; //$NON-NLS-1$
private static final String TAG2 = "tag2"; //$NON-NLS-1$
/**
* Test the tree category to make sure it initializes and stores tags properly.
* Tags must be unique, so the category should not add tags that already exist
* within the category.
*/
@Test
public void testCreaterepoTreeCategory() {
List<String> tagsToCheck = new ArrayList<>();
tagsToCheck.add(TAG1);
tagsToCheck.add(TAG2);
CreaterepoTreeCategory categoryTest = new CreaterepoTreeCategory(CATEGORY_NAME);
assertEquals(0, categoryTest.getTags().size());
assertEquals(CATEGORY_NAME, categoryTest.getName());
categoryTest.addTag(TAG2);
assertEquals(1, categoryTest.getTags().size());
assertEquals(TAG2, categoryTest.getTags().get(0));
categoryTest.addAllTags(tagsToCheck);
// TAG2 should not be added again, hence size should = 2
assertEquals(2, categoryTest.getTags().size());
}
}
|