Skip to content

Commit 7cff6b3

Browse files
committed
fix QueryRequestConverterTest
1 parent 5971aef commit 7cff6b3

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

server/src/test/java/com/linecorp/centraldogma/server/internal/api/converter/QueryRequestConverterTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
package com.linecorp.centraldogma.server.internal.api.converter;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.mockito.ArgumentMatchers.eq;
2021
import static org.mockito.Mockito.mock;
2122
import static org.mockito.Mockito.when;
2223

2324
import javax.annotation.Nullable;
2425

2526
import org.junit.jupiter.api.Test;
2627

28+
import com.google.common.collect.ImmutableList;
29+
2730
import com.linecorp.armeria.common.AggregatedHttpRequest;
2831
import com.linecorp.armeria.server.ServiceRequestContext;
2932
import com.linecorp.centraldogma.common.Query;
@@ -61,8 +64,7 @@ void convertJsonPathQuery() throws Exception {
6164
final String jsonFilePath = "/a.json";
6265
when(ctx.pathParam("path")).thenReturn(jsonFilePath);
6366

64-
final String httpQuery = "?jsonpath=%22%24.a%22"; // "$.a"
65-
when(ctx.query()).thenReturn(httpQuery);
67+
when(ctx.queryParams(eq("jsonpath"))).thenReturn(ImmutableList.of("\"$.a\""));
6668

6769
final Query<?> query = convert(ctx);
6870
assertThat(query).isNotNull();
@@ -80,7 +82,7 @@ void withoutExpression() throws Exception {
8082
final String jsonFilePath = "/a.json";
8183
when(ctx.pathParam("path")).thenReturn(jsonFilePath);
8284

83-
when(ctx.query()).thenReturn("");
85+
when(ctx.queryParams(eq("jsonpath"))).thenReturn(ImmutableList.of());
8486

8587
final Query<?> query = convert(ctx);
8688
assertThat(query).isNotNull();

server/src/test/java/com/linecorp/centraldogma/server/internal/api/sysadmin/RawFileViewTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void getFileWithViewRaw() {
6767
.viewRaw(true)
6868
.get().join();
6969
// The raw content should be equal to the original JSON text.
70-
assertThat(entry.rawContent()).isEqualTo(jsonText);
70+
assertThat(entry.rawContent()).isEqualTo(jsonText + '\n');
7171
assertThat(entry.content()).isNotNull();
7272
assertThatJson(entry.content()).isEqualTo("{\"b\": 2,\"a\": 1}");
7373

@@ -101,12 +101,12 @@ void getFilesWithViewRaw() {
101101

102102
assertThat(entriesWithRaw).hasSize(2);
103103
final Entry<?> entry1WithRaw = entriesWithRaw.get("/file1.json");
104-
assertThat(entry1WithRaw.rawContent()).isEqualTo(jsonText1);
104+
assertThat(entry1WithRaw.rawContent()).isEqualTo(jsonText1 + '\n');
105105
assertThat(entry1WithRaw.content()).isNotNull();
106106
assertThatJson(entry1WithRaw.content()).isEqualTo("{\"key1\":\"value1\",\"key2\":\"value2\"}");
107107

108108
final Entry<?> entry2WithRaw = entriesWithRaw.get("/file2.json");
109-
assertThat(entry2WithRaw.rawContent()).isEqualTo(jsonText2);
109+
assertThat(entry2WithRaw.rawContent()).isEqualTo(jsonText2 + '\n');
110110
assertThat(entry2WithRaw.content()).isNotNull();
111111
assertThatJson(entry2WithRaw.content()).isEqualTo("{\"foo\":\"bar\"}");
112112

@@ -146,7 +146,7 @@ void watchWithViewRaw() {
146146
.start(initialResult.revision())
147147
.join();
148148

149-
assertThat(entryWithRaw.rawContent()).isEqualTo(updatedJsonText);
149+
assertThat(entryWithRaw.rawContent()).isEqualTo(updatedJsonText + '\n');
150150
assertThat(entryWithRaw.content()).isNotNull();
151151
assertThatJson(entryWithRaw.content()).isEqualTo("{\"version\":2}");
152152

@@ -237,14 +237,14 @@ void otherQueryTypesCanBeUsedWithViewRawForFile() {
237237
.get()
238238
.join();
239239
assertThat(jsonEntry).isNotNull();
240-
assertThat(jsonEntry.rawContent()).isEqualTo(jsonText);
240+
assertThat(jsonEntry.rawContent()).isEqualTo(jsonText + '\n');
241241

242242
// TEXT query should work with viewRaw
243243
final Entry<String> textEntry = repo.file(Query.ofText("/test.json"))
244244
.viewRaw(true)
245245
.get()
246246
.join();
247247
assertThat(textEntry).isNotNull();
248-
assertThat(textEntry.rawContent()).isEqualTo(jsonText);
248+
assertThat(textEntry.rawContent()).isEqualTo(jsonText + '\n');
249249
}
250250
}

0 commit comments

Comments
 (0)