1   /*
2   	StatCvs - CVS statistics generation 
3   	Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
4   	http://statcvs.sf.net/
5       
6   	This library is free software; you can redistribute it and/or
7   	modify it under the terms of the GNU Lesser General Public
8   	License as published by the Free Software Foundation; either
9   	version 2.1 of the License, or (at your option) any later version.
10  
11  	This library is distributed in the hope that it will be useful,
12  	but WITHOUT ANY WARRANTY; without even the implied warranty of
13  	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  	Lesser General Public License for more details.
15  
16  	You should have received a copy of the GNU Lesser General Public
17  	License along with this library; if not, write to the Free Software
18  	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20  package net.sf.statcvs.model;
21  
22  import java.util.Date;
23  
24  import junit.framework.TestCase;
25  
26  /**
27   * Tests for {@link net.sf.statcvs.model.Revision}
28   * 
29   * @author Richard Cyganiak <richard@cyganiak.de>
30   * @version $Id: RevisionTest.java,v 1.6 2008/04/02 11:22:15 benoitx Exp $
31   */
32  public class RevisionTest extends TestCase {
33      private Author author;
34      private Date date1;
35      private Date date2;
36      private Date date3;
37      private Date date4;
38  
39      public RevisionTest(final String arg) {
40          super(arg);
41      }
42  
43      public void setUp() {
44          author = new Author("author");
45          date1 = new Date(110000000);
46          date2 = new Date(120000000);
47          date3 = new Date(130000000);
48          date4 = new Date(140000000);
49      }
50  
51      public void testGetFileCountChange1() {
52          final VersionedFile file = new VersionedFile("file", Directory.createRoot());
53          final Revision rev4 = new Revision(file, "1.4", Revision.TYPE_CREATION, author, date4, null, 0, 0, 0, null);
54          final Revision rev3 = new Revision(file, "1.3", Revision.TYPE_CHANGE, author, date3, null, 0, 0, 0, null);
55          final Revision rev2 = new Revision(file, "1.2", Revision.TYPE_DELETION, author, date2, null, 0, 0, 0, null);
56          final Revision rev1 = new Revision(file, "1.1", Revision.TYPE_CREATION, author, date1, null, 0, 0, 0, null);
57          assertEquals(1, rev4.getFileCountDelta());
58          assertEquals(0, rev3.getFileCountDelta());
59          assertEquals(-1, rev2.getFileCountDelta());
60          assertEquals(1, rev1.getFileCountDelta());
61      }
62  
63      public void testGetFileCountChange2() {
64          final VersionedFile file = new VersionedFile("file", Directory.createRoot());
65          final Revision rev = new Revision(file, null, Revision.TYPE_BEGIN_OF_LOG, author, date1, null, 0, 0, 0, null);
66          assertEquals(0, rev.getFileCountDelta());
67      }
68  }