JPA Entities and the Serializable Interface - formatting

This commit is contained in:
Mladen Savic 2021-07-01 19:43:04 +02:00
parent 860605b3e9
commit ec09e1293f
1 changed files with 25 additions and 25 deletions

View File

@ -40,33 +40,33 @@ public class JPASerializableIntegrationTest {
assertEquals("johndoe", userDb.getEmail().getName()); assertEquals("johndoe", userDb.getEmail().getName());
} }
@Test @Test
public void givenAssociation_whenPersisted_thenMultipleAccountsWillBeFoundByEmail() { public void givenAssociation_whenPersisted_thenMultipleAccountsWillBeFoundByEmail() {
UserId userId = new UserId(); UserId userId = new UserId();
userId.setName("John"); userId.setName("John");
userId.setLastName("Doe"); userId.setLastName("Doe");
Email email = new Email(); Email email = new Email();
email.setId(1); email.setId(1);
email.setName("johndoe"); email.setName("johndoe");
email.setDomain("gmail.com"); email.setDomain("gmail.com");
User user = new User(userId, email); User user = new User(userId, email);
Account account = new Account(); Account account = new Account();
account.setType("test"); account.setType("test");
account.setId(10); account.setId(10);
account.setUser(user); account.setUser(user);
Account account2 = new Account(); Account account2 = new Account();
account2.setType("main"); account2.setType("main");
account2.setId(11); account2.setId(11);
account2.setUser(user); account2.setUser(user);
entityManager.persist(user); entityManager.persist(user);
entityManager.persist(account); entityManager.persist(account);
entityManager.persist(account2); entityManager.persist(account2);
List userAccounts = entityManager.createQuery("select a from Account a join fetch a.user where a.user.email = :email") List userAccounts = entityManager.createQuery("select a from Account a join fetch a.user where a.user.email = :email")
.setParameter("email", email).getResultList(); .setParameter("email", email).getResultList();
assertEquals(2, userAccounts.size()); assertEquals(2, userAccounts.size());
} }
@After @After
public void tearDown() { public void tearDown() {