15
15
*/
16
16
package com .linecorp .centraldogma .it ;
17
17
18
- import static com .linecorp .centraldogma .it .TestConstants .JSON5_CONTENTS ;
19
18
import static net .javacrumbs .jsonunit .fluent .JsonFluentAssert .assertThatJson ;
20
19
import static org .assertj .core .api .Assertions .assertThat ;
21
20
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
41
40
import org .junit .jupiter .params .ParameterizedTest ;
42
41
import org .junit .jupiter .params .provider .EnumSource ;
43
42
44
- import com .fasterxml .jackson .core .JsonParseException ;
45
43
import com .fasterxml .jackson .databind .JsonNode ;
46
44
import com .fasterxml .jackson .databind .node .TextNode ;
47
45
59
57
import com .linecorp .centraldogma .common .PushResult ;
60
58
import com .linecorp .centraldogma .common .Query ;
61
59
import com .linecorp .centraldogma .common .Revision ;
62
- import com .linecorp .centraldogma .internal .Json5 ;
63
60
64
61
class WatchTest {
65
62
@@ -783,17 +780,22 @@ class WatchJson5Test {
783
780
void watchJson5 () throws Exception {
784
781
final CentralDogma client = dogma .client ();
785
782
783
+ client .forRepo (dogma .project (), dogma .repo1 ())
784
+ .commit ("Add foo.json5" , Change .ofJsonUpsert ("/test/foo.json5" , "{a: 'b'}" ))
785
+ .push (Revision .HEAD )
786
+ .join ();
787
+
786
788
final CompletableFuture <Entry <JsonNode >> future =
787
789
client .forRepo (dogma .project (), dogma .repo1 ())
788
- .watch (Query .ofJson ("/test/test1 .json5" ))
790
+ .watch (Query .ofJson ("/test/foo .json5" ))
789
791
.start (Revision .HEAD );
790
792
791
793
assertThatThrownBy (() -> future .get (500 , TimeUnit .MILLISECONDS ))
792
794
.isInstanceOf (TimeoutException .class );
793
795
794
796
// Make change to an irrelevant file.
795
797
client .forRepo (dogma .project (), dogma .repo1 ())
796
- .commit ("Edit foo.json " , Change .ofJsonUpsert ("/test/foo.json " , "{}" ))
798
+ .commit ("Add bar.json5 " , Change .ofJsonUpsert ("/test/bar.json5 " , "{}" ))
797
799
.push (Revision .HEAD )
798
800
.join ();
799
801
@@ -803,30 +805,32 @@ void watchJson5() throws Exception {
803
805
// Make change to a relevant file.
804
806
final PushResult result =
805
807
client .forRepo (dogma .project (), dogma .repo1 ())
806
- .commit ("Edit test1 .json5" , Change .ofJsonUpsert ("/test/test1 .json5" , "{a: 'foo'}" ))
808
+ .commit ("Edit foo .json5" , Change .ofJsonUpsert ("/test/foo .json5" , "{a: 'foo'}" ))
807
809
.push (Revision .HEAD )
808
810
.join ();
809
811
810
812
assertThat (future .get (3 , TimeUnit .SECONDS )).isEqualTo (
811
- Entry .ofJson (result .revision (), "/test/test1 .json5" , "{a: 'foo'}\n " ));
813
+ Entry .ofJson (result .revision (), "/test/foo .json5" , "{a: 'foo'}\n " ));
812
814
}
813
815
814
816
@ Test
815
- void watchJson5_notNotifiedIfJsonContentNotChanged () throws JsonParseException {
817
+ void watchJson5_notNotifiedIfJsonContentNotChanged () {
816
818
final CentralDogma client = dogma .client ();
817
819
820
+ client .forRepo (dogma .project (), dogma .repo1 ())
821
+ .commit ("Add bar.json5" , Change .ofJsonUpsert ("/test/bar.json5" , "{a: 'b'}" ))
822
+ .push (Revision .HEAD )
823
+ .join ();
824
+
818
825
final CompletableFuture <Entry <JsonNode >> future =
819
826
client .forRepo (dogma .project (), dogma .repo1 ())
820
- .watch (Query .ofJson ("/test/test1 .json5" ))
827
+ .watch (Query .ofJson ("/test/bar .json5" ))
821
828
.start (Revision .HEAD );
822
829
823
- // Edit file to the plain JSON, so it doesn't change the actual JSON content in it.
824
- final JsonNode plainJson = Json5 .readTree (JSON5_CONTENTS );
825
- client .forRepo (dogma .project (), dogma .repo1 ())
826
- .commit ("Edit test1.json5" ,
827
- Change .ofJsonUpsert ("/test/test1.json5" , plainJson ))
828
- .push (Revision .HEAD )
829
- .join ();
830
+ client .forRepo (dogma .project (), dogma .repo1 ())
831
+ .commit ("Edit bar.json5" , Change .ofJsonUpsert ("/test/bar.json5" , "{\" a\" : \" b\" }" ))
832
+ .push (Revision .HEAD )
833
+ .join ();
830
834
831
835
// Watcher should not be notified since the JSON content is still the same.
832
836
assertThatThrownBy (() -> future .get (1000 , TimeUnit .MILLISECONDS ))
0 commit comments