### Question:
TransactionalComponentService extends AbstractTransactionalEntityService<Component, ComponentDao> implements ComponentService { @Override public Date getComponentModificationTime() { Date modificationDate = null; if (getDao().getComponent() != null) { String dateString = getDao().getComponent().getProperty(COMPONENT_INFO_CHANGE_DATE_PROPERTY); if (dateString != null) { modificationDate = new Date(Long.parseLong(dateString)); } } return modificationDate; } TransactionalComponentService(ImageService icoFormatImageService, ComponentDao dao); @Override Component getComponentOfForum(); @Override @PreAuthorize("hasPermission(#componentInformation.id, 'COMPONENT', 'GeneralPermission.ADMIN')") void setComponentInformation(ComponentInformation componentInformation); @Override Date getComponentModificationTime(); @Override @PreAuthorize("hasPermission(#componentId, 'COMPONENT', 'GeneralPermission.ADMIN')") void checkPermissionsForComponent(long componentId); static final String LOGO_TOOLTIP_PROPERTY; static final String TITLE_PREFIX_PROPERTY; static final String LOGO_PROPERTY; static final String COPYRIGHT_PROPERTY; static final String COMPONENT_FAVICON_ICO_PARAM; static final String COMPONENT_FAVICON_PNG_PARAM; static final String COMPONENT_SESSION_TIMEOUT; static final String COMPONENT_EMAIL_NOTIFICATION; static final String COMPONENT_AVATAR_MAX_SIZE; }### Answer:
@Test public void getComponentModificationTimeShouldReturnPropertyIfItExists() { long lastModificationTime = 42; when(componentDao.getComponent()).thenReturn(component); when(component.getProperty(TransactionalComponentService.COMPONENT_INFO_CHANGE_DATE_PROPERTY)) .thenReturn(String.valueOf(lastModificationTime)); Date modificationTime = componentService.getComponentModificationTime(); assertEquals(modificationTime.getTime(), lastModificationTime); }
@Test public void getComponentModificationTimeShouldReturnNullIfNotExists() { when(componentDao.getComponent()).thenReturn(component); when(component.getProperty(TransactionalComponentService.COMPONENT_INFO_CHANGE_DATE_PROPERTY)) .thenReturn(null); Date modificationTime = componentService.getComponentModificationTime(); assertNull(modificationTime); }