public void testCreateExpertBeerConsumer() { EntityManager em = createEntityManager(); beginTransaction(em); ExpertBeerConsumer beerConsumer = new ExpertBeerConsumer(); try { beerConsumer.setName("Expert Beer Consumer"); beerConsumer.setIQ(110); beerConsumer.getAcclaims().add("A"); beerConsumer.getAcclaims().add("B"); beerConsumer.getAcclaims().add("C"); // Commenting out this mapping until bug 272298 is resolved. // beerConsumer.getAudio().add(new byte[]{1}); // beerConsumer.getAudio().add(new byte[]{2}); // beerConsumer.getAudio().add(new byte[]{3}); beerConsumer.getAwards().put("A", "A"); beerConsumer.getAwards().put("B", "B"); beerConsumer.getAwards().put("C", "C"); beerConsumer.getDesignations().add("A"); beerConsumer.getDesignations().add("B"); m_quote1Stamp = Helper.timestampFromDate(Helper.dateFromYearMonthDate(2009, 1, 1)); beerConsumer.getQuotes().put(m_quote1Stamp, QUOTE_ONE); m_quote2Stamp = Helper.timestampFromDate(Helper.dateFromYearMonthDate(2005, 7, 9)); beerConsumer.getQuotes().put(m_quote2Stamp, QUOTE_TWO); Record record1 = new Record(); record1.setDescription("Fastest beer ever consumed - 10 ms"); record1.setDate(Helper.dateFromYearMonthDate(2009, 10, 10)); record1.setLocation(new Location("Ottawa", "Canada")); beerConsumer.getRecords().add(record1); Record record2 = new Record(); record2.setDescription("Most beers consumed in a second - 5"); record2.setDate(Helper.dateFromYearMonthDate(2005, 12, 12)); record2.setLocation(new Location("Miami", "USA")); beerConsumer.getRecords().add(record2); Accredidation accredidation = new Accredidation(); accredidation.setDetails("Elite, absolutely elite!"); Witness witness1 = new Witness(); witness1.setName("Big Bobby"); accredidation.addWitness(witness1); Witness witness2 = new Witness(); witness2.setName("Little Bobby"); accredidation.addWitness(witness2); Official official = new Official(); official.setName("Authority Joe"); accredidation.addOfficial(official); beerConsumer.setAccredidation(accredidation); Birthday birthday1 = new Birthday(); birthday1.setDay(9); birthday1.setMonth(7); birthday1.setYear(2005); beerConsumer.addCelebration(birthday1, "Drank a 24 of Heineken"); Birthday birthday2 = new Birthday(); birthday2.setDay(10); birthday2.setMonth(7); birthday2.setYear(2006); beerConsumer.addCelebration(birthday2, "Drank a 24 of Becks"); Committee committee1 = new Committee(); committee1.setDescription("New beer committee"); beerConsumer.addCommittee(committee1); Committee committee2 = new Committee(); committee2.setDescription("Alcohol content regulation"); beerConsumer.addCommittee(committee2); em.persist(beerConsumer); m_expertBeerConsumerId = beerConsumer.getId(); commitTransaction(em); } catch (RuntimeException e) { if (isTransactionActive(em)) { rollbackTransaction(em); } closeEntityManager(em); fail( "An exception was caught during create operation for an expert beer consumer: [" + e.getMessage() + "]"); } closeEntityManager(em); clearCache(); em = createEntityManager(); BeerConsumer refreshedBC = em.find(BeerConsumer.class, m_expertBeerConsumerId); assertTrue( "The expert beer consumer read back did not match the original", getServerSession().compareObjects(beerConsumer, refreshedBC)); }