### Question:
TransactionalBannerService extends AbstractTransactionalEntityService<Banner, BannerDao> implements BannerService { @Override @PreAuthorize("hasPermission(#forumComponent.id, 'COMPONENT', 'GeneralPermission.ADMIN')") public void uploadBanner(Banner uploadedBanner, Component forumComponent) { Banner existBanner = getDao().getByPosition(uploadedBanner.getPositionOnPage()); if (existBanner == null) { existBanner = uploadedBanner; } else { existBanner.setContent(uploadedBanner.getContent()); } getDao().saveOrUpdate(existBanner); } TransactionalBannerService(BannerDao bannerDao); @Override @PreAuthorize("hasPermission(#forumComponent.id, 'COMPONENT', 'GeneralPermission.ADMIN')") void uploadBanner(Banner uploadedBanner, Component forumComponent); @Override Map<String, Banner> getAllBanners();  }### Answer:
@Test public void newBannerShouldBeSaved() { Banner uploadedBanner = new Banner(BannerPosition.TOP, "<html></html>"); bannerService.uploadBanner(uploadedBanner, new Component()); verify(bannerDao).saveOrUpdate(uploadedBanner); }
@Test public void existingBannerShouldBeSavedWithNewContent() { Banner newBanner = new Banner(BannerPosition.TOP, "<html></html>"); Banner existingBanner = new Banner(BannerPosition.TOP, "<html>exists banner</html>"); when(bannerDao.getByPosition(BannerPosition.TOP)).thenReturn(existingBanner); bannerService.uploadBanner(newBanner, new Component()); verify(bannerDao).saveOrUpdate(existingBanner); assertEquals(existingBanner.getContent(), newBanner.getContent(), "Content of banner must be changed."); }