View Javadoc
1   /*
2    * Copyright (C) 2011, Tomasz Zarna <Tomasz.Zarna@pl.ibm.com> and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  package org.eclipse.jgit.revwalk;
11  
12  import static org.junit.Assert.assertNull;
13  
14  import org.eclipse.jgit.revwalk.filter.MaxCountRevFilter;
15  import org.junit.Test;
16  
17  public class MaxCountRevFilterTest extends RevWalkTestCase {
18  	@Test
19  	public void testMaxCountRevFilter() throws Exception {
20  		final RevCommit a = commit();
21  		final RevCommit b = commit(a);
22  		final RevCommit c1 = commit(b);
23  		final RevCommit c2 = commit(b);
24  		final RevCommit d = commit(c1, c2);
25  		final RevCommit e = commit(d);
26  
27  		rw.reset();
28  		rw.setRevFilter(MaxCountRevFilter.create(3));
29  		markStart(e);
30  		assertCommit(e, rw.next());
31  		assertCommit(d, rw.next());
32  		assertCommit(c2, rw.next());
33  		assertNull(rw.next());
34  
35  		rw.reset();
36  		rw.setRevFilter(MaxCountRevFilter.create(0));
37  		markStart(e);
38  		assertNull(rw.next());
39  	}
40  
41  	@Test
42  	public void testMaxCountRevFilter0() throws Exception {
43  		final RevCommit a = commit();
44  		final RevCommit b = commit(a);
45  
46  		rw.reset();
47  		rw.setRevFilter(MaxCountRevFilter.create(0));
48  		markStart(b);
49  		assertNull(rw.next());
50  	}
51  }