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());
}
}
Aggregations