File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
firebase-vertexai/src/test/java/com/google/firebase/vertexai Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,18 @@ internal class StreamingSnapshotTests {
123
123
}
124
124
}
125
125
126
+ @Test
127
+ fun `prompt blocked for safety with message` () =
128
+ goldenStreamingFile(" streaming-failure-prompt-blocked-safety-with-message.txt" ) {
129
+ val responses = model.generateContentStream(" prompt" )
130
+
131
+ withTimeout(testTimeout) {
132
+ val exception = shouldThrow<PromptBlockedException > { responses.collect() }
133
+ exception.response.promptFeedback?.blockReason shouldBe BlockReason .SAFETY
134
+ exception.response.promptFeedback?.blockReasonMessage shouldBe " Reasons"
135
+ }
136
+ }
137
+
126
138
@Test
127
139
fun `empty content` () =
128
140
goldenStreamingFile(" streaming-failure-empty-content.txt" ) {
Original file line number Diff line number Diff line change @@ -167,6 +167,18 @@ internal class UnarySnapshotTests {
167
167
}
168
168
}
169
169
170
+ @Test
171
+ fun `prompt blocked for safety with message` () =
172
+ goldenUnaryFile(" unary-failure-prompt-blocked-safety-with-message.json" ) {
173
+ withTimeout(testTimeout) {
174
+ shouldThrow<PromptBlockedException > { model.generateContent(" prompt" ) } should
175
+ {
176
+ it.response.promptFeedback?.blockReason shouldBe BlockReason .SAFETY
177
+ it.response.promptFeedback?.blockReasonMessage shouldContain " Reasons"
178
+ }
179
+ }
180
+ }
181
+
170
182
@Test
171
183
fun `empty content` () =
172
184
goldenUnaryFile(" unary-failure-empty-content.json" ) {
You can’t perform that action at this time.
0 commit comments