1
1
package io.projectenv.intellijplugin.services.impl
2
2
3
+ import com.intellij.diagnostic.LogMessage
3
4
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
4
5
import com.intellij.openapi.diagnostic.SubmittedReportInfo
5
6
import com.intellij.testFramework.fixtures.BasePlatformTestCase
@@ -14,7 +15,7 @@ import org.mockito.Mockito.mock
14
15
import org.mockito.Mockito.mockStatic
15
16
import org.mockito.kotlin.any
16
17
import java.awt.Component
17
- import java.util.UUID
18
+ import java.util.*
18
19
19
20
class SentryErrorReportSubmitterIT : BasePlatformTestCase () {
20
21
@@ -39,7 +40,7 @@ class SentryErrorReportSubmitterIT : BasePlatformTestCase() {
39
40
}
40
41
sentry.`when `<SentryId > { Sentry .captureEvent(any()) }.then {
41
42
val event = it.getArgument<SentryEvent >(0 )
42
- assertThat(event.message?.formatted).isEqualTo(" java.lang.Throwable: test error " )
43
+ assertThat(event.message?.formatted).isEqualTo(" test message " )
43
44
44
45
SentryId (UUID .randomUUID())
45
46
}
@@ -73,7 +74,7 @@ class SentryErrorReportSubmitterIT : BasePlatformTestCase() {
73
74
}
74
75
sentry.`when `<SentryId > { Sentry .captureEvent(any()) }.then {
75
76
val event = it.getArgument<SentryEvent >(0 )
76
- assertThat(event.message?.formatted).isEqualTo(" java.lang.Throwable: test error " )
77
+ assertThat(event.message?.formatted).isEqualTo(" test message " )
77
78
78
79
SentryId .EMPTY_ID
79
80
}
@@ -86,4 +87,36 @@ class SentryErrorReportSubmitterIT : BasePlatformTestCase() {
86
87
}
87
88
}
88
89
}
90
+
91
+ @Test
92
+ fun testSubmitErrorsWithLogMessage () {
93
+ executeSubmitErrorsLogMessageTest()
94
+ }
95
+
96
+ private fun executeSubmitErrorsLogMessageTest () {
97
+ mockStatic(Sentry ::class .java).use { sentry ->
98
+ val throwable = Throwable (" test error" )
99
+ val message = " test message"
100
+
101
+ sentry.`when `<Void > { Sentry .init (any<Sentry .OptionsConfiguration <SentryOptions >>()) }.then {
102
+ // noop
103
+ }
104
+ sentry.`when `<SentryId > { Sentry .captureEvent(any()) }.then {
105
+ val event = it.getArgument<SentryEvent >(0 )
106
+ assertThat(event.message?.formatted).isEqualTo(message)
107
+ assertThat(event.throwable).isEqualTo(throwable)
108
+
109
+ SentryId (UUID .randomUUID())
110
+ }
111
+ sentry.`when `<Void > { Sentry .captureUserFeedback(any()) }.then {
112
+ val userFeedback = it.getArgument<UserFeedback >(0 )
113
+ assertThat(userFeedback.comments).isEqualTo(" test comment" )
114
+ }
115
+
116
+ val component = mock(Component ::class .java)
117
+ SentryErrorReportSubmitter ().submit(arrayOf(LogMessage .createEvent(throwable, message)), " test comment" , component) {
118
+ assertThat(it.status).isEqualTo(SubmittedReportInfo .SubmissionStatus .NEW_ISSUE )
119
+ }
120
+ }
121
+ }
89
122
}
0 commit comments