View Javadoc
1   /*
2    * #%L
3    * IsisFish
4    * 
5    * $Id: SimulationMonitorTest.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/simulator/launcher/SimulationMonitorTest.java $
7    * %%
8    * Copyright (C) 2006 - 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.simulator.launcher;
27  
28  import java.util.AbstractMap.SimpleEntry;
29  import java.util.Comparator;
30  import java.util.Date;
31  import java.util.SortedSet;
32  import java.util.TreeSet;
33  
34  import org.junit.Assert;
35  import org.junit.Test;
36  
37  import fr.ifremer.isisfish.AbstractIsisFishTest;
38  import fr.ifremer.isisfish.simulator.SimulationControl;
39  import fr.ifremer.isisfish.simulator.SimulationParameterImpl;
40  
41  /**
42   * Test de la class SimulationMonitor.
43   * 
44   * @author chatellier
45   * @version $Revision: 4156 $
46   * 
47   * Last update : $Date: 2014-12-09 12:27:18 +0100 (Tue, 09 Dec 2014) $
48   * By : $Author: echatellier $
49   */
50  public class SimulationMonitorTest extends AbstractIsisFishTest {
51  
52      protected SortedSet<SimpleEntry<Date, SimulationJob>> checkSet = new TreeSet<SimpleEntry<Date, SimulationJob>>(new Comparator<SimpleEntry<Date, SimulationJob>>(){
53          @Override
54          public int compare(SimpleEntry<Date, SimulationJob> o1,
55                  SimpleEntry<Date, SimulationJob> o2) {
56              
57              int result = o1.getKey().compareTo(o2.getKey());
58              if (result == 0) {
59                  result = o1.getValue().compareTo(o2.getValue());
60              }
61              return result;
62          }
63          
64      });
65      
66      @Test
67      public void testSimulationSetUniqueNess() {
68          SimulationService service = SimulationService.getService();
69          
70          SimulationControl control1 = new SimulationControl("test1");
71          SimulationItem item1 = new SimulationItem(control1, new SimulationParameterImpl());
72          SimulationJob job1 = new SimulationJob(service, item1, 0);
73          
74          SimulationControl control2 = new SimulationControl("test2");
75          SimulationItem item2 = new SimulationItem(control2, new SimulationParameterImpl());
76          SimulationJob job2 = new SimulationJob(service, item2, 0);
77          
78          Date d = new Date();
79          checkSet.add(new SimpleEntry<Date, SimulationJob>(d, job1));
80          checkSet.add(new SimpleEntry<Date, SimulationJob>(d, job2));
81          
82          Assert.assertEquals(2, checkSet.size());
83      }
84  }