use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitControllerBase method consumeEvents.
/**
* An exception was intercepted. Make sure we notify any started() events that haven't been notified of failed().
*
* @param t Caught exception.
*/
private void consumeEvents(Throwable t) {
if (!events.isEmpty()) {
skipEventTracking = true;
try {
// Operations in progress, no failed issued for them.
while (!events.isEmpty()) {
GitEventInfo pop = events.pop();
gitAccess.fireOperationFailed(pop, t);
}
} finally {
skipEventTracking = false;
}
}
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class GitControllerTest method testFailPushNotification.
/**
* For asynchronous tasks we always issue fail events when exceptions are thrown.
*
* @throws Exception If it fails.
*/
@Test
public void testFailPushNotification() throws Exception {
GitAccess mock = Mockito.mock(GitAccess.class);
// When Push will be invoked a runtime exception is thrown.
GitController ctrl = new GitController(mock);
StringBuilder b = new StringBuilder();
ctrl.addGitListener(new GitEventListener() {
@Override
public void operationSuccessfullyEnded(GitEventInfo info) {
b.append("E: " + info.toString()).append("\n");
}
@Override
public void operationFailed(GitEventInfo info, Throwable t) {
b.append("F: ").append(info.toString()).append("\n");
b.append(" ").append(t.getClass()).append("\n");
}
@Override
public void operationAboutToStart(GitEventInfo info) {
b.append("S: ").append(info.toString()).append("\n");
}
});
Future<?> push = ctrl.push();
push.get();
Assert.assertEquals("Not the expected events", "S: Status: null, message: Push_In_Progress GitEventInfo [Operation: PUSH].\n" + "F: Status: null, message: Push_failed: null GitEventInfo [Operation: PUSH].\n" + " class java.lang.NullPointerException\n" + "", b.toString());
}
use of com.oxygenxml.git.view.event.GitEventInfo in project oxygen-git-client-addon by oxygenxml.
the class StatusCacheTest method testGitEvent.
/**
* <p><b>Description:</b> A git event resets the cache.</p>
* <p><b>Bug ID:</b> EXM-49363</p>
*
* @author alex_jitianu
*
* @throws Exception If it fails.
*/
public void testGitEvent() throws Exception {
OxygenGitPluginExtension extension = new OxygenGitPluginExtension();
PluginWorkspace pluginWorkspace = PluginWorkspaceProvider.getPluginWorkspace();
JFrame mockFrame = new JFrame();
Mockito.when(pluginWorkspace.getParentFrame()).thenReturn(mockFrame);
// These operations do not affect a status.
List<GitOperation> exceptions = Arrays.asList(GitOperation.DELETE_BRANCH, GitOperation.PUSH);
extension.applicationStarted((StandalonePluginWorkspace) pluginWorkspace);
Arrays.stream(GitOperation.values()).forEach(op -> {
GitStatus status = GitAccess.getInstance().getStatus();
GitEventAdapter listener = new GitEventAdapter() {
@Override
public void operationSuccessfullyEnded(GitEventInfo info) {
// When a normal listener receives a git event, if it requests the status it
// should receive a newly computed status, not the stale one from cache.
assertStatus(exceptions, op, status);
}
};
GitListeners.getInstance().addGitListener(listener);
GitListeners.getInstance().fireOperationSuccessfullyEnded(new GitEventInfo(op));
GitListeners.getInstance().removeGitListener(listener);
assertStatus(exceptions, op, status);
});
}
Aggregations