Skip to content

Commit 3a818e7

Browse files
committed
Fix WatchJson5 test
1 parent a3c3e64 commit 3a818e7

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

it/src/test/java/com/linecorp/centraldogma/it/WatchTest.java

+20-16
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package com.linecorp.centraldogma.it;
1717

18-
import static com.linecorp.centraldogma.it.TestConstants.JSON5_CONTENTS;
1918
import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
2019
import static org.assertj.core.api.Assertions.assertThat;
2120
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -41,7 +40,6 @@
4140
import org.junit.jupiter.params.ParameterizedTest;
4241
import org.junit.jupiter.params.provider.EnumSource;
4342

44-
import com.fasterxml.jackson.core.JsonParseException;
4543
import com.fasterxml.jackson.databind.JsonNode;
4644
import com.fasterxml.jackson.databind.node.TextNode;
4745

@@ -59,7 +57,6 @@
5957
import com.linecorp.centraldogma.common.PushResult;
6058
import com.linecorp.centraldogma.common.Query;
6159
import com.linecorp.centraldogma.common.Revision;
62-
import com.linecorp.centraldogma.internal.Json5;
6360

6461
class WatchTest {
6562

@@ -783,17 +780,22 @@ class WatchJson5Test {
783780
void watchJson5() throws Exception {
784781
final CentralDogma client = dogma.client();
785782

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+
786788
final CompletableFuture<Entry<JsonNode>> future =
787789
client.forRepo(dogma.project(), dogma.repo1())
788-
.watch(Query.ofJson("/test/test1.json5"))
790+
.watch(Query.ofJson("/test/foo.json5"))
789791
.start(Revision.HEAD);
790792

791793
assertThatThrownBy(() -> future.get(500, TimeUnit.MILLISECONDS))
792794
.isInstanceOf(TimeoutException.class);
793795

794796
// Make change to an irrelevant file.
795797
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", "{}"))
797799
.push(Revision.HEAD)
798800
.join();
799801

@@ -803,30 +805,32 @@ void watchJson5() throws Exception {
803805
// Make change to a relevant file.
804806
final PushResult result =
805807
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'}"))
807809
.push(Revision.HEAD)
808810
.join();
809811

810812
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"));
812814
}
813815

814816
@Test
815-
void watchJson5_notNotifiedIfJsonContentNotChanged() throws JsonParseException {
817+
void watchJson5_notNotifiedIfJsonContentNotChanged() {
816818
final CentralDogma client = dogma.client();
817819

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+
818825
final CompletableFuture<Entry<JsonNode>> future =
819826
client.forRepo(dogma.project(), dogma.repo1())
820-
.watch(Query.ofJson("/test/test1.json5"))
827+
.watch(Query.ofJson("/test/bar.json5"))
821828
.start(Revision.HEAD);
822829

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();
830834

831835
// Watcher should not be notified since the JSON content is still the same.
832836
assertThatThrownBy(() -> future.get(1000, TimeUnit.MILLISECONDS))

0 commit comments

Comments
 (0)