### Question:
AcmFileListener implements ApplicationListener<EcmFileAddedEvent> { @Override public void onApplicationEvent(EcmFileAddedEvent ecmFileAddedEvent) { AlfrescoRmaConfig rmaConfig = alfrescoRecordsService.getRmaConfig(); boolean proceed = rmaConfig.getIntegrationEnabled() && rmaConfig.getDeclareRecordFolderOnFileUpload(); if (!proceed) { return; } if (!ecmFileAddedEvent.isSucceeded()) { log.trace("Returning - file creation was not successful"); return; } try { getAlfrescoRecordsService().declareFileAsRecord(ecmFileAddedEvent.getSource().getContainer(), ecmFileAddedEvent.getEventDate(), ecmFileAddedEvent.getParentObjectName(), rmaConfig.getDefaultOriginatorOrg(), ecmFileAddedEvent.getUserId(), ecmFileAddedEvent.getEcmFileId(), ecmFileAddedEvent.getSource().getStatus(), ecmFileAddedEvent.getObjectId()); } catch (AlfrescoServiceException e) { log.error("Could not declare file as record: {}", e.getMessage(), e); } }  @Override void onApplicationEvent(EcmFileAddedEvent ecmFileAddedEvent); AlfrescoRecordsService getAlfrescoRecordsService(); void setAlfrescoRecordsService(AlfrescoRecordsService alfrescoRecordsService);  }### Answer:
@Test public void doNotProceed_shouldNotDeclareRecord() { EcmFile file = new EcmFile(); file.setContainer(new AcmContainer()); rmaConfig.setDeclareRecordFolderOnFileUpload(false); expect(mockService.getRmaConfig()).andReturn(rmaConfig); expect(mockAuthentication.getDetails()).andReturn("details").anyTimes(); replayAll(); EcmFileAddedEvent event = new EcmFileAddedEvent(file, mockAuthentication); unit.onApplicationEvent(event); verifyAll(); }
@Test public void ecmFileAddedEvent_shouldDeclareRecord() throws Exception { EcmFile file = new EcmFile(); file.setContainer(new AcmContainer()); file.getContainer().setContainerObjectType("containerObjectType"); String categoryFolder = "categoryFolder"; file.setStatus("ACTIVE"); String originatorOrg = "originatorOrg"; rmaConfig.setDefaultOriginatorOrg(originatorOrg); rmaConfig.setCategoryFolderCaseFile(categoryFolder); rmaConfig.setDeclareRecordFolderOnFileUpload(true); expect(mockService.getRmaConfig()).andReturn(rmaConfig); expect(mockAuthentication.getDetails()).andReturn("details").anyTimes(); mockService.declareFileAsRecord(eq(file.getContainer()), anyObject(Date.class), eq("parentObjectName"), eq(originatorOrg), eq("userId"), eq("cmisObjectId"), eq(file.getStatus()), eq(500L)); replayAll(); EcmFileAddedEvent event = new EcmFileAddedEvent(file, mockAuthentication); event.setSucceeded(true); event.setParentObjectName("parentObjectName"); event.setUserId("userId"); event.setEcmFileId("cmisObjectId"); event.setObjectId(500L); unit.onApplicationEvent(event); verifyAll(); }