Search in sources :

Example 16 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project records-management by Alfresco.

the class LoadSingleComponentUnitTest method testWithNullSessionID.

@Test
public void testWithNullSessionID() throws Exception {
    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(LOAD_RECORD_OPERATION);
    when(mockedEvent.getData()).thenReturn(mockedData);
    FolderData mockedFolder = mock(FolderData.class);
    when(mockedFileFolderService.getFolder("someContext", "/aPath")).thenReturn(mockedFolder);
    when(mockedEvent.getSessionId()).thenReturn(null);
    EventResult result = loadSingleComponent.processEvent(mockedEvent, new StopWatch());
    assertEquals(false, result.isSuccess());
    assertEquals("Load scheduling should create a session for each loader.", result.getData());
    assertEquals(0, result.getNextEvents().size());
}
Also used : EventResult(org.alfresco.bm.event.EventResult) FolderData(org.alfresco.bm.cm.FolderData) Event(org.alfresco.bm.event.Event) DBObject(com.mongodb.DBObject) StopWatch(org.apache.commons.lang3.time.StopWatch) Test(org.junit.Test)

Example 17 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project records-management by Alfresco.

the class LoadSingleComponentUnitTest method testWithNullContext.

@Test
public void testWithNullContext() throws Exception {
    Event mockedEvent = mock(Event.class);
    DBObject mockedData = mock(DBObject.class);
    when(mockedData.get(FIELD_CONTEXT)).thenReturn(null);
    when(mockedEvent.getData()).thenReturn(mockedData);
    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());
}
Also used : EventResult(org.alfresco.bm.event.EventResult) Event(org.alfresco.bm.event.Event) DBObject(com.mongodb.DBObject) StopWatch(org.apache.commons.lang3.time.StopWatch) Test(org.junit.Test)

Example 18 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project records-management by Alfresco.

the class LoadSingleComponentUnitTest method testWithNullData.

@Test(expected = IllegalStateException.class)
public void testWithNullData() throws Exception {
    Event mockedEvent = mock(Event.class);
    when(mockedEvent.getData()).thenReturn(null);
    loadSingleComponent.processEvent(mockedEvent, new StopWatch());
}
Also used : Event(org.alfresco.bm.event.Event) StopWatch(org.apache.commons.lang3.time.StopWatch) Test(org.junit.Test)

Example 19 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project records-management by Alfresco.

the class LoadSingleComponentUnitTest method testInexistentFolderForContextAndPath.

@Test(expected = IllegalStateException.class)
public void testInexistentFolderForContextAndPath() throws Exception {
    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(LOAD_RECORD_OPERATION);
    when(mockedEvent.getData()).thenReturn(mockedData);
    when(mockedFileFolderService.getFolder("someContext", "/aPath")).thenReturn(null);
    loadSingleComponent.processEvent(mockedEvent, new StopWatch());
}
Also used : Event(org.alfresco.bm.event.Event) DBObject(com.mongodb.DBObject) StopWatch(org.apache.commons.lang3.time.StopWatch) Test(org.junit.Test)

Example 20 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project records-management by Alfresco.

the class ScheduleFilePlanLoadersUnitTest method testScheduleChildrenRecordFoldersInCategoriesWithFilePlanDepthLessThan2.

@Test
public void testScheduleChildrenRecordFoldersInCategoriesWithFilePlanDepthLessThan2() throws Exception {
    int maxActiveLoaders = 8;
    int rootCategoriesNumber = 0;
    int categoriesChildrenNumber = 0;
    int foldersChildrenNumber = 2;
    int categoryStructureDepth = 1;
    scheduleFilePlanLoaders.setMaxActiveLoaders(maxActiveLoaders);
    scheduleFilePlanLoaders.setCategoryNumber(rootCategoriesNumber);
    scheduleFilePlanLoaders.setCategoryStructureDepth(categoryStructureDepth);
    scheduleFilePlanLoaders.setChildCategNumber(categoriesChildrenNumber);
    scheduleFilePlanLoaders.setFolderNumber(foldersChildrenNumber);
    scheduleFilePlanLoaders.setFolderCategoryMix(true);
    FolderData mockedRootCategoryFolder = mock(FolderData.class);
    when(mockedRootCategoryFolder.getContext()).thenReturn(RECORD_CATEGORY_CONTEXT);
    when(mockedRootCategoryFolder.getPath()).thenReturn("/a");
    String name1 = ROOT_CATEGORY_NAME_IDENTIFIER + UUID.randomUUID().toString();
    when(mockedRootCategoryFolder.getName()).thenReturn(name1);
    FolderData mockedChildCategoryFolder = mock(FolderData.class);
    when(mockedChildCategoryFolder.getContext()).thenReturn(RECORD_CATEGORY_CONTEXT);
    when(mockedChildCategoryFolder.getPath()).thenReturn("/b");
    String name2 = CATEGORY_NAME_IDENTIFIER + UUID.randomUUID().toString();
    when(mockedChildCategoryFolder.getName()).thenReturn(name2);
    FolderData filePlanFolder = mock(FolderData.class);
    when(filePlanFolder.getContext()).thenReturn(FILEPLAN_CONTEXT);
    when(filePlanFolder.getPath()).thenReturn(RECORD_CONTAINER_PATH);
    when(mockedFileFolderService.getFolder(FILEPLAN_CONTEXT, RECORD_CONTAINER_PATH)).thenReturn(filePlanFolder);
    List<FolderData> folders = Arrays.asList(mockedRootCategoryFolder, mockedChildCategoryFolder);
    when(mockedFileFolderService.getFoldersByCounts(RECORD_CATEGORY_CONTEXT, Long.valueOf(FILE_PLAN_LEVEL + 1), Long.valueOf(scheduleFilePlanLoaders.getMaxLevel() - 1 - 1), 0L, Long.valueOf(foldersChildrenNumber - 1), null, null, 0, 100)).thenReturn(folders);
    EventResult result = scheduleFilePlanLoaders.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_FILE_PLANLOADING_COMPLETE, result.getNextEvents().get(0).getName());
}
Also used : EventResult(org.alfresco.bm.event.EventResult) FolderData(org.alfresco.bm.cm.FolderData) DBObject(com.mongodb.DBObject) StopWatch(org.apache.commons.lang3.time.StopWatch) Test(org.junit.Test)

Aggregations

StopWatch (org.apache.commons.lang3.time.StopWatch)500 Test (org.junit.Test)149 EventResult (org.alfresco.bm.event.EventResult)97 DBObject (com.mongodb.DBObject)90 Event (org.alfresco.bm.event.Event)87 FolderData (org.alfresco.bm.cm.FolderData)75 File (java.io.File)72 ArrayList (java.util.ArrayList)48 HashSet (java.util.HashSet)31 Gene (ubic.gemma.model.genome.Gene)31 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)26 BaseTest (org.umlg.sqlg.test.BaseTest)26 Element (org.w3c.dom.Element)25 LoadSingleComponentUnitTest (org.alfresco.bm.dataload.LoadSingleComponentUnitTest)23 UserModel (org.alfresco.utility.model.UserModel)23 IOException (java.io.IOException)20 Collectors (java.util.stream.Collectors)19 HashMap (java.util.HashMap)18 List (java.util.List)18 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)18