File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
main/java/io/quarkiverse/openapi/generator
test/java/io/quarkiverse/openapi/generator Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 2020import io .quarkus .deployment .IsDevelopment ;
2121import io .quarkus .deployment .annotations .BuildProducer ;
2222import io .quarkus .deployment .annotations .BuildStep ;
23+ import io .quarkus .deployment .builditem .HotDeploymentWatchedFileBuildItem ;
2324import io .quarkus .runtime .util .ClassPathUtils ;
2425
2526public class MoquProjectProcessor {
@@ -68,6 +69,16 @@ MoquProjectBuildItem generate(MoquConfig config) {
6869 }
6970 }
7071
72+ @ BuildStep (onlyIf = { IsDevelopment .class })
73+ void watchOpenApiFiles (MoquConfig config , BuildProducer <HotDeploymentWatchedFileBuildItem > watchedPaths )
74+ throws IOException {
75+ ClassPathUtils .consumeAsPaths (config .resourceDir (), path -> {
76+ if (Files .exists (path )) {
77+ watchedPaths .produce (new HotDeploymentWatchedFileBuildItem (path .toString (), Files .isDirectory (path )));
78+ }
79+ });
80+ }
81+
7182 @ BuildStep (onlyIf = { IsDevelopment .class })
7283 void consume (Optional <MoquProjectBuildItem > moquProject ,
7384 BuildProducer <MoquBuildItem > moquMocks ) {
Original file line number Diff line number Diff line change 99
1010public class MoquProjectProcessorTest {
1111
12+ private static final String WIREMOCK_MAPPINGS_JSON_PATH = "/q/moqu/json/api/wiremock-mappings.json" ;
13+
1214 @ RegisterExtension
1315 static final QuarkusDevModeTest unitTest = new QuarkusDevModeTest ()
1416 .withApplicationRoot (javaArchive -> javaArchive
@@ -38,10 +40,27 @@ void testModeAsDownload() {
3840 @ Test
3941 void testModeAsDownloadUsingJson () {
4042 RestAssured .given ()
41- .when ().get ("/q/moqu/json/api/wiremock-mappings.json" )
43+ .when ().get (WIREMOCK_MAPPINGS_JSON_PATH )
4244 .then ()
4345 .statusCode (200 )
4446 .body (Matchers .containsString ("Alice" ))
4547 .log ().ifError ();
4648 }
49+
50+ @ Test
51+ void testDevModeWatchOpenApiFiles () {
52+ RestAssured .given ()
53+ .when ().get (WIREMOCK_MAPPINGS_JSON_PATH )
54+ .then ()
55+ .statusCode (200 )
56+ .body (Matchers .containsString ("80" ));
57+
58+ unitTest .modifyResourceFile ("openapi/api.json" , (content ) -> content .replace ("80" , "77" ));
59+
60+ RestAssured .given ()
61+ .when ().get (WIREMOCK_MAPPINGS_JSON_PATH )
62+ .then ()
63+ .statusCode (200 )
64+ .body (Matchers .containsString ("77" ));
65+ }
4766}
You can’t perform that action at this time.
0 commit comments