BusinessObjectFactory { public Permission newPermission(Site owner) { Permission permission = new Permission(); permission.setIdentity(getNewIdentity()); permission.setStatus(Permission.STATUS_PENDING); permission.setSite(owner); permission.setOwningAgency(owner.getOwningAgency()); permission.setCreationDate(new Date()); return permission; }  Schedule newSchedule(AbstractTarget owner); AuthorisingAgent newAuthorisingAgent(); Seed newSeed(Target owner); SeedHistory newSeedHistory(TargetInstance owner, Seed seed); UrlPattern newUrlPattern(Site owner); Permission newPermission(Site owner); Target newTarget(); Target newTarget(User theUser); TargetGroup newTargetGroup(); void setProfileManager(ProfileManager profileManager);  }
@Test public final void testNewPermission() { UserRoleDAO urDao = new MockUserRoleDAO(testFile); Site site1 = new Site(); site1.setOwningAgency(urDao.getAgencyByOid(2000L)); Permission permission1 = testInstance.newPermission(site1); assertTrue(permission1 != null); assertSame(permission1.getOwningAgency(), site1.getOwningAgency()); Site site2 = new Site(); site2.setOwningAgency(urDao.getAgencyByOid(2001L)); Permission permission2 = testInstance.newPermission(site2); assertTrue(permission2 != null); assertSame(permission2.getOwningAgency(), site2.getOwningAgency()); assertNotSame(site1.getOwningAgency(), site2.getOwningAgency()); }