use of de.catma.repository.git.managers.JGitRepoManager in project catma by forTEXT.
the class GitTagsetHandlerTest method create.
@Test
public void create() 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 for Tagset", "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());
GitTagsetHandler gitTagsetHandler = new GitTagsetHandler(jGitRepoManager, this.gitLabServerManager);
String name = "Test Tagset";
String description = "Test Tagset Description";
String tagsetId = gitTagsetHandler.create(projectId, null, name, description);
// we don't add the tagsetId to this.tagsetReposToDeleteOnTearDown as deletion of the
// project will take care of that for us
assertNotNull(tagsetId);
assert tagsetId.startsWith("CATMA_");
File expectedRepoPath = new File(jGitRepoManager.getRepositoryBasePath(), GitTagsetHandler.getTagsetRepositoryName(tagsetId));
assert expectedRepoPath.exists();
assert expectedRepoPath.isDirectory();
assert Arrays.asList(expectedRepoPath.list()).contains("header.json");
GitTagsetHeader expectedHeader = new GitTagsetHeader(name, description);
String serialized = FileUtils.readFileToString(new File(expectedRepoPath, "header.json"), StandardCharsets.UTF_8);
GitTagsetHeader actualHeader = new SerializationHelper<GitTagsetHeader>().deserialize(serialized, GitTagsetHeader.class);
assertEquals(expectedHeader.getName(), actualHeader.getName());
assertEquals(expectedHeader.getDescription(), actualHeader.getDescription());
}
}
use of de.catma.repository.git.managers.JGitRepoManager in project catma by forTEXT.
the class GitMarkupCollectionHandlerTest method delete.
@Test
public void delete() throws Exception {
try (ILocalGitRepositoryManager jGitRepoManager = new JGitRepoManager(this.catmaProperties.getProperty(RepositoryPropertyKey.GitBasedRepositoryBasePath.name()), this.catmaUser)) {
GitMarkupCollectionHandler gitMarkupCollectionHandler = new GitMarkupCollectionHandler(jGitRepoManager, this.gitLabServerManager);
thrown.expect(IOException.class);
thrown.expectMessage("Not implemented");
gitMarkupCollectionHandler.delete("fakeProjectId", "fakeMarkupCollectionId");
}
}
use of de.catma.repository.git.managers.JGitRepoManager in project catma by forTEXT.
the class GitMarkupCollectionHandlerTest method addTagset.
@Test
public void addTagset() 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", "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 markup collection
String markupCollectionId = gitProjectHandler.createMarkupCollection(null, "Test Markup Collection", null, "fakeSourceDocumentId", "fakeSourceDocumentVersion");
// we don't add the markupCollectionId to this.markupCollectionReposToDeleteOnTearDown as deletion of the
// project will take care of that for us
// add the tagset to the markup collection
GitMarkupCollectionHandler gitMarkupCollectionHandler = new GitMarkupCollectionHandler(jGitRepoManager, this.gitLabServerManager);
gitMarkupCollectionHandler.addTagset(projectId, markupCollectionId, tagsetId, "fakeTagsetVersion");
// the JGitRepoManager instance should always be in a detached state after GitMarkupCollectionHandler
// calls return
assertFalse(jGitRepoManager.isAttached());
// assert that the markup collection header file was updated as expected
String expectedSerializedHeader = "" + "{\n" + "\t\"author\":null,\n" + "\t\"description\":null,\n" + "\t\"name\":\"Test Markup Collection\",\n" + "\t\"publisher\":null,\n" + "\t\"sourceDocumentId\":\"fakeSourceDocumentId\",\n" + "\t\"sourceDocumentVersion\":\"fakeSourceDocumentVersion\",\n" + "\t\"tagsets\":{\n" + "\t\t\"%s\":\"fakeTagsetVersion\"\n" + "\t}\n" + "}";
expectedSerializedHeader = String.format(expectedSerializedHeader, tagsetId);
File markupCollectionHeaderFilePath = Paths.get(jGitRepoManager.getRepositoryBasePath().toString(), GitProjectManager.getProjectRootRepositoryName(projectId), GitProjectHandler.MARKUP_COLLECTION_SUBMODULES_DIRECTORY_NAME, markupCollectionId, "header.json").toFile();
assertEquals(expectedSerializedHeader.replaceAll("[\n\t]", ""), FileUtils.readFileToString(markupCollectionHeaderFilePath, StandardCharsets.UTF_8));
}
}
Aggregations