Search in sources :

Example 1 with UserMarkupCollection

use of de.catma.document.standoffmarkup.usermarkup.UserMarkupCollection in project catma by forTEXT.

the class GitMarkupCollectionHandlerTest method open.

@Test
public void open() throws Exception {
    // TODO: don't hardcode anything in assertions (markup collection name...)
    try (JGitRepoManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
        this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
        HashMap<String, Object> getJsonLdWebAnnotationResult = JsonLdWebAnnotationTest.getJsonLdWebAnnotation(jGitRepoManager, this.gitLabServerManager, this.catmaUser);
        JsonLdWebAnnotation jsonLdWebAnnotation = (JsonLdWebAnnotation) getJsonLdWebAnnotationResult.get("jsonLdWebAnnotation");
        String projectId = (String) getJsonLdWebAnnotationResult.get("projectUuid");
        String markupCollectionId = (String) getJsonLdWebAnnotationResult.get("userMarkupCollectionUuid");
        String tagsetId = (String) getJsonLdWebAnnotationResult.get("tagsetDefinitionUuid");
        this.projectsToDeleteOnTearDown.add(projectId);
        // add the tagset to the markup collection
        GitMarkupCollectionHandler gitMarkupCollectionHandler = new GitMarkupCollectionHandler(jGitRepoManager, this.gitLabServerManager);
        // TODO: use the real tagset hash - currently the handler does not validate it at all
        gitMarkupCollectionHandler.addTagset(projectId, markupCollectionId, tagsetId, "fakeTagsetVersion");
        // the JGitRepoManager instance should always be in a detached state after GitMarkupCollectionHandler calls
        // return
        assertFalse(jGitRepoManager.isAttached());
        // create the tag instance within the markup collection
        gitMarkupCollectionHandler.createTagInstance(projectId, markupCollectionId, jsonLdWebAnnotation);
        // the JGitRepoManager instance should always be in a detached state after GitMarkupCollectionHandler calls
        // return
        assertFalse(jGitRepoManager.isAttached());
        UserMarkupCollection markupCollection = gitMarkupCollectionHandler.open(projectId, markupCollectionId);
        // the JGitRepoManager instance should always be in a detached state after GitMarkupCollectionHandler
        // calls return
        assertFalse(jGitRepoManager.isAttached());
        assertNotNull(markupCollection);
        assertEquals("Test Markup Collection", markupCollection.getContentInfoSet().getTitle());
        assertEquals(2, markupCollection.getTagReferences().size());
        assertTrue(markupCollection.getTagReferences().get(0).getRange().equals(new Range(12, 18)));
        assertNotNull(markupCollection.getRevisionHash());
    }
}
Also used : JGitRepoManager(de.catma.repository.git.managers.JGitRepoManager) UserMarkupCollection(de.catma.document.standoffmarkup.usermarkup.UserMarkupCollection) JsonLdWebAnnotation(de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation) Range(de.catma.document.Range) GitLabServerManagerTest(de.catma.repository.git.managers.GitLabServerManagerTest) Test(org.junit.Test) JsonLdWebAnnotationTest(de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotationTest)

Aggregations

Range (de.catma.document.Range)1 UserMarkupCollection (de.catma.document.standoffmarkup.usermarkup.UserMarkupCollection)1 GitLabServerManagerTest (de.catma.repository.git.managers.GitLabServerManagerTest)1 JGitRepoManager (de.catma.repository.git.managers.JGitRepoManager)1 JsonLdWebAnnotation (de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotation)1 JsonLdWebAnnotationTest (de.catma.repository.git.serialization.models.json_ld.JsonLdWebAnnotationTest)1 Test (org.junit.Test)1