Search in sources :

Example 1 with RepositoryProperties

use of de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties in project webanno by webanno.

the class ImportExportServiceImplTest method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    // schemaService = mock(AnnotationSchemaServiceImpl.class);
    schemaService = Mockito.spy(new AnnotationSchemaServiceImpl());
    backupProperties = new BackupProperties();
    repositoryProperties = new RepositoryProperties();
    repositoryProperties.setPath(testFolder.newFolder());
    storageService = new CasStorageServiceImpl(null, null, repositoryProperties, backupProperties);
    sut = new ImportExportServiceImpl(repositoryProperties, asList(new XmiFormatSupport()), storageService, schemaService);
    sut.onContextRefreshedEvent();
    doReturn(emptyList()).when(schemaService).listAnnotationLayer(any());
    doReturn(emptyList()).when(schemaService).listAnnotationFeature((Project) any());
    // The prepareCasForExport method internally calls getFullProjectTypeSystem, so we need to
    // ensure this is actually callable and doesn't run into a mocked version which simply
    // returns null.
    when(schemaService.getFullProjectTypeSystem(any(), anyBoolean())).thenCallRealMethod();
    when(schemaService.getTypeSystemForExport(any())).thenCallRealMethod();
    doCallRealMethod().when(schemaService).prepareCasForExport(any(), any(), any(), any());
    doCallRealMethod().when(schemaService).upgradeCas(any(), any(), any(TypeSystemDescription.class));
    casStorageSession = CasStorageSession.open();
}
Also used : TypeSystemDescription(org.apache.uima.resource.metadata.TypeSystemDescription) TypeSystemDescriptionFactory.createTypeSystemDescription(org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription) XmiFormatSupport(de.tudarmstadt.ukp.clarin.webanno.xmi.XmiFormatSupport) RepositoryProperties(de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties) Before(org.junit.Before)

Example 2 with RepositoryProperties

use of de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties in project webanno by webanno.

the class AnnotationDocumentsExporterTest method setUp.

@Before
public void setUp() throws Exception {
    initMocks(this);
    workFolder = tempFolder.newFolder();
    project = new Project();
    project.setId(1l);
    project.setName("Test Project");
    backupProperties = new BackupProperties();
    repositoryProperties = new RepositoryProperties();
    repositoryProperties.setPath(workFolder);
    casStorageService = new CasStorageServiceImpl(null, schemaService, repositoryProperties, backupProperties);
    importExportSerivce = new ImportExportServiceImpl(repositoryProperties, asList(new XmiFormatSupport()), casStorageService, schemaService);
    sut = new AnnotationDocumentExporter(documentService, null, importExportSerivce, repositoryProperties);
}
Also used : BackupProperties(de.tudarmstadt.ukp.clarin.webanno.api.dao.BackupProperties) Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) ExportedProject(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedProject) XmiFormatSupport(de.tudarmstadt.ukp.clarin.webanno.xmi.XmiFormatSupport) CasStorageServiceImpl(de.tudarmstadt.ukp.clarin.webanno.api.dao.CasStorageServiceImpl) RepositoryProperties(de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties) ImportExportServiceImpl(de.tudarmstadt.ukp.clarin.webanno.api.dao.ImportExportServiceImpl) Before(org.junit.Before)

Example 3 with RepositoryProperties

use of de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties in project webanno by webanno.

the class CasStorageServiceImplTest method setup.

@Before
public void setup() throws Exception {
    exception.set(false);
    rwTasksCompleted.set(false);
    managedReadCounter.set(0);
    unmanagedReadCounter.set(0);
    unmanagedNonInitializingReadCounter.set(0);
    writeCounter.set(0);
    deleteCounter.set(0);
    deleteInitialCounter.set(0);
    backupProperties = new BackupProperties();
    repositoryProperties = new RepositoryProperties();
    repositoryProperties.setPath(testFolder.newFolder());
    sut = new CasStorageServiceImpl(null, null, repositoryProperties, backupProperties);
}
Also used : RepositoryProperties(de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties) Before(org.junit.Before)

Example 4 with RepositoryProperties

use of de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties in project webanno by webanno.

the class DocumentServiceImplTest method setup.

@Before
public void setup() throws Exception {
    exception.set(false);
    rwTasksCompleted.set(false);
    managedReadCounter.set(0);
    unmanagedReadCounter.set(0);
    writeCounter.set(0);
    deleteCounter.set(0);
    deleteInitialCounter.set(0);
    backupProperties = new BackupProperties();
    repositoryProperties = new RepositoryProperties();
    repositoryProperties.setPath(testFolder.newFolder());
    storageService = new CasStorageServiceImpl(null, null, repositoryProperties, backupProperties);
    sut = spy(new DocumentServiceImpl(repositoryProperties, storageService, importExportService, projectService, applicationEventPublisher, entityManager));
    doAnswer(_invocation -> {
        SourceDocument doc = _invocation.getArgument(0, SourceDocument.class);
        String user = _invocation.getArgument(1, String.class);
        return new AnnotationDocument(doc.getName(), doc.getProject(), user, doc);
    }).when(sut).getAnnotationDocument(any(), any(String.class));
    when(importExportService.importCasFromFile(any(File.class), any(Project.class), any(), any())).thenReturn(CasFactory.createText("Test"));
}
Also used : Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) AnnotationDocument(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument) RepositoryProperties(de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties) File(java.io.File) Before(org.junit.Before)

Example 5 with RepositoryProperties

use of de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties in project webanno by webanno.

the class CuratedDocumentsExporterTest method setUp.

@Before
public void setUp() throws Exception {
    initMocks(this);
    workFolder = tempFolder.newFolder();
    project = new Project();
    project.setId(1l);
    project.setName("Test Project");
    backupProperties = new BackupProperties();
    repositoryProperties = new RepositoryProperties();
    repositoryProperties.setPath(workFolder);
    casStorageService = spy(new CasStorageServiceImpl(null, schemaService, repositoryProperties, backupProperties));
    importExportSerivce = new ImportExportServiceImpl(repositoryProperties, asList(new XmiFormatSupport()), casStorageService, schemaService);
    // documentService.getCasFile() is just a stupid wrapper around storageService.getCasFile()
    // and it is easiest we emulate it here
    when(documentService.getCasFile(any(), any())).thenAnswer(invocation -> {
        return casStorageService.getCasFile(invocation.getArgument(0, SourceDocument.class), invocation.getArgument(1, String.class));
    });
    // Dynamically generate a SourceDocument with an incrementing ID when asked for one
    when(documentService.getSourceDocument(any(), any())).then(invocation -> {
        SourceDocument doc = new SourceDocument();
        doc.setId(nextDocId++);
        doc.setProject(invocation.getArgument(0, Project.class));
        doc.setName(invocation.getArgument(1, String.class));
        return doc;
    });
    sut = new CuratedDocumentsExporter(documentService, importExportSerivce);
}
Also used : BackupProperties(de.tudarmstadt.ukp.clarin.webanno.api.dao.BackupProperties) Project(de.tudarmstadt.ukp.clarin.webanno.model.Project) ExportedProject(de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedProject) XmiFormatSupport(de.tudarmstadt.ukp.clarin.webanno.xmi.XmiFormatSupport) CasStorageServiceImpl(de.tudarmstadt.ukp.clarin.webanno.api.dao.CasStorageServiceImpl) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) RepositoryProperties(de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties) ImportExportServiceImpl(de.tudarmstadt.ukp.clarin.webanno.api.dao.ImportExportServiceImpl) Before(org.junit.Before)

Aggregations

RepositoryProperties (de.tudarmstadt.ukp.clarin.webanno.api.RepositoryProperties)5 Before (org.junit.Before)5 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)3 XmiFormatSupport (de.tudarmstadt.ukp.clarin.webanno.xmi.XmiFormatSupport)3 BackupProperties (de.tudarmstadt.ukp.clarin.webanno.api.dao.BackupProperties)2 CasStorageServiceImpl (de.tudarmstadt.ukp.clarin.webanno.api.dao.CasStorageServiceImpl)2 ImportExportServiceImpl (de.tudarmstadt.ukp.clarin.webanno.api.dao.ImportExportServiceImpl)2 ExportedProject (de.tudarmstadt.ukp.clarin.webanno.export.model.ExportedProject)2 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)2 AnnotationDocument (de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument)1 File (java.io.File)1 TypeSystemDescriptionFactory.createTypeSystemDescription (org.apache.uima.fit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription)1 TypeSystemDescription (org.apache.uima.resource.metadata.TypeSystemDescription)1