HandicapGroupSetDao extends BaseHibernateEntityDao<HandicapGroupSetHibernateEntity> { @Override public void create(HandicapGroupSetHibernateEntity entity) { persist(entity); } @Inject  HandicapGroupSetDao(SessionFactory sessionFactory); @Override void create(HandicapGroupSetHibernateEntity entity); @Override List<HandicapGroupSetHibernateEntity> findAll(); @Override HandicapGroupSetHibernateEntity findById(String id);  }
@Test public void itShouldSaveMultipleSetsAssociatedToSameHandicapGroup() { daoTestRule.inTransaction(() -> { HandicapGroupHibernateEntity entity = HibernateEntityTestUtils.fullHandicapGroup(); entity.setId(null); entityDao.create(entity); HandicapGroupSetHibernateEntity setEntity1 = HibernateEntityTestUtils.fullHandicapGroupSet(); setEntity1.setId(null); setEntity1.setHandicapGroups(Sets.newHashSet()); setDao.create(setEntity1); HandicapGroupSetHibernateEntity setEntity2 = HibernateEntityTestUtils.fullHandicapGroupSet(); setEntity2.setId(null); setEntity2.setHandicapGroups(Sets.newHashSet()); setDao.create(setEntity2); assertThat(setEntity1.getId()).isNotEqualTo(setEntity2.getId()); setEntity1.getHandicapGroups().add(entity); setEntity2.getHandicapGroups().add(entity); setDao.update(setEntity1); setDao.update(setEntity2); }); }
@Test public void itShouldSaveOneSetAssociatedtoMultipleHandicapGroups() { daoTestRule.inTransaction(() -> { HandicapGroupHibernateEntity entity1 = HibernateEntityTestUtils.fullHandicapGroup(); entity1.setId(null); entityDao.create(entity1); HandicapGroupHibernateEntity entity2 = HibernateEntityTestUtils.fullHandicapGroup(); entity2.setId(null); entityDao.create(entity2); assertThat(entity1.getId()).isNotEqualTo(entity2.getId()); HandicapGroupSetHibernateEntity setEntity = HibernateEntityTestUtils.fullHandicapGroupSet(); setEntity.setId(null); setEntity.setHandicapGroups(Sets.newHashSet(entity1, entity2)); setDao.create(setEntity); }); }
@Test public void itShouldCreateWithMultipleHandicapGroups() { daoTestRule.inTransaction(() -> { HandicapGroupHibernateEntity ssEntity = HibernateEntityTestUtils.fullHandicapGroup( null, "SS", BigDecimal.valueOf(0.826d) ); entityDao.create(ssEntity); HandicapGroupHibernateEntity asEntity = HibernateEntityTestUtils.fullHandicapGroup( null, "AS", BigDecimal.valueOf(0.819d) ); entityDao.create(asEntity); HandicapGroupHibernateEntity bsEntity = HibernateEntityTestUtils.fullHandicapGroup( null, "BS", BigDecimal.valueOf(0.813d) ); entityDao.create(bsEntity); HandicapGroupSetHibernateEntity setEntity = HibernateEntityTestUtils.fullHandicapGroupSet( null, "2017 PAX/RTP INDEX", Sets.newHashSet(ssEntity, asEntity, bsEntity) ); setDao.create(setEntity); }); }