-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathCsvGithubIssueSubmitterTest.java
More file actions
52 lines (41 loc) · 3.06 KB
/
CsvGithubIssueSubmitterTest.java
File metadata and controls
52 lines (41 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package net.seesharpsoft.intellij.plugins.csv;
import com.intellij.openapi.diagnostic.IdeaLoggingEvent;
import com.intellij.testFramework.UsefulTestCase;
import java.io.PrintStream;
import java.io.PrintWriter;
public class CsvGithubIssueSubmitterTest extends UsefulTestCase {
// for accessing protected methods during test
class CsvGithubIssueSubmitterSubClass extends CsvGithubIssueSubmitter {
}
class DummyException extends Throwable {
public DummyException(String message) {
super(message);
}
public void printStackTrace(PrintStream stream) {
stream.println(this.getMessage());
}
public void printStackTrace(PrintWriter writer) {
writer.println(this.getMessage());
}
}
private CsvGithubIssueSubmitterSubClass classUnderTest = new CsvGithubIssueSubmitterSubClass();
public void testSearchExistingIssuesNeedle() throws Exception {
assertEquals("crash", classUnderTest.searchExistingIssuesNeedle(null));
assertEquals("crash", classUnderTest.searchExistingIssuesNeedle(""));
assertEquals("crash", classUnderTest.searchExistingIssuesNeedle(" "));
assertEquals("test", classUnderTest.searchExistingIssuesNeedle("test"));
assertEquals("test", classUnderTest.searchExistingIssuesNeedle("[Automated Report] test"));
assertEquals("[Automated Report]", classUnderTest.searchExistingIssuesNeedle("[Automated Report]"));
}
public void testGetIssueTitle() {
assertEquals("[Automated Report] Test", classUnderTest.getIssueTitle(new IdeaLoggingEvent("Test", new DummyException("Test"))));
assertEquals("[Automated Report] Unhandled exception in [CoroutineName(com.intellij.openapi.fileEditor.impl.PsiAwareFileEditorManagerImpl), StandaloneCoroutine{Cancelling}, Dispatchers.Default]", classUnderTest.getIssueTitle(new IdeaLoggingEvent("Test", new DummyException("Unhandled exception in [CoroutineName(com.intellij.openapi.fileEditor.impl.PsiAwareFileEditorManagerImpl), StandaloneCoroutine{Cancelling}@5cfe3e69, Dispatchers.Default]"))));
assertEquals("[Automated Report] An invalid state was detected that occurs if the key's equals or hashCode was modified while it resided in the cache. This violation of the Map contract can lead to non-deterministic behavior (key: com.intellij.psi.impl.ElementBase$ElementIconRequest, key type: ElementIconRequest, node type: PSMS, cache type: SSMS).",
classUnderTest.getIssueTitle(new IdeaLoggingEvent("", new DummyException("An invalid state was detected that occurs if the key's equals or hashCode was modified while it resided in the cache. This violation of the Map contract can lead to non-deterministic behavior (key: com.intellij.psi.impl.ElementBase$ElementIconRequest@e2330a, key type: ElementIconRequest, node type: PSMS, cache type: SSMS)."))));
}
public void testRecentSent() {
assertEquals(false, classUnderTest.reportWasRecentlySent());
classUnderTest.reportWasSent();
assertEquals(true, classUnderTest.reportWasRecentlySent());
}
}