1   /*******************************************************************************
2    *   Gisgraphy Project 
3    * 
4    *   This library is free software; you can redistribute it and/or
5    *   modify it under the terms of the GNU Lesser General Public
6    *   License as published by the Free Software Foundation; either
7    *   version 2.1 of the License, or (at your option) any later version.
8    * 
9    *   This library is distributed in the hope that it will be useful,
10   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   *   Lesser General Public License for more details.
13   * 
14   *   You should have received a copy of the GNU Lesser General Public
15   *   License along with this library; if not, write to the Free Software
16   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
17   * 
18   *  Copyright 2008  Gisgraphy project 
19   *  David Masclet <davidmasclet@gisgraphy.com>
20   *  
21   *  
22   *******************************************************************************/
23  package com.gisgraphy.domain.geoloc.importer;
24  
25  import static org.junit.Assert.assertEquals;
26  
27  import java.util.List;
28  
29  import junit.framework.Assert;
30  
31  import org.easymock.classextension.EasyMock;
32  import org.junit.Test;
33  
34  import com.gisgraphy.domain.repository.ICountryDao;
35  import com.gisgraphy.domain.valueobject.NameValueDTO;
36  
37  public class GeonamesCountryImporterTest {
38  
39      @Test
40      public void rollbackShouldRollback() {
41  	GeonamesCountryImporter geonamesCountryImporter = new GeonamesCountryImporter();
42  	ICountryDao countryDao = EasyMock.createMock(ICountryDao.class);
43  	EasyMock.expect(countryDao.deleteAll()).andReturn(5);
44  	EasyMock.replay(countryDao);
45  	geonamesCountryImporter.setCountryDao(countryDao);
46  	List<NameValueDTO<Integer>> deleted = geonamesCountryImporter
47  		.rollback();
48  	assertEquals(1, deleted.size());
49  	assertEquals(5, deleted.get(0).getValue().intValue());
50      }
51      
52      @Test
53      public void shouldBeSkipShouldReturnCorrectValue(){
54  	GeonamesCountryImporter geonamesCountryImporter = new GeonamesCountryImporter();
55  	
56  	Assert.assertFalse("country importer should never be skiped",geonamesCountryImporter.shouldBeSkipped());
57  	
58  		
59      }
60  
61  }