View Javadoc
1   /*
2    * #%L
3    * IsisFish
4    * 
5    * $Id: EquationTest.java 4263 2015-06-11 09:01:47Z echatellier $
6    * $HeadURL: https://svn.codelutin.com/isis-fish/tags/isis-fish-4.4.0.2/src/test/java/fr/ifremer/isisfish/equation/EquationTest.java $
7    * %%
8    * Copyright (C) 2015 Ifremer, CodeLutin, Chatellier Eric
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  package fr.ifremer.isisfish.equation;
26  
27  import org.junit.Assert;
28  import org.junit.Test;
29  
30  import fr.ifremer.isisfish.AbstractIsisFishTest;
31  import fr.ifremer.isisfish.util.EvaluatorHelper;
32  
33  /**
34   * Equation related tests.
35   * 
36   * @author chatellier
37   */
38  public class EquationTest extends AbstractIsisFishTest {
39      
40      /**
41       * Try to compile all equation with a default content to detect basic
42       * compile error.
43       * 
44       * @throws java.lang.ClassNotFoundException
45       */
46      @Test
47      public void testCompileAllEquations() throws ClassNotFoundException {
48          test(EmigrationEquation.class, new Object[5]);
49          test(ImmigrationEquation.class, new Object[5]);
50          test(MigrationEquation.class, new Object[6]);
51          test(PopulationCapturabilityEquation.class, new Object[4]);
52          test(PopulationGrowth.class, null, 0.0, null);
53          test(PopulationGrowthReverse.class, null, 0.0, null);
54          test(PopulationMaturityOgiveEquation.class, new Object[2]);
55          test(PopulationMeanWeight.class, new Object[2]);
56          test(PopulationNaturalDeathRate.class, new Object[4]);
57          test(PopulationPrice.class, new Object[2]);
58          test(PopulationRecruitmentEquation.class, new Object[5]);
59          test(PopulationReproductionEquation.class, null, null, null, null, 0.0, null, null, null, null);
60          test(PopulationReproductionRateEquation.class, new Object[2]);
61          test(SelectivityEquation.class, new Object[4]);
62          test(SoVTechnicalEfficiencyEquation.class, new Object[3]);
63          test(StrategyInactivityEquation.class, new Object[3]);
64          test(TargetSpeciesTargetFactorEquation.class,  null, null, null, null, false);
65          test(VariableEquation.class, new Object[3]);
66      }
67  
68      /**
69       * Try to set 'return 42.0;' in all equation content and test to get this result.
70       * 
71       * @param clazz class to test
72       * @param args equation args
73       */
74      protected void test(Class clazz, Object... args) {
75          EvaluatorHelper.evaluate("fr.isisfish.equation",
76                      "TestCompileAll", clazz, "return 42.0;", args);
77          Assert.assertEquals(42, 42, 0.0001);
78      }
79  }