Example #1
0
 private void setEventData(AbstractHibernateObject entity) {
   // Be careful to check for null before setting so we don't overwrite anything useful
   if (entity instanceof Named && ((Named) entity).getName() != null) {
     event.setTargetName(((Named) entity).getName());
   }
   if (entity instanceof Owned) {
     Owner entityOwner = ((Owned) entity).getOwner();
     if (entityOwner != null && entityOwner.getId() != null) {
       event.setOwnerId(entityOwner.getId());
     }
   }
   if (entity instanceof Entitlement) {
     event.setReferenceType(Event.ReferenceType.POOL);
     Pool referencedPool = ((Entitlement) entity).getPool();
     if (referencedPool != null && referencedPool.getId() != null) {
       event.setReferenceId(referencedPool.getId());
     }
   }
   if ((String) entity.getId() != null) {
     event.setEntityId((String) entity.getId());
     if (entity instanceof ConsumerProperty) {
       Consumer owningConsumer = ((ConsumerProperty) entity).getConsumer();
       if (owningConsumer != null && owningConsumer.getId() != null) {
         event.setConsumerId(owningConsumer.getId());
       }
     }
   }
 }
Example #2
0
 @Test
 public void testCreate() {
   Pool lookedUp = entityManager().find(Pool.class, pool.getId());
   assertNotNull(lookedUp);
   assertEquals(owner.getId(), lookedUp.getOwner().getId());
   assertEquals(prod1.getId(), lookedUp.getProductId());
   assertTrue(lookedUp.provides(prod1.getId()));
 }