View Javadoc
1   /*
2    * #%L
3    * IsisFish
4    * 
5    * $Id: MonthTest.java 4156 2014-12-09 11:27:18Z echatellier $
6    * $HeadURL: https://svn.codelutin.com/isis-fish/tags/isis-fish-4.4.0.2/src/test/java/fr/ifremer/isisfish/types/MonthTest.java $
7    * %%
8    * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
9    * %%
10   * This program is free software: you can redistribute it and/or modify
11   * it under the terms of the GNU General Public License as
12   * published by the Free Software Foundation, either version 3 of the 
13   * License, or (at your option) any later version.
14   * 
15   * This program is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   * GNU General Public License for more details.
19   * 
20   * You should have received a copy of the GNU General Public 
21   * License along with this program.  If not, see
22   * <http://www.gnu.org/licenses/gpl-3.0.html>.
23   * #L%
24   */
25  
26  package fr.ifremer.isisfish.types;
27  
28  import static org.nuiton.i18n.I18n.t;
29  
30  import java.util.LinkedList;
31  import java.util.List;
32  
33  import org.nuiton.math.matrix.MatrixFactory;
34  import org.nuiton.math.matrix.MatrixND;
35  import org.junit.Assert;
36  import org.junit.Test;
37  
38  /**
39   * Test on {@link Month}.
40   * 
41   * @author chatellier
42   * @version $Revision: 4156 $
43   * 
44   * Last update : $Date: 2014-12-09 12:27:18 +0100 (Tue, 09 Dec 2014) $
45   * By : $Author: echatellier $
46   */
47  public class MonthTest {
48  
49      /**
50       * Test that indexOf works on list of month. 
51       */
52      @Test
53      public void listTest() {
54          
55          List<Month> monthList = new LinkedList<Month>();
56          monthList.add(new Month(0));
57          monthList.add(new Month(1));
58          monthList.add(new Month(2));
59          
60          Assert.assertTrue(monthList.contains(Month.JANUARY));
61          Assert.assertFalse(monthList.contains(Month.AUGUST));
62          
63          Assert.assertEquals(0, monthList.indexOf(Month.JANUARY));
64          Assert.assertEquals(-1, monthList.indexOf(Month.AUGUST));
65      }
66      
67      @Test
68      public void maxtrixWithMonth() {
69          
70          List<Month> monthList = new LinkedList<Month>();
71          monthList.add(new Month(0));
72          monthList.add(new Month(1));
73          monthList.add(new Month(2));
74          
75          List<Month> monthList2 = new LinkedList<Month>();
76          monthList2.add(Month.FEBRUARY);
77          
78          MatrixND tmp = MatrixFactory.getInstance().create(
79                  "test",
80                  new List[] { monthList },
81                  new String[] { t("isisfish.populationSeasonInfo.months") });
82          
83          MatrixND result = MatrixFactory.getInstance().create(
84                  "test",
85                  new List[] { monthList2 },
86                  new String[] { t("isisfish.populationSeasonInfo.months") });
87  
88          tmp.pasteSemantics(result);
89      }
90  }