Add test
This commit is contained in:
parent
956da855cd
commit
1dbda278f9
|
@ -48,6 +48,58 @@ public class ArrayTests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void emptyArrayTest(SessionFactoryScope scope) {
|
||||||
|
scope.inTransaction(
|
||||||
|
session -> {
|
||||||
|
Employee employee = new Employee( 2, "Andrea" );
|
||||||
|
session.save( employee );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
scope.inTransaction(
|
||||||
|
session -> {
|
||||||
|
final QueryImplementor<Employee> query = session.createQuery(
|
||||||
|
"select e from Employee e where e.id = :id",
|
||||||
|
Employee.class
|
||||||
|
);
|
||||||
|
final Employee result = query.setParameter( "id", 2 ).uniqueResult();
|
||||||
|
|
||||||
|
assertThat( result, notNullValue() );
|
||||||
|
assertThat( result.getName(), is( "Andrea" ) );
|
||||||
|
String[] todo = result.getToDoList();
|
||||||
|
assertThat( todo.length, is( 0 ) );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
scope.inTransaction(
|
||||||
|
session -> {
|
||||||
|
final QueryImplementor<Employee> query = session.createQuery(
|
||||||
|
"select e from Employee e ",
|
||||||
|
Employee.class
|
||||||
|
);
|
||||||
|
final List<Employee> results = query.list();
|
||||||
|
|
||||||
|
assertThat( results.size(), is( 2 ) );
|
||||||
|
results.forEach( employee -> {
|
||||||
|
if ( employee.getId() == 1 ) {
|
||||||
|
assertThat( employee.getName(), is( "Koen" ) );
|
||||||
|
String[] todo = employee.getToDoList();
|
||||||
|
assertThat( todo.length, is( 3 ) );
|
||||||
|
assertThat( todo[0], is( "metro" ) );
|
||||||
|
assertThat( todo[1], is( "boulot" ) );
|
||||||
|
assertThat( todo[2], is( "dodo" ) );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assertThat( employee.getName(), is( "Andrea" ) );
|
||||||
|
String[] todo = employee.getToDoList();
|
||||||
|
assertThat( todo.length, is( 0 ) );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp(SessionFactoryScope scope) {
|
public void setUp(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
|
|
Loading…
Reference in New Issue