diff --git a/it/src/test/java/com/linecorp/centraldogma/it/WatchTest.java b/it/src/test/java/com/linecorp/centraldogma/it/WatchTest.java index 1bbbe0d5c6..11674b6126 100644 --- a/it/src/test/java/com/linecorp/centraldogma/it/WatchTest.java +++ b/it/src/test/java/com/linecorp/centraldogma/it/WatchTest.java @@ -15,7 +15,6 @@ */ package com.linecorp.centraldogma.it; -import static com.linecorp.centraldogma.it.TestConstants.JSON5_CONTENTS; import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -41,7 +40,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; -import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; @@ -59,7 +57,6 @@ import com.linecorp.centraldogma.common.PushResult; import com.linecorp.centraldogma.common.Query; import com.linecorp.centraldogma.common.Revision; -import com.linecorp.centraldogma.internal.Json5; class WatchTest { @@ -783,9 +780,14 @@ class WatchJson5Test { void watchJson5() throws Exception { final CentralDogma client = dogma.client(); + client.forRepo(dogma.project(), dogma.repo1()) + .commit("Add foo.json5", Change.ofJsonUpsert("/test/foo.json5", "{a: 'b'}")) + .push(Revision.HEAD) + .join(); + final CompletableFuture> future = client.forRepo(dogma.project(), dogma.repo1()) - .watch(Query.ofJson("/test/test1.json5")) + .watch(Query.ofJson("/test/foo.json5")) .start(Revision.HEAD); assertThatThrownBy(() -> future.get(500, TimeUnit.MILLISECONDS)) @@ -793,7 +795,7 @@ void watchJson5() throws Exception { // Make change to an irrelevant file. client.forRepo(dogma.project(), dogma.repo1()) - .commit("Edit foo.json", Change.ofJsonUpsert("/test/foo.json", "{}")) + .commit("Add bar.json5", Change.ofJsonUpsert("/test/bar.json5", "{}")) .push(Revision.HEAD) .join(); @@ -803,30 +805,32 @@ void watchJson5() throws Exception { // Make change to a relevant file. final PushResult result = client.forRepo(dogma.project(), dogma.repo1()) - .commit("Edit test1.json5", Change.ofJsonUpsert("/test/test1.json5", "{a: 'foo'}")) + .commit("Edit foo.json5", Change.ofJsonUpsert("/test/foo.json5", "{a: 'foo'}")) .push(Revision.HEAD) .join(); assertThat(future.get(3, TimeUnit.SECONDS)).isEqualTo( - Entry.ofJson(result.revision(), "/test/test1.json5", "{a: 'foo'}\n")); + Entry.ofJson(result.revision(), "/test/foo.json5", "{a: 'foo'}\n")); } @Test - void watchJson5_notNotifiedIfJsonContentNotChanged() throws JsonParseException { + void watchJson5_notNotifiedIfJsonContentNotChanged() { final CentralDogma client = dogma.client(); + client.forRepo(dogma.project(), dogma.repo1()) + .commit("Add bar.json5", Change.ofJsonUpsert("/test/bar.json5", "{a: 'b'}")) + .push(Revision.HEAD) + .join(); + final CompletableFuture> future = client.forRepo(dogma.project(), dogma.repo1()) - .watch(Query.ofJson("/test/test1.json5")) + .watch(Query.ofJson("/test/bar.json5")) .start(Revision.HEAD); - // Edit file to the plain JSON, so it doesn't change the actual JSON content in it. - final JsonNode plainJson = Json5.readTree(JSON5_CONTENTS); - client.forRepo(dogma.project(), dogma.repo1()) - .commit("Edit test1.json5", - Change.ofJsonUpsert("/test/test1.json5", plainJson)) - .push(Revision.HEAD) - .join(); + client.forRepo(dogma.project(), dogma.repo1()) + .commit("Edit bar.json5", Change.ofJsonUpsert("/test/bar.json5", "{\"a\": \"b\"}")) + .push(Revision.HEAD) + .join(); // Watcher should not be notified since the JSON content is still the same. assertThatThrownBy(() -> future.get(1000, TimeUnit.MILLISECONDS))