Package org.mockserver.model
Class ModerationResponse
java.lang.Object
org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.model.ObjectWithJsonToString
org.mockserver.model.ModerationResponse
Configuration for a mocked OpenAI Moderations endpoint response
(
POST /v1/moderations). Production LLM agents call the moderations
endpoint to decide whether user or model content should be blocked; mocking it
lets those agents be tested deterministically against both flagged and
not-flagged verdicts.
The wire shape is OpenAI's:
{"id":..,"model":..,"results":[{"flagged":bool,"categories":{..},"category_scores":{..}}]}.
Every category named in getFlaggedCategories() is marked
true (with a high score) and the top-level flagged is true
when the list is non-empty; all other categories are false (with a low
score). An empty/absent list yields a fully not-flagged verdict — the safe default.
Follows the model field/withX/getter convention so it round-trips through
the schema-validated expectation JSON without a bespoke (de)serializer.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleangetModel()inthashCode()static ModerationResponsewithFlaggedCategories(List<String> flaggedCategories) The moderation categories to markflagged=true(e.g.withFlaggedCategory(String category) Add a single category to the flagged set.Optional model identifier echoed in the response; defaults toomni-moderation-latest.Methods inherited from class org.mockserver.model.ObjectWithJsonToString
toStringMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
fieldsExcludedFromEqualsAndHashCode
-
Constructor Details
-
ModerationResponse
public ModerationResponse()
-
-
Method Details
-
moderationResponse
-
withFlaggedCategories
The moderation categories to markflagged=true(e.g."hate","violence","self-harm"). Unknown/unrecognised category names are ignored by the encoder. When null or empty the verdict is not-flagged. -
withFlaggedCategory
Add a single category to the flagged set. -
getFlaggedCategories
-
withModel
Optional model identifier echoed in the response; defaults toomni-moderation-latest. -
getModel
-
equals
- Overrides:
equalsin classObjectWithReflectiveEqualsHashCodeToString
-
hashCode
public int hashCode()- Overrides:
hashCodein classObjectWithReflectiveEqualsHashCodeToString
-