Skip to content

Commit 7c99761

Browse files
authored
Merge pull request #590 from MarkEWaite/improve-test-coverage
Add GitBranchSpecifierColumnTest
2 parents 8e3550c + 783fab8 commit 7c99761

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright 2018 CloudBees, Inc.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
package hudson.plugins.git;
25+
26+
import hudson.model.Item;
27+
import java.util.ArrayList;
28+
import java.util.List;
29+
import static org.hamcrest.Matchers.*;
30+
import org.junit.Test;
31+
import static org.junit.Assert.*;
32+
33+
/**
34+
* @author Mark Waite
35+
*/
36+
public class GitBranchSpecifierColumnTest {
37+
38+
public GitBranchSpecifierColumnTest() {
39+
}
40+
41+
@Test
42+
public void testGetBranchSpecifierNull() {
43+
Item item = null;
44+
GitBranchSpecifierColumn branchSpecifierColumn = new GitBranchSpecifierColumn();
45+
List<String> result = branchSpecifierColumn.getBranchSpecifier(item);
46+
assertThat(result, is(emptyCollectionOf(String.class)));
47+
}
48+
49+
@Test
50+
public void testBreakOutString() {
51+
List<String> branches = new ArrayList<>();
52+
final String MASTER_BRANCH = "master";
53+
branches.add(MASTER_BRANCH);
54+
String DEVELOP_BRANCH = "develop";
55+
branches.add(DEVELOP_BRANCH);
56+
GitBranchSpecifierColumn branchSpecifier = new GitBranchSpecifierColumn();
57+
String result = branchSpecifier.breakOutString(branches);
58+
assertEquals(MASTER_BRANCH + ", " + DEVELOP_BRANCH, result);
59+
}
60+
61+
@Test
62+
public void testBreakOutStringEmpty() {
63+
List<String> branches = new ArrayList<>();
64+
GitBranchSpecifierColumn branchSpecifier = new GitBranchSpecifierColumn();
65+
String result = branchSpecifier.breakOutString(branches);
66+
assertEquals("", result);
67+
}
68+
69+
@Test
70+
public void testBreakOutStringNull() {
71+
List<String> branches = null;
72+
GitBranchSpecifierColumn branchSpecifier = new GitBranchSpecifierColumn();
73+
String result = branchSpecifier.breakOutString(branches);
74+
assertEquals(null, result);
75+
}
76+
}

0 commit comments

Comments
 (0)