Skip to content

Commit

Permalink
add one more integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
pboos committed Nov 22, 2023
1 parent d3f37bf commit adfa254
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.options;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
Expand Down Expand Up @@ -109,13 +110,26 @@ public void whenTestInvalidRequestAndInvalidResponseThenShouldReturnSuccessAndLo
assertEquals(Optional.of("/value"), violation2.getInstance());
}

@Test
public void whenTestOptionsCallThenShouldNotValidate() throws Exception {
// Note: Options is not in the spec and would report a violation if it was validated.
mockMvc.perform(options("/test"))
.andExpectAll(
status().isOk(),
content().string(Matchers.blankOrNullString())
);
Thread.sleep(100);

assertEquals(0, openApiViolationLogger.getViolations().size());
}

// TODO Add test that fails on request violation immediately (maybe needs separate test class & setup) should not log violation

@Nullable
private OpenApiViolation getViolationByRule(List<OpenApiViolation> violations, String rule) {
return violations.stream()
.filter(violation -> violation.getRule().equals(rule))
.findFirst()
.orElse(null);
}

// TODO Add test that fails on request violation immediately (maybe needs separate test class & setup)
}

0 comments on commit adfa254

Please sign in to comment.