Search in sources :

Example 1 with EventFactory

use of org.candlepin.audit.EventFactory in project candlepin by candlepin.

the class OwnerResourceTest method testConflictOnDelete.

@Test(expected = ConflictException.class)
public void testConflictOnDelete() {
    Owner o = mock(Owner.class);
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    OwnerManager ownerManager = mock(OwnerManager.class);
    EventFactory eventFactory = mock(EventFactory.class);
    OwnerResource or = new OwnerResource(oc, pc, null, null, i18n, null, eventFactory, null, null, null, poolManager, ownerManager, null, null, null, null, null, null, null, null, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
    when(oc.lookupByKey(eq("testOwner"))).thenReturn(o);
    ConstraintViolationException ce = new ConstraintViolationException(null, null, null);
    PersistenceException pe = new PersistenceException(ce);
    Mockito.doThrow(pe).when(ownerManager).cleanupAndDelete(eq(o), eq(true));
    or.deleteOwner("testOwner", true, true);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ProductCurator(org.candlepin.model.ProductCurator) PersistenceException(javax.persistence.PersistenceException) EventFactory(org.candlepin.audit.EventFactory) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) OwnerManager(org.candlepin.controller.OwnerManager) Test(org.junit.Test)

Aggregations

PersistenceException (javax.persistence.PersistenceException)1 EventFactory (org.candlepin.audit.EventFactory)1 OwnerManager (org.candlepin.controller.OwnerManager)1 Owner (org.candlepin.model.Owner)1 OwnerCurator (org.candlepin.model.OwnerCurator)1 ProductCurator (org.candlepin.model.ProductCurator)1 ConstraintViolationException (org.hibernate.exception.ConstraintViolationException)1 Test (org.junit.Test)1