org.springframework.jdbc.core.test.Person Java Examples

The following examples show how to use org.springframework.jdbc.core.test.Person. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeanPropertyRowMapperTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testMappingNullValue() throws Exception {
	BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class);
	Mock mock = new Mock(MockType.TWO);
	thrown.expect(TypeMismatchException.class);
	mock.getJdbcTemplate().query(
			"select name, null as age, birth_date, balance from people", mapper);
}
 
Example #2
Source File: BeanPropertyRowMapperTests.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
@Test
public void testStaticQueryWithRowMapper() throws Exception {
	Mock mock = new Mock();
	List<Person> result = mock.getJdbcTemplate().query(
			"select name, age, birth_date, balance from people",
			new BeanPropertyRowMapper<Person>(Person.class));
	assertEquals(1, result.size());
	verifyPerson(result.get(0));
	mock.verifyClosed();
}
 
Example #3
Source File: BeanPropertyRowMapperTests.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testOverridingDifferentClassDefinedForMapping() {
	BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class);
	thrown.expect(InvalidDataAccessApiUsageException.class);
	mapper.setMappedClass(Long.class);
}
 
Example #4
Source File: BeanPropertyRowMapperTests.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
@Test
public void testMappingNullValue() throws Exception {
	BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<Person>(Person.class);
	Mock mock = new Mock(MockType.TWO);
	thrown.expect(TypeMismatchException.class);
	mock.getJdbcTemplate().query(
			"select name, null as age, birth_date, balance from people", mapper);
}
 
Example #5
Source File: BeanPropertyRowMapperTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testMappingNullValue() throws Exception {
	BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<Person>(Person.class);
	Mock mock = new Mock(MockType.TWO);
	thrown.expect(TypeMismatchException.class);
	mock.getJdbcTemplate().query(
			"select name, null as age, birth_date, balance from people", mapper);
}
 
Example #6
Source File: BeanPropertyRowMapperTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void testStaticQueryWithRowMapper() throws Exception {
	Mock mock = new Mock();
	List<Person> result = mock.getJdbcTemplate().query(
			"select name, age, birth_date, balance from people",
			new BeanPropertyRowMapper<Person>(Person.class));
	assertEquals(1, result.size());
	verifyPerson(result.get(0));
	mock.verifyClosed();
}
 
Example #7
Source File: BeanPropertyRowMapperTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testOverridingDifferentClassDefinedForMapping() {
	BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class);
	assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
			mapper.setMappedClass(Long.class));
}
 
Example #8
Source File: BeanPropertyRowMapperTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testOverridingDifferentClassDefinedForMapping() {
	BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class);
	thrown.expect(InvalidDataAccessApiUsageException.class);
	mapper.setMappedClass(Long.class);
}
 
Example #9
Source File: BeanPropertyRowMapperTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void testStaticQueryWithRowMapper() throws Exception {
	Mock mock = new Mock();
	List<Person> result = mock.getJdbcTemplate().query(
			"select name, age, birth_date, balance from people",
			new BeanPropertyRowMapper<>(Person.class));
	assertEquals(1, result.size());
	verifyPerson(result.get(0));
	mock.verifyClosed();
}
 
Example #10
Source File: ParameterizedBeanPropertyRowMapperTests.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testOverridingDifferentClassDefinedForMapping() {
	ParameterizedBeanPropertyRowMapper mapper = ParameterizedBeanPropertyRowMapper.newInstance(Person.class);
	thrown.expect(InvalidDataAccessApiUsageException.class);
	mapper.setMappedClass(Long.class);
}
 
Example #11
Source File: BeanPropertyRowMapperTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testOverridingDifferentClassDefinedForMapping() {
	BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class);
	thrown.expect(InvalidDataAccessApiUsageException.class);
	mapper.setMappedClass(Long.class);
}
 
Example #12
Source File: BeanPropertyRowMapperTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testMappingNullValue() throws Exception {
	BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class);
	Mock mock = new Mock(MockType.TWO);
	assertThatExceptionOfType(TypeMismatchException.class).isThrownBy(() ->
			mock.getJdbcTemplate().query("select name, null as age, birth_date, balance from people", mapper));
}
 
Example #13
Source File: BeanPropertyRowMapperTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void testStaticQueryWithRowMapper() throws Exception {
	Mock mock = new Mock();
	List<Person> result = mock.getJdbcTemplate().query(
			"select name, age, birth_date, balance from people",
			new BeanPropertyRowMapper<>(Person.class));
	assertEquals(1, result.size());
	verifyPerson(result.get(0));
	mock.verifyClosed();
}
 
Example #14
Source File: ParameterizedBeanPropertyRowMapperTests.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
@Test
public void testStaticQueryWithRowMapper() throws Exception {
	Mock mock = new Mock();
	List<Person> result = mock.getJdbcTemplate().query(
			"select name, age, birth_date, balance from people",
			ParameterizedBeanPropertyRowMapper.newInstance(Person.class));
	assertEquals(1, result.size());
	verifyPerson(result.get(0));
	mock.verifyClosed();
}
 
Example #15
Source File: BeanPropertyRowMapperTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Test
public void testOverridingSameClassDefinedForMapping() {
	BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<Person>(Person.class);
	mapper.setMappedClass(Person.class);
}
 
Example #16
Source File: AbstractRowMapperTests.java    From effectivejava with Apache License 2.0 4 votes vote down vote up
protected void verifyPerson(Person bean) throws Exception {
	assertEquals("Bubba", bean.getName());
	assertEquals(22L, bean.getAge());
	assertEquals(new java.util.Date(1221222L), bean.getBirth_date());
	assertEquals(new BigDecimal("1234.56"), bean.getBalance());
}
 
Example #17
Source File: ParameterizedBeanPropertyRowMapperTests.java    From effectivejava with Apache License 2.0 4 votes vote down vote up
@Test
public void testOverridingSameClassDefinedForMapping() {
	ParameterizedBeanPropertyRowMapper<Person> mapper = ParameterizedBeanPropertyRowMapper.newInstance(Person.class);
	mapper.setMappedClass(Person.class);
}
 
Example #18
Source File: BeanPropertyRowMapperTests.java    From effectivejava with Apache License 2.0 4 votes vote down vote up
@Test
public void testOverridingSameClassDefinedForMapping() {
	BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<Person>(Person.class);
	mapper.setMappedClass(Person.class);
}
 
Example #19
Source File: AbstractRowMapperTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
protected void verifyPerson(Person bean) throws Exception {
	assertEquals("Bubba", bean.getName());
	assertEquals(22L, bean.getAge());
	assertEquals(new java.util.Date(1221222L), bean.getBirth_date());
	assertEquals(new BigDecimal("1234.56"), bean.getBalance());
}
 
Example #20
Source File: AbstractRowMapperTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
protected void verifyPerson(Person bean) throws Exception {
	assertEquals("Bubba", bean.getName());
	assertEquals(22L, bean.getAge());
	assertEquals(new java.util.Date(1221222L), bean.getBirth_date());
	assertEquals(new BigDecimal("1234.56"), bean.getBalance());
}
 
Example #21
Source File: BeanPropertyRowMapperTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Test
public void testOverridingSameClassDefinedForMapping() {
	BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class);
	mapper.setMappedClass(Person.class);
}
 
Example #22
Source File: AbstractRowMapperTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
protected void verifyPerson(Person bean) throws Exception {
	assertEquals("Bubba", bean.getName());
	assertEquals(22L, bean.getAge());
	assertEquals(new java.util.Date(1221222L), bean.getBirth_date());
	assertEquals(new BigDecimal("1234.56"), bean.getBalance());
}
 
Example #23
Source File: BeanPropertyRowMapperTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Test
public void testOverridingSameClassDefinedForMapping() {
	BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class);
	mapper.setMappedClass(Person.class);
}