use of org.springframework.integration.jpa.test.entity.StudentDomain in project spring-integration by spring-projects.
the class JpaTests method testRetrievingGatewayFlow.
@Test
public void testRetrievingGatewayFlow() {
this.retrievingGatewayFlowInput.send(MessageBuilder.withPayload(1002L).build());
Message<?> receive = this.retrieveResults.receive(10_000);
assertNotNull(receive);
assertThat(receive.getPayload(), instanceOf(StudentDomain.class));
StudentDomain student = (StudentDomain) receive.getPayload();
assertEquals("First Two", student.getFirstName());
assertEquals(Gender.FEMALE, student.getGender());
}
use of org.springframework.integration.jpa.test.entity.StudentDomain in project spring-integration by spring-projects.
the class JpaTests method testInboundAdapterFlow.
@Test
public void testInboundAdapterFlow() {
Message<?> message = this.pollingResults.receive(10_000);
assertNotNull(message);
assertThat(message.getPayload(), instanceOf(StudentDomain.class));
StudentDomain student = (StudentDomain) message.getPayload();
assertEquals("First One", student.getFirstName());
}
use of org.springframework.integration.jpa.test.entity.StudentDomain in project spring-integration by spring-projects.
the class JpaTests method testOutboundAdapterFlow.
@Test
public void testOutboundAdapterFlow() {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
List<?> results1 = jdbcTemplate.queryForList("Select * from Student");
assertNotNull(results1);
assertTrue(results1.size() == 3);
Calendar dateOfBirth = Calendar.getInstance();
dateOfBirth.set(1981, 9, 27);
StudentDomain student = new StudentDomain().withFirstName("Artem").withLastName("Bilan").withGender(Gender.MALE).withDateOfBirth(dateOfBirth.getTime()).withLastUpdated(new Date());
assertNull(student.getRollNumber());
this.outboundAdapterFlowInput.send(MessageBuilder.withPayload(student).build());
List<?> results2 = jdbcTemplate.queryForList("Select * from Student");
assertNotNull(results2);
assertTrue(results2.size() == 4);
assertNotNull(student.getRollNumber());
}
use of org.springframework.integration.jpa.test.entity.StudentDomain in project spring-integration by spring-projects.
the class JpaOutboundChannelAdapterTransactionalTests method saveEntityWithTransaction.
@Test
@DirtiesContext
public void saveEntityWithTransaction() throws InterruptedException {
List<?> results1 = new JdbcTemplate(dataSource).queryForList("Select * from Student");
Assert.assertNotNull(results1);
Assert.assertTrue(results1.size() == 3);
StudentDomain testStudent = JpaTestUtils.getTestStudent();
Message<StudentDomain> message = MessageBuilder.withPayload(testStudent).build();
channel.send(message);
List<?> results2 = new JdbcTemplate(dataSource).queryForList("Select * from Student");
Assert.assertNotNull(results2);
Assert.assertTrue(results2.size() == 4);
Assert.assertNull(testStudent.getRollNumber());
}
use of org.springframework.integration.jpa.test.entity.StudentDomain in project spring-integration by spring-projects.
the class JpaOutboundGatewayTests method persistStudent.
@Test
@Transactional
public void persistStudent() {
final StudentDomain studentToPersist = JpaTestUtils.getTestStudent();
Assert.assertNull(studentToPersist.getRollNumber());
final StudentDomain persistedStudent = studentService.persistStudent(studentToPersist);
Assert.assertNotNull(persistedStudent);
Assert.assertNotNull(persistedStudent.getRollNumber());
}
Aggregations