public void testFKToCMPMapping()
throws Exception
{
GroupLocal kv61Group = null;
GroupLocal kv62Group = null;
ExamenationLocal exam = null;
try {
kv62Group = getGroupHome().create("KV", 62, "KV-62");
exam = getExamHome().create("kv61-1", "Math", "KV", 62);
assertTrue("kv62Group.isIdentical(exam.getGroup())", kv62Group.isIdentical(exam.getGroup()));
assertTrue("kv62Group.getExamenations().contains(exam)", kv62Group.getExamenations().contains(exam));
kv61Group = getGroupHome().create("KV", 61, "KV-61");
exam.setGroup(kv61Group);
assertTrue("expected: exam.getGroupNumber() == 61;"
+ " got: exam.getGroupNumber() == " + exam.getGroupNumber(),
exam.getGroupNumber() == 61);
exam.setGroupNumber(62);
assertTrue("kv62Group.isIdentical(exam.getGroup())", kv62Group.isIdentical(exam.getGroup()));
assertTrue("kv62Group.getExamenations().contains(exam);", kv62Group.getExamenations().contains(exam));
assertTrue("kv61Group.getExamenations().isEmpty();", kv61Group.getExamenations().isEmpty());
exam.setDepartmentCode("KM");
exam.setDepartmentCode2("XKM");
assertTrue("exam.getGroup() == null", exam.getGroup() == null);
assertTrue("kv62Group.getExamenations().isEmpty();", kv62Group.getExamenations().isEmpty());
exam.setDepartmentCode("KV");
exam.setDepartmentCode2("XKV");
assertTrue("kv62Group.isIdentical(exam.getGroup())", kv62Group.isIdentical(exam.getGroup()));
assertTrue("kv62Group.getExamenations().contains(exam);", kv62Group.getExamenations().contains(exam));
} finally {
removeEntity(exam);
removeEntity(kv61Group);
removeEntity(kv62Group);