use of org.alfresco.bm.event.EventResult in project records-management by Alfresco.
the class ScheduleUnfiledRecordFolderLoadersUnitTest method testScheduleRootUnfiledRecordFolders.
@Test
public void testScheduleRootUnfiledRecordFolders() throws Exception {
int maxActiveLoaders = 8;
int rootUnfiledRecordFolderNumber = 4;
int unfiledRecordFoldersDepth = 1;
scheduleUnfiledRecordFolderLoaders.setCreateUnfiledRecordFolderStructure(true);
scheduleUnfiledRecordFolderLoaders.setMaxActiveLoaders(maxActiveLoaders);
scheduleUnfiledRecordFolderLoaders.setUnfiledRecordFolderDepth(unfiledRecordFoldersDepth);
scheduleUnfiledRecordFolderLoaders.setRootUnfiledRecordFolderNumber(rootUnfiledRecordFolderNumber);
FolderData unfiledContainerFolder = mock(FolderData.class);
when(unfiledContainerFolder.getContext()).thenReturn(UNFILED_CONTEXT);
when(unfiledContainerFolder.getPath()).thenReturn(UNFILED_RECORD_CONTAINER_PATH);
when(mockedFileFolderService.getFolder(UNFILED_CONTEXT, UNFILED_RECORD_CONTAINER_PATH)).thenReturn(unfiledContainerFolder);
EventResult result = scheduleUnfiledRecordFolderLoaders.processEvent(null, new StopWatch());
verify(mockedSessionService, times(4)).startSession(any(DBObject.class));
assertEquals(true, result.isSuccess());
assertEquals("Raised further 4 events and rescheduled self.", result.getData());
assertEquals(5, result.getNextEvents().size());
for (int i = 0; i < 4; i++) {
Event event = result.getNextEvents().get(i);
assertEquals(EVENT_LOAD_ROOT_UNFILED_RECORD_FOLDER, event.getName());
DBObject dataObj = (DBObject) event.getData();
assertNotNull(dataObj);
assertEquals(UNFILED_CONTEXT, (String) dataObj.get(FIELD_CONTEXT));
assertEquals(UNFILED_RECORD_CONTAINER_PATH, (String) dataObj.get(FIELD_PATH));
assertEquals(LOAD_ROOT_UNFILED_RECORD_FOLDER_OPERATION, dataObj.get(FIELD_LOAD_OPERATION));
}
assertEquals(EVENT_SCHEDULE_SELF, result.getNextEvents().get(4).getName());
}
use of org.alfresco.bm.event.EventResult in project records-management by Alfresco.
the class ScheduleUnfiledRecordFolderLoadersUnitTest method testSchedule4RootUnfiledRecordFoldersWithMaxActiveLoaders3.
@Test
public void testSchedule4RootUnfiledRecordFoldersWithMaxActiveLoaders3() throws Exception {
int maxActiveLoaders = 3;
int rootUnfiledRecordFolderNumber = 4;
int unfiledRecordFoldersDepth = 1;
scheduleUnfiledRecordFolderLoaders.setCreateUnfiledRecordFolderStructure(true);
scheduleUnfiledRecordFolderLoaders.setMaxActiveLoaders(maxActiveLoaders);
scheduleUnfiledRecordFolderLoaders.setUnfiledRecordFolderDepth(unfiledRecordFoldersDepth);
scheduleUnfiledRecordFolderLoaders.setRootUnfiledRecordFolderNumber(rootUnfiledRecordFolderNumber);
FolderData unfiledContainerFolder = mock(FolderData.class);
when(unfiledContainerFolder.getContext()).thenReturn(UNFILED_CONTEXT);
when(unfiledContainerFolder.getPath()).thenReturn(UNFILED_RECORD_CONTAINER_PATH);
when(mockedFileFolderService.getFolder(UNFILED_CONTEXT, UNFILED_RECORD_CONTAINER_PATH)).thenReturn(unfiledContainerFolder);
EventResult result = scheduleUnfiledRecordFolderLoaders.processEvent(null, new StopWatch());
verify(mockedSessionService, times(3)).startSession(any(DBObject.class));
assertEquals(true, result.isSuccess());
assertEquals("Raised further 3 events and rescheduled self.", result.getData());
assertEquals(4, result.getNextEvents().size());
for (int i = 0; i < 3; i++) {
Event event = result.getNextEvents().get(i);
assertEquals(EVENT_LOAD_ROOT_UNFILED_RECORD_FOLDER, event.getName());
DBObject dataObj = (DBObject) event.getData();
assertNotNull(dataObj);
assertEquals(UNFILED_CONTEXT, (String) dataObj.get(FIELD_CONTEXT));
assertEquals(UNFILED_RECORD_CONTAINER_PATH, (String) dataObj.get(FIELD_PATH));
assertEquals(LOAD_ROOT_UNFILED_RECORD_FOLDER_OPERATION, dataObj.get(FIELD_LOAD_OPERATION));
}
assertEquals(EVENT_SCHEDULE_SELF, result.getNextEvents().get(3).getName());
}
use of org.alfresco.bm.event.EventResult in project records-management by Alfresco.
the class ScheduleUnfiledRecordFolderLoadersUnitTest method testScheduleUnfiledRecordFoldersChildrenWithDepthLessThan2.
@Test
public void testScheduleUnfiledRecordFoldersChildrenWithDepthLessThan2() throws Exception {
int maxActiveLoaders = 8;
int rootUnfiledRecordFolderNumber = 0;
int unfiledRecordFolderChildrenNumber = 2;
int unfiledRecordFolderDepth = 1;
scheduleUnfiledRecordFolderLoaders.setCreateUnfiledRecordFolderStructure(true);
scheduleUnfiledRecordFolderLoaders.setMaxActiveLoaders(maxActiveLoaders);
scheduleUnfiledRecordFolderLoaders.setRootUnfiledRecordFolderNumber(rootUnfiledRecordFolderNumber);
scheduleUnfiledRecordFolderLoaders.setUnfiledRecordFolderDepth(unfiledRecordFolderDepth);
scheduleUnfiledRecordFolderLoaders.setUnfiledRecordFolderNumber(unfiledRecordFolderChildrenNumber);
FolderData mockedUnfiledRecordContainerFolder = mock(FolderData.class);
when(mockedUnfiledRecordContainerFolder.getContext()).thenReturn(UNFILED_CONTEXT);
when(mockedUnfiledRecordContainerFolder.getPath()).thenReturn("/a");
FolderData mockedUnfiledRecordContainerFolder2 = mock(FolderData.class);
when(mockedUnfiledRecordContainerFolder2.getContext()).thenReturn(UNFILED_CONTEXT);
when(mockedUnfiledRecordContainerFolder2.getPath()).thenReturn("/b");
List<FolderData> folders = Arrays.asList(mockedUnfiledRecordContainerFolder, mockedUnfiledRecordContainerFolder2);
when(mockedFileFolderService.getFoldersByCounts(UNFILED_CONTEXT, Long.valueOf(UNFILED_RECORD_CONTAINER_LEVEL + 1), Long.valueOf(scheduleUnfiledRecordFolderLoaders.getMaxLevel() - 1), 0L, Long.valueOf(unfiledRecordFolderChildrenNumber - 1), null, null, 0, 100)).thenReturn(folders);
FolderData unfiledContainerFolder = mock(FolderData.class);
when(unfiledContainerFolder.getContext()).thenReturn(UNFILED_CONTEXT);
when(unfiledContainerFolder.getPath()).thenReturn(UNFILED_RECORD_CONTAINER_PATH);
when(mockedFileFolderService.getFolder(UNFILED_CONTEXT, UNFILED_RECORD_CONTAINER_PATH)).thenReturn(unfiledContainerFolder);
EventResult result = scheduleUnfiledRecordFolderLoaders.processEvent(null, new StopWatch());
verify(mockedFileFolderService, never()).createNewFolder(any(FolderData.class));
verify(mockedSessionService, never()).startSession(any(DBObject.class));
assertEquals(true, result.isSuccess());
assertEquals("Loading completed. Raising 'done' event.", result.getData());
assertEquals(1, result.getNextEvents().size());
assertEquals(EVENT_COMPLETE, result.getNextEvents().get(0).getName());
}
use of org.alfresco.bm.event.EventResult in project records-management by Alfresco.
the class ScheduleUnfiledRecordFolderLoadersUnitTest method testUnfiledRecordFoldersNotWanted.
@Test
public void testUnfiledRecordFoldersNotWanted() throws Exception {
scheduleUnfiledRecordFolderLoaders.setCreateUnfiledRecordFolderStructure(false);
EventResult result = scheduleUnfiledRecordFolderLoaders.processEvent(null, new StopWatch());
verify(mockedFileFolderService, never()).createNewFolder(any(FolderData.class));
verify(mockedSessionService, never()).startSession(any(DBObject.class));
assertEquals(true, result.isSuccess());
assertEquals("Unfiled Record Folders structure creation not wanted, continue with loading data.", result.getData());
assertEquals(1, result.getNextEvents().size());
}
use of org.alfresco.bm.event.EventResult in project records-management by Alfresco.
the class FileUnfiledRecordUnitTest method testFileRecordOperationWithEmptyRecordId.
@Test
public void testFileRecordOperationWithEmptyRecordId() throws Exception {
loadSingleComponent.setEventNameComplete(EVENT_UNFILED_RECORD_FILED);
Event mockedEvent = mock(Event.class);
DBObject mockedData = mock(DBObject.class);
when(mockedData.get(FIELD_CONTEXT)).thenReturn("someContext");
when(mockedData.get(FIELD_PATH)).thenReturn("/aPath");
when(mockedData.get(FIELD_LOAD_OPERATION)).thenReturn(FILE_RECORD_OPERATION);
when(mockedData.get(FIELD_RECORD_ID)).thenReturn("");
when(mockedEvent.getData()).thenReturn(mockedData);
FolderData mockedFolder = mock(FolderData.class);
when(mockedFolder.getId()).thenReturn("folderId");
when(mockedFolder.getPath()).thenReturn("/aPath");
when(mockedFolder.getContext()).thenReturn("someContext");
when(mockedFileFolderService.getFolder("someContext", "/aPath")).thenReturn(mockedFolder);
when(mockedEvent.getSessionId()).thenReturn("someId");
EventResult result = loadSingleComponent.processEvent(mockedEvent, new StopWatch());
assertEquals(false, result.isSuccess());
assertEquals("Request data not complete for filing unfiled record: " + mockedData, result.getData());
assertEquals(0, result.getNextEvents().size());
}
Aggregations