### Question:
OpenApiSecuritySizeEqValidator implements OpenApiValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, OpenAPI openAPI) { int size = CollectionUtils.size(openAPI.getSecurity()); if (size != expectedSize) { return singletonList( new OasViolation(location.property("security", SECURITY_REQUIREMENT), ERROR + expectedSize)); } return emptyList(); } OpenApiSecuritySizeEqValidator(int expectedSize); @Override List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location,
    OpenAPI openAPI); static final String CONFIG_KEY; static final String ERROR; }### Answer:
@Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-security-empty.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OpenApiSecuritySizeEqValidator.CONFIG_KEY, "0") ); List<OasViolation> violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations) .containsExactly( createViolation(OpenApiSecuritySizeEqValidator.ERROR + "0", "security", SECURITY_REQUIREMENT)); }
@Test public void testValidateGood() { OpenAPI openAPI = loadRelative("petstore-security-empty-good.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OpenApiSecuritySizeEqValidator.CONFIG_KEY, "0") ); List<OasViolation> violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).isEmpty(); }