use of com.oxygenxml.git.service.PushResponse in project oxygen-git-client-addon by oxygenxml.
the class TreeViewTest method testConflict_resolveUsingMine.
/**
* Resolve a conflict using my copy.
*
* @throws Exception If it fails.
*/
public void testConflict_resolveUsingMine() throws Exception {
/**
* Local repository location.
*/
String localTestRepository = "target/test-resources/testConflict_resolveUsingMine_local";
/**
* Remote repository location.
*/
String remoteTestRepository = "target/test-resources/testConflict_resolveUsingMine_remote";
String localTestRepository2 = localTestRepository + "2";
File file2 = new File(localTestRepository2 + "/test.txt");
// Create repositories
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo1 = createRepository(localTestRepository);
Repository localRepo2 = createRepository(localTestRepository2);
// Bind the local repository to the remote one.
bindLocalToRemote(localRepo2, remoteRepo);
// Bind the local repository to the remote one.
bindLocalToRemote(localRepo1, remoteRepo);
// Create a new file and push it.
new File(localTestRepository).mkdirs();
File file = new File(localTestRepository + "/test.txt");
createNewFile(localTestRepository, "test.txt", "content");
add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
GitAccess.getInstance().commit("First version.");
PushResponse push = push("", "");
assertEquals("status: OK message null", push.toString());
GitAccess.getInstance().setRepositorySynchronously(localTestRepository2);
// Commit a new version of the file.
setFileContent(file2, "modified from 2nd local repo");
add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
push("", "");
// Change back the repo.
GitAccess.getInstance().setRepositorySynchronously(localTestRepository);
// Change the file. Create a conflict.
setFileContent(file, "modified from 1st repo");
add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
// Get the remote. The conflict appears.
pull();
flushAWT();
sleep(300);
assertTreeModels("CONFLICT, test.txt", "");
stagingPanel.getGitController().asyncResolveUsingMine(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
waitForScheduler();
waitForScheluerBetter();
assertTreeModels("", "");
// Check the commit.
CommitAndStatusPanel commitPanel = stagingPanel.getCommitPanel();
assertEquals("Commit_to_merge", commitPanel.getCommitMessageArea().getText());
commitPanel.getCommitButton().doClick();
waitForScheduler();
// TODO What should it assert here?
assertEquals("", "");
}
use of com.oxygenxml.git.service.PushResponse in project oxygen-git-client-addon by oxygenxml.
the class TreeViewTest method testConflict_resolveUsingTheirsAndRestartMerge.
/**
* Resolve a conflict using "their" copy, restart merge, and resolve again.
*
* @throws Exception If it fails.
*/
public void testConflict_resolveUsingTheirsAndRestartMerge() throws Exception {
/**
* Local repository location.
*/
String localTestRepository = "target/test-resources/testConflict_resolveUsingTheirs_local";
/**
* Remote repository location.
*/
String remoteTestRepository = "target/test-resources/testConflict_resolveUsingTheirs_remote";
String localTestRepository2 = localTestRepository + "2";
File file2 = new File(localTestRepository2 + "/test.txt");
// Create repositories
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo1 = createRepository(localTestRepository);
Repository localRepo2 = createRepository(localTestRepository2);
// Bind the local repository to the remote one.
bindLocalToRemote(localRepo2, remoteRepo);
// Bind the local repository to the remote one.
bindLocalToRemote(localRepo1, remoteRepo);
// Create a new file and push it.
new File(localTestRepository).mkdirs();
File file = createNewFile(localTestRepository, "test.txt", "content");
add(new FileStatus(GitChangeType.UNKNOWN, "test.txt"));
GitAccess.getInstance().commit("First version.");
PushResponse push = push("", "");
assertEquals("status: OK message null", push.toString());
GitAccess.getInstance().setRepositorySynchronously(localTestRepository2);
// Commit a new version of the file.
setFileContent(file2, "modified from 2nd local repo");
add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
push("", "");
// Change back the repo.
GitAccess.getInstance().setRepositorySynchronously(localTestRepository);
// Change the file. Create a conflict.
setFileContent(file, "modified from 1st repo");
add(new FileStatus(GitChangeType.MODIFIED, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
// Get the remote. The conflict appears.
pull();
flushAWT();
assertTreeModels("CONFLICT, test.txt", "");
// Resolve using theirs
stagingPanel.getGitController().asyncResolveUsingTheirs(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
waitForScheduler();
assertTreeModels("", "CHANGED, test.txt");
// Restart merge
ScheduledFuture<?> restartMerge = GitAccess.getInstance().restartMerge();
restartMerge.get();
flushAWT();
assertTreeModels("CONFLICT, test.txt", "");
// Resolve again using theirs
stagingPanel.getGitController().asyncResolveUsingTheirs(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
waitForScheduler();
assertTreeModels("", "CHANGED, test.txt");
// Commit
GitAccess.getInstance().commit("commit");
flushAWT();
assertTreeModels("", "");
}
use of com.oxygenxml.git.service.PushResponse in project oxygen-git-client-addon by oxygenxml.
the class FlatView2Test method testAPullCannotLockRef.
/**
* <p><b>Description:</b> lock fail test.</p>
* <p><b>Bug ID:</b> EXM-42867</p>
*
* @author sorin_carbunaru
*
* @throws Exception If it fails.
*/
@Test
public void testAPullCannotLockRef() throws Exception {
PluginWorkspace pluginWorkspaceMock = PluginWorkspaceProvider.getPluginWorkspace();
final boolean[] showErrorMessageCalled = new boolean[] { false };
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
showErrorMessageCalled[0] = true;
return null;
}
}).when(pluginWorkspaceMock).showErrorMessage(Mockito.anyString());
PluginWorkspaceProvider.setPluginWorkspace(pluginWorkspaceMock);
String localTestRepository = "target/test-resources/testStageUnstage_ModifiedFile_local_pullCannotLock";
String remoteTestRepository = "target/test-resources/testStageUnstage_ModifiedFile_remote_pullCannotLock";
// Create repositories
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo = createRepository(localTestRepository);
bindLocalToRemote(localRepo, remoteRepo);
sleep(700);
// Create a new file and push it.
String fileName = "test.txt";
File file = commitNewFile(localTestRepository, fileName, "content");
PushResponse push = push("", "");
assertEquals("status: OK message null", push.toString());
// Create lock files
String repoDir = GitAccess.getInstance().getRepository().getDirectory().getAbsolutePath();
Ref ref = GitAccess.getInstance().getRemoteBrachListForCurrentRepo().get(0);
File lockFile = new File(repoDir, ref.getName() + ".lock");
boolean createNewFile = lockFile.createNewFile();
assertTrue("Unnable to create lock file " + lockFile.getAbsolutePath(), createNewFile);
setFileContent(lockFile, GitAccess.getInstance().getLastLocalCommitInRepo().getName());
// Commit a new version of the file.
setFileContent(file, "modified");
GitAccess.getInstance().add(new FileStatus(GitChangeType.MODIFIED, fileName));
GitAccess.getInstance().commit("modified");
push("", "");
assertEquals("status: OK message null", push.toString());
// Pull should throw "Lock failed" error
PullResponse pullResponse = pull("", "", PullType.MERGE_FF, false);
assertEquals(PullStatus.LOCK_FAILED, pullResponse.getStatus());
assertTrue(showErrorMessageCalled[0]);
Future<?> execute = ((GitController) stagingPanel.getGitController()).pull();
execute.get();
flushAWT();
assertEquals("Lock_failed", stagingPanel.getCommitPanel().getStatusLabel().getText());
}
use of com.oxygenxml.git.service.PushResponse in project oxygen-git-client-addon by oxygenxml.
the class FlatViewTest method testConflict_resolveUsingMine.
/**
* Resolve a conflict using my copy.
*
* @throws Exception If it fails.
*/
public void testConflict_resolveUsingMine() throws Exception {
String localTestRepository = "target/test-resources/testConflict_resolveUsingMine_local";
String remoteTestRepository = "target/test-resources/testConflict_resolveUsingMine_remote";
String localTestRepository2 = localTestRepository + "2";
File file2 = new File(localTestRepository2 + "/test.txt");
// Create repositories
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo1 = createRepository(localTestRepository);
Repository localRepo2 = createRepository(localTestRepository2);
bindLocalToRemote(localRepo1, remoteRepo);
bindLocalToRemote(localRepo2, remoteRepo);
// Create a new file and push it.
new File(localTestRepository).mkdirs();
File file = createNewFile(localTestRepository, "test.txt", "content");
add(new FileStatus(GitChangeType.ADD, "test.txt"));
GitAccess.getInstance().commit("First version.");
PushResponse push = push("", "");
assertEquals("status: OK message null", push.toString());
GitAccess.getInstance().setRepositorySynchronously(localTestRepository2);
// Commit a new version of the file.
setFileContent(file2, "modified from 2nd local repo");
add(new FileStatus(GitChangeType.ADD, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
push("", "");
// Change back the repo.
GitAccess.getInstance().setRepositorySynchronously(localTestRepository);
// Change the file. Create a conflict.
setFileContent(file, "modified from 1st repo");
add(new FileStatus(GitChangeType.ADD, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
// Get the remote. The conflict appears.
pull();
flushAWT();
assertTableModels("CONFLICT, test.txt", "");
stagingPanel.getGitController().asyncResolveUsingMine(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
waitForScheduler();
waitForScheluerBetter();
assertTableModels("", "");
// Check the commit.
CommitAndStatusPanel commitPanel = stagingPanel.getCommitPanel();
assertEquals("Commit_to_merge", commitPanel.getCommitMessageArea().getText());
commitPanel.getCommitButton().doClick();
flushAWT();
// TODO Alex What should it assert here?
assertEquals("", "");
}
use of com.oxygenxml.git.service.PushResponse in project oxygen-git-client-addon by oxygenxml.
the class FlatViewTest method testConflict_resolveUsingTheirsAndRestartMerge.
/**
* Resolve a conflict using "their" copy, restart merge, and resolve again.
*
* @throws Exception If it fails.
*/
public void testConflict_resolveUsingTheirsAndRestartMerge() throws Exception {
String localTestRepository = "target/test-resources/testConflict_resolveUsingTheirs_local";
String remoteTestRepository = "target/test-resources/testConflict_resolveUsingTheirs_remote";
String localTestRepository2 = localTestRepository + "2";
File file2 = new File(localTestRepository2 + "/test.txt");
// Create repositories
Repository remoteRepo = createRepository(remoteTestRepository);
Repository localRepo1 = createRepository(localTestRepository);
Repository localRepo2 = createRepository(localTestRepository2);
bindLocalToRemote(localRepo1, remoteRepo);
bindLocalToRemote(localRepo2, remoteRepo);
// Create a new file and push it.
new File(localTestRepository).mkdirs();
File file = createNewFile(localTestRepository, "test.txt", "content");
add(new FileStatus(GitChangeType.ADD, "test.txt"));
GitAccess.getInstance().commit("First version.");
PushResponse push = push("", "");
assertEquals("status: OK message null", push.toString());
GitAccess.getInstance().setRepositorySynchronously(localTestRepository2);
// Commit a new version of the file.
setFileContent(file2, "modified from 2nd local repo");
add(new FileStatus(GitChangeType.ADD, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
push("", "");
// Change back the repo.
GitAccess.getInstance().setRepositorySynchronously(localTestRepository);
// Change the file. Create a conflict.
setFileContent(file, "modified from 1st repo");
add(new FileStatus(GitChangeType.ADD, "test.txt"));
GitAccess.getInstance().commit("modified from 2nd local repo");
// Get the remote. The conflict appears.
pull();
flushAWT();
assertTableModels("CONFLICT, test.txt", "");
// Resolve using theirs
stagingPanel.getGitController().asyncResolveUsingTheirs(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
waitForScheduler();
assertTableModels("", "CHANGED, test.txt");
// Restart merge
ScheduledFuture<?> restartMerge = GitAccess.getInstance().restartMerge();
restartMerge.get();
flushAWT();
assertTableModels("CONFLICT, test.txt", "");
// Resolve again using theirs
stagingPanel.getGitController().asyncResolveUsingTheirs(Arrays.asList(new FileStatus(GitChangeType.CONFLICT, "test.txt")));
waitForScheduler();
assertTableModels("", "CHANGED, test.txt");
// Commit
// TODO Alex What should it assert here?
GitAccess.getInstance().commit("commit");
assertTableModels("", "");
}
Aggregations