*/
@Test
public void testPersistAndFind() {
// Create a new Role
Role expected = RoleBuilder.newInstance()
.withName("ROLE_TEST")
.withDescription("A test role")
.withAuthority(Authority.CHANGE_OWN_PASSWORD)
.build();
// Persist with insert
int originalRoleRows = countRowsInTable("roles");
int originalAuthorityRows = countRowsInTable("authorities");
testObject.saveOrUpdate(expected);
testObject.flush();
// Session flush: Expect an insert in roles and authorities
int updatedRoleRows = countRowsInTable("roles");
int updatedAuthorityRows = countRowsInTable("authorities");
assertThat("Expected session flush for first insert", updatedRoleRows, equalTo(originalRoleRows + 1));
assertThat("Unexpected data in authorities", updatedAuthorityRows, equalTo(originalAuthorityRows + 1));
// Perform an update to the Role that should not update authorities
expected.setDescription("An updated test role");
expected=testObject.saveOrUpdate(expected);
testObject.flush();
// Session flush: Expect no change to roles, authorities
updatedRoleRows = countRowsInTable("roles");