@PersistenceContext
private EntityManager entityManager;
@Test
public void testPersistPolicyType() {
final PolicyType policyType1 = new PolicyType("КАСКО", "машины");
final PolicySeries serie1 = new PolicySeries("KKKKKK");
final PolicySeries serie2 = new PolicySeries("KIKIKI");
final PolicySeries serie3 = new PolicySeries("IKIKIK");
policyType1.getTypeSeries().add(serie1);
policyType1.getTypeSeries().add(serie2);
policyType1.getTypeSeries().add(serie3);
serie1.setPolicyType(policyType1);
serie2.setPolicyType(policyType1);
serie3.setPolicyType(policyType1);
policyTypeDAO.persistPolicyType(policyType1);
final PolicyType policyType2 = new PolicyType("Жизнь", "жизнь");
final PolicySeries serie21 = new PolicySeries("JJJJJJ");
final PolicySeries serie22 = new PolicySeries("JIDKIL");
final PolicySeries serie23 = new PolicySeries("MKIOLM");
policyType2.getTypeSeries().add(serie21);
policyType2.getTypeSeries().add(serie22);
policyType2.getTypeSeries().add(serie23);
serie21.setPolicyType(policyType2);
serie22.setPolicyType(policyType2);
serie23.setPolicyType(policyType2);
policyTypeDAO.persistPolicyType(policyType2);
final PolicyType policyType3 = new PolicyType("дом", "дом");
final PolicySeries serie31 = new PolicySeries("OPLIHN");
final PolicySeries serie32 = new PolicySeries("JFYNDT");
final PolicySeries serie33 = new PolicySeries("PROUFN");
policyType3.getTypeSeries().add(serie31);
policyType3.getTypeSeries().add(serie32);
policyType3.getTypeSeries().add(serie33);
serie31.setPolicyType(policyType3);
serie32.setPolicyType(policyType3);
serie33.setPolicyType(policyType3);
policyTypeDAO.persistPolicyType(policyType3);
assertEquals(policyType1, entityManager.find(PolicyType.class, policyType1.getId()));
assertEquals(policyType2, entityManager.find(PolicyType.class, policyType2.getId()));
assertEquals(policyType3, entityManager.find(PolicyType.class, policyType3.getId()));
}