Project

General

Profile

« Previous | Next » 

Revision b7317c6c

Added by Andreas Müller almost 6 years ago

cleanup

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/TimePeriodTest.java
5 5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/ 
8
*/
9 9

  
10 10
package eu.etaxonomy.cdm.model.common;
11 11

  
......
22 22
import org.joda.time.MutableDateTime;
23 23
import org.joda.time.Partial;
24 24
import org.joda.time.ReadableInstant;
25
import org.junit.After;
26 25
import org.junit.Assert;
27 26
import org.junit.Before;
28 27
import org.junit.Test;
......
37 36
public class TimePeriodTest {
38 37
	@SuppressWarnings("unused")
39 38
	private static final Logger logger = Logger.getLogger(TimePeriodTest.class);
40
	
39

  
41 40
	private TimePeriod onlyStartYear;
42 41
	private TimePeriod onlyEndYear;
43 42
	private TimePeriod startAndEndYear;
......
45 44
	private static final Integer year = 1982;
46 45
	private static final Integer month = 1;
47 46
	private static final Integer day = 5;
48
	
49
		
50

  
51 47

  
52 48
	/**
53 49
	 * @throws java.lang.Exception
......
59 55
		startAndEndYear = TimePeriod.NewInstance(1931, 1957);
60 56
		Integer start = null;
61 57
		Integer end = null;
62
		noStartAndEndYear = TimePeriod.NewInstance(start, end);;
58
		noStartAndEndYear = TimePeriod.NewInstance(start, end);
63 59
	}
64 60

  
65
	/**
66
	 * @throws java.lang.Exception
67
	 */
68
	@After
69
	public void tearDown() throws Exception {
70
	}
61
//************************ TESTS ******************************************
71 62

  
72
	
73
//************************ TESTS ******************************************	
74
	
75 63
	/**
76 64
	 * Test method for {@link eu.etaxonomy.cdm.model.common.TimePeriod#NewInstance()}.
77 65
	 */
......
173 161
		TimePeriod tp = TimePeriod.NewInstance(readInst);
174 162
		Assert.assertNotNull(tp);
175 163
		Assert.assertFalse("Timeperiod should not be empty",tp.isEmpty());
176
		Assert.assertEquals("Timeperiod's should not be empty", (Integer)readInst.get(DateTimeFieldType.dayOfMonth()), (Integer)tp.getStartDay());
164
		Assert.assertEquals("Timeperiod's should not be empty", (Integer)readInst.get(DateTimeFieldType.dayOfMonth()), tp.getStartDay());
177 165
	}
178 166

  
179 167
	/**
......
185 173
		ReadableInstant readInst2 = new MutableDateTime();
186 174
		((MutableDateTime)readInst).addDays(5);
187 175
		TimePeriod tp = TimePeriod.NewInstance(readInst, readInst2);
188
		
176

  
189 177
		Assert.assertNotNull(tp);
190 178
		Assert.assertFalse("Timeperiod should not be empty",tp.isEmpty());
191 179
		Assert.assertEquals("Timeperiod's day should not be equal to readable instant", (Integer)readInst.get(DateTimeFieldType.dayOfMonth()), tp.getStartDay());
......
239 227
		tp.setStart(newStartDate);
240 228
		String changedString = tp.toString();
241 229
		Assert.assertTrue("Setting the partial should change the string representation of the TimePeriod", !startString.equals(changedString));
242
		
230

  
243 231
		//
244 232
		tp = TimePeriodParser.parseString("1752");
245 233
		assertNull("Freetext should be not set", tp.getFreeText());
......
256 244
		changedString = tp.toString();
257 245
		Assert.assertEquals("Setting a partial for a time period having the freetext set should not change the string representation of the TimePeriod	", startString, changedString);
258 246

  
259
		
247

  
260 248
		//
261 249
//		tp = TimePeriodParser.parseString("15.12.1730"); //TODO currently not parsed
262
//		
250
//
263 251
//		startString = tp.toString();
264 252
//		tp.setStart(newStartDate);
265 253
//		changedString = tp.toString();
266
//				
254
//
267 255
//		Assert.assertTrue("Setting a partial for a parsed time period should change the string representation of the TimePeriod	", !startString.equals(changedString));
268 256
	}
269 257

  
......
279 267
		onlyStartYear.setEndDay(14);
280 268
		assertFalse(onlyStartYear.isPeriod());
281 269
		onlyStartYear.setEndYear(1988);
282
		assertTrue(onlyStartYear.isPeriod()); //may be discussed		
270
		assertTrue(onlyStartYear.isPeriod()); //may be discussed
283 271
	}
284 272

  
285 273
	/**
......
318 306
		tp.setEndYear(2002);
319 307
		Assert.assertEquals("Year should be 1999-2002", "1999-2002", tp.getYear());
320 308
	}
321
	
322
	
309

  
310

  
323 311
	/**
324
	 * TODO should be partly moved to a test class for {@link TimePeriodPartialFormatter}	
312
	 * TODO should be partly moved to a test class for {@link TimePeriodPartialFormatter}
325 313
	 */
326 314
	@Test
327 315
	public void testToStringTimePeriod() {
......
333 321
		tp1.setEndMonth(11);
334 322
		Assert.assertEquals("3.xx.1788-11.1799", tp1.toString());
335 323
	}
336
	
324

  
337 325

  
338 326
	/**
339 327
	 * Test method for {@link eu.etaxonomy.cdm.model.common.TimePeriod#clone()}.
......
373 361
		Integer endDay = 21;
374 362
		Integer endYear = 1799;
375 363
		String freeText = "A free period";
376
		
364

  
377 365
		TimePeriod tp1 = TimePeriod.NewInstance(startYear);
378 366
		TimePeriod tpClone = (TimePeriod)tp1.clone();
379 367
		Assert.assertEquals("Cloned time period must be equal to originial", tp1, tpClone);
380
		
368

  
381 369
		tp1.setStartMonth(startMonth);
382 370
		Assert.assertFalse("Cloned time period must not be equal to originial", tp1.equals(tpClone));
383 371
		tpClone = (TimePeriod)tp1.clone();
384 372
		Assert.assertEquals("Cloned time period must be equal to originial", tp1, tpClone);
385
		
373

  
386 374

  
387 375
		tp1.setEndYear(endYear);
388 376
		Assert.assertFalse("Cloned time period must not be equal to originial", tp1.equals(tpClone));
......
393 381
		Assert.assertFalse("Cloned time period must not be equal to originial", tp1.equals(tpClone));
394 382
		tpClone = (TimePeriod)tp1.clone();
395 383
		Assert.assertEquals("Cloned time period must be equal to originial", tp1, tpClone);
396
		
384

  
397 385
		tp1.setFreeText(freeText);
398 386
		Assert.assertFalse("Cloned time period must not be equal to originial", tp1.equals(tpClone));
399 387
		tpClone = (TimePeriod)tp1.clone();
......
412 400
		Assert.assertEquals("Tp2 must be equal", tp1, tp2);
413 401
	}
414 402

  
415
	
416
	
403

  
404

  
417 405
}

Also available in: Unified diff