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