use of de.catma.repository.git.managers.JGitRepoManager in project catma by forTEXT.
the class GitProjectHandlerTest method createMarkupCollection.
@Test
public void createMarkupCollection() throws Exception {
try (JGitRepoManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
GitProjectManager gitProjectManager = new GitProjectManager(RepositoryPropertyKey.GitBasedRepositoryBasePath.getValue(), UserIdentification.userToMap(this.catmaUser.getIdentifier()));
String projectId = gitProjectManager.create("Test CATMA Project", "This is a test CATMA project");
this.projectsToDeleteOnTearDown.add(projectId);
// the JGitRepoManager instance should always be in a detached state after GitProjectHandler calls return
assertFalse(jGitRepoManager.isAttached());
GitProjectHandler gitProjectHandler = new GitProjectHandler(null, projectId, jGitRepoManager, gitLabServerManager);
String markupCollectionId = gitProjectHandler.createMarkupCollection(null, "Test Markup Collection", null, "fakeSourceDocumentId", "fakeSourceDocumentVersion");
assertNotNull(markupCollectionId);
// the JGitRepoManager instance should always be in a detached state after GitProjectHandler calls return
assertFalse(jGitRepoManager.isAttached());
jGitRepoManager.open(projectId, GitProjectManager.getProjectRootRepositoryName(projectId));
Status status = jGitRepoManager.getGitApi().status().call();
Set<String> added = status.getAdded();
assert status.hasUncommittedChanges();
assert added.contains(".gitmodules");
assert added.contains(String.format("%s/%s", GitProjectHandler.MARKUP_COLLECTION_SUBMODULES_DIRECTORY_NAME, markupCollectionId));
}
}
use of de.catma.repository.git.managers.JGitRepoManager in project catma by forTEXT.
the class GitProjectHandlerTest method delete.
@Test
public void delete() throws Exception {
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
GitProjectManager gitProjectHandler = new GitProjectManager(RepositoryPropertyKey.GitBasedRepositoryBasePath.getValue(), UserIdentification.userToMap(this.catmaUser.getIdentifier()));
String projectId = gitProjectHandler.create("Test CATMA Project", "This is a test CATMA project");
// we don't add the projectId to this.projectsToDeleteOnTearDown as this is the delete test
assertNotNull(projectId);
assert projectId.startsWith("CATMA_");
// the JGitRepoManager instance should always be in a detached state after GitProjectHandler calls
// return
assertFalse(jGitRepoManager.isAttached());
String expectedRootRepositoryName = GitProjectManager.getProjectRootRepositoryName(projectId);
File expectedRootRepositoryPath = new File(jGitRepoManager.getRepositoryBasePath(), expectedRootRepositoryName);
assert expectedRootRepositoryPath.exists();
assert expectedRootRepositoryPath.isDirectory();
gitProjectHandler.delete(projectId);
assertFalse(expectedRootRepositoryPath.exists());
// the JGitRepoManager instance should always be in a detached state after GitProjectHandler calls
// return
assertFalse(jGitRepoManager.isAttached());
}
}
use of de.catma.repository.git.managers.JGitRepoManager in project catma by forTEXT.
the class GitSourceDocumentHandlerTest method open.
@Test
public void open() throws Exception {
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);
String projectId = (String) getJsonLdWebAnnotationResult.get("projectUuid");
String sourceDocumentId = (String) getJsonLdWebAnnotationResult.get("sourceDocumentUuid");
this.projectsToDeleteOnTearDown.add(projectId);
GitSourceDocumentHandler gitSourceDocumentHandler = new GitSourceDocumentHandler(jGitRepoManager, this.gitLabServerManager);
SourceDocument loadedSourceDocument = gitSourceDocumentHandler.open(projectId, sourceDocumentId);
assertNotNull(loadedSourceDocument);
assertEquals("William Faulkner", loadedSourceDocument.getSourceContentHandler().getSourceDocumentInfo().getContentInfoSet().getAuthor());
assertEquals("A Rose for Emily", loadedSourceDocument.getSourceContentHandler().getSourceDocumentInfo().getContentInfoSet().getTitle());
assertNotNull(loadedSourceDocument.getRevisionHash());
}
}
use of de.catma.repository.git.managers.JGitRepoManager in project catma by forTEXT.
the class GitSourceDocumentHandlerTest method delete.
@Test
public void delete() throws Exception {
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
GitSourceDocumentHandler gitSourceDocumentHandler = new GitSourceDocumentHandler(jGitRepoManager, this.gitLabServerManager);
thrown.expect(IOException.class);
thrown.expectMessage("Not implemented");
gitSourceDocumentHandler.delete("fakeProjectId", "fakeSourceDocumentId");
}
}
use of de.catma.repository.git.managers.JGitRepoManager in project catma by forTEXT.
the class GitTagsetHandlerTest method createTagDefinitionWithoutParent.
@Test
public void createTagDefinitionWithoutParent() throws Exception {
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
this.directoriesToDeleteOnTearDown.add(jGitRepoManager.getRepositoryBasePath());
// create a project
GitProjectManager gitProjectManager = new GitProjectManager(RepositoryPropertyKey.GitBasedRepositoryBasePath.getValue(), UserIdentification.userToMap(this.catmaUser.getIdentifier()));
String projectId = gitProjectManager.create("Test CATMA Project for Tagset", "This is a test CATMA project");
this.projectsToDeleteOnTearDown.add(projectId);
GitProjectHandler gitProjectHandler = new GitProjectHandler(null, projectId, jGitRepoManager, gitLabServerManager);
// create a tagset
String tagsetId = gitProjectHandler.createTagset(null, "Test Tagset", null);
// we don't add the tagsetId to this.tagsetReposToDeleteOnTearDown as deletion of the project will take
// care of that for us
// create a TagDefinition object
String tagDefinitionId = this.idGenerator.generate();
Version tagDefinitionVersion = new Version();
TagDefinition tagDefinition = new TagDefinition(null, tagDefinitionId, "FakeTagDefinitionName", tagDefinitionVersion, null, null);
PropertyDefinition propertyDefinition = new PropertyDefinition("Weather", Arrays.asList("Good", "Bad", "Toto, I've a feeling we're not in Kansas anymore."));
tagDefinition.addUserDefinedPropertyDefinition(propertyDefinition);
// call createTagDefinition
GitTagsetHandler gitTagsetHandler = new GitTagsetHandler(jGitRepoManager, this.gitLabServerManager);
String returnedTagDefinitionId = gitTagsetHandler.createOrUpdateTagDefinition(projectId, tagsetId, tagDefinition);
assertNotNull(returnedTagDefinitionId);
assert returnedTagDefinitionId.startsWith("CATMA_");
// the JGitRepoManager instance should always be in a detached state after GitTagsetHandler calls return
assertFalse(jGitRepoManager.isAttached());
assertEquals(tagDefinitionId, returnedTagDefinitionId);
String projectRootRepositoryName = GitProjectManager.getProjectRootRepositoryName(projectId);
File expectedTagDefinitionPath = Paths.get(jGitRepoManager.getRepositoryBasePath().toString(), projectRootRepositoryName, GitProjectHandler.TAGSET_SUBMODULES_DIRECTORY_NAME, tagsetId, tagDefinition.getUuid()).toFile();
assert expectedTagDefinitionPath.exists() : "Directory does not exist";
assert expectedTagDefinitionPath.isDirectory() : "Path is not a directory";
assert Arrays.asList(expectedTagDefinitionPath.list()).contains("propertydefs.json");
GitTagDefinition expectedGitTagDefinition = new GitTagDefinition(tagDefinition);
String actualSerializedGitTagDefinition = FileUtils.readFileToString(new File(expectedTagDefinitionPath, "propertydefs.json"), StandardCharsets.UTF_8);
GitTagDefinition actualGitTagDefinition = new SerializationHelper<GitTagDefinition>().deserialize(actualSerializedGitTagDefinition, GitTagDefinition.class);
assertEquals(expectedGitTagDefinition.getTagsetDefinitionUuid(), actualGitTagDefinition.getTagsetDefinitionUuid());
assertEquals(expectedGitTagDefinition.getParentUuid(), actualGitTagDefinition.getParentUuid());
assertEquals(expectedGitTagDefinition.getUuid(), actualGitTagDefinition.getUuid());
assertEquals(expectedGitTagDefinition.getName(), actualGitTagDefinition.getName());
// TODO: assert tag definition and properties
}
}
Aggregations