View Javadoc
1   package civitas.common.ballotdesign;
2   
3   import static org.junit.jupiter.api.Assertions.assertEquals;
4   
5   import org.junit.jupiter.api.DisplayName;
6   import org.junit.jupiter.api.Test;
7   import org.mockito.InjectMocks;
8   
9   import civitas.common.RandomAwareTestBase;
10  import civitas.util.BasicValuesTestData;
11  
12  class GetIndexOfCandidateTest extends RandomAwareTestBase implements BallotDesignTestData, BasicValuesTestData {
13  
14  	@InjectMocks
15  	GetIndexOfCandidate getIndexOfCandidate;
16  
17  	@Test
18  	@DisplayName("gets index of candidate")
19  	void test() {
20  		assertEquals(1, getIndexOfCandidate.apply(BALLOTDESIGN, CANDIDATE));
21  	}
22  
23  	@Test
24  	@DisplayName("finds the candidate even when case does not match")
25  	void test1() {
26  		assertEquals(1, getIndexOfCandidate.apply(BALLOTDESIGN, CANDIDATE.toLowerCase()));
27  	}
28  
29  	@Test
30  	@DisplayName("if there is no such candidate -1 is returned")
31  	void test2() {
32  		assertEquals(-1, getIndexOfCandidate.apply(BALLOTDESIGN, SOMESTRING));
33  	}
34  }