PageRenderTime 32ms CodeModel.GetById 11ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/hippo/src/test/java/com/googlecode/hdbc/model/validator/ExperimentDataValidatorTest.java

http://hdbc.googlecode.com/
Java | 47 lines | 33 code | 8 blank | 6 comment | 0 complexity | 0ddf6836e9ba93cfe7c1cca873d4998d MD5 | raw file
 1package com.googlecode.hdbc.model.validator;
 2
 3import static org.junit.Assert.*;
 4
 5import org.junit.Before;
 6import org.junit.Test;
 7import org.springframework.validation.BeanPropertyBindingResult;
 8import org.springframework.validation.Errors;
 9import org.springframework.validation.Validator;
10
11import com.googlecode.hdbc.model.record.ExperimentData;
12
13public class ExperimentDataValidatorTest {
14	private ExperimentData data;
15	private Validator validator;
16	
17	@Before
18	public final void setUp() {
19		data = new ExperimentData(-1L, 
20				"title that is way to long aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 
21				"purpose");
22		validator = new ExperimentDataValidator();
23	}
24	
25	/**
26	 * Test a item with a bad uid and title
27	 */
28	@Test
29	public final void testBadEquipmentData() {
30		Errors errors = new BeanPropertyBindingResult(data, "experimentData");
31		validator.validate(data, errors);
32		assertEquals(2, errors.getErrorCount());
33	}
34	
35	/**
36	 * Test a minimally correct EquipmentData
37	 */
38	@Test
39	public final void testMinimalCorrectObject() {
40		data.setUid(null);
41		data.setTitle("aTitle");
42		Errors errors = new BeanPropertyBindingResult(data, "experimentData");
43		validator.validate(data, errors);
44		assertEquals(0, errors.getErrorCount());
45	}
46	
47}