Skip to content

Commit 3a0e421

Browse files
authored
[ZEPPELIN-6316] Fix broken tests caused by field name change
### What is this PR for? After a field name change in `NewNoteRequest`, several tests are failing. ``` Error: Failures: Error: NotebookRestApiTest.testCreateNote:555->lambda$testCreateNote$17:557 expected: <test1> but was: <Untitled Note> Error: ZeppelinRestApiTest.testCloneNote:440->lambda$testCloneNote$8:443 Compare note names ==> expected: <clone Note Name> but was: <Cloned Note_2M6SWJ8WV> Error: ZeppelinRestApiTest.testNoteCreateWithName:159->testNoteCreate:235->lambda$testNoteCreate$2:245 compare note name ==> expected: <Test note name> but was: <Untitled Note> Error: ZeppelinRestApiTest.testNoteCreateWithParagraphs:181 test note create method: ``` Related Issue: #5055 ### What type of PR is it? Fixing broken tests ### What is the Jira issue? [ZEPPELIN-6316](https://issues.apache.org/jira/browse/ZEPPELIN-6316) ### How should this be tested? - Check if tests success in `core-modules` job. - `NotebookRestApiTest.testCreateNote` - `ZeppelinRestApiTest.testCloneNote` - `ZeppelinRestApiTest.testNoteCreateWithName` - `ZeppelinRestApiTest.testNoteCreateWithParagraphs` ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes #5066 from tbonelee/fix-tests. Signed-off-by: ParkGyeongTae <[email protected]>
1 parent a0ef5b8 commit 3a0e421

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

zeppelin-client/src/main/java/org/apache/zeppelin/client/ZeppelinClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public String createNote(String notePath) throws Exception {
303303
*/
304304
public String createNote(String notePath, String defaultInterpreterGroup) throws Exception {
305305
JSONObject bodyObject = new JSONObject();
306-
bodyObject.put("name", notePath);
306+
bodyObject.put("notePath", notePath);
307307
bodyObject.put("defaultInterpreterGroup", defaultInterpreterGroup);
308308
HttpResponse<JsonNode> response = Unirest
309309
.post("/notebook")

zeppelin-server/src/test/java/org/apache/zeppelin/rest/NotebookRestApiTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ void testRunParagraphSynchronously() throws IOException {
543543
@Test
544544
void testCreateNote() throws Exception {
545545
LOGGER.info("Running testCreateNote");
546-
String message1 = "{\n\t\"name\" : \"test1\",\n\t\"addingEmptyParagraph\" : true\n}";
546+
String message1 = "{\n\t\"notePath\" : \"test1\",\n\t\"addingEmptyParagraph\" : true\n}";
547547
CloseableHttpResponse post1 = httpPost("/notebook/", message1);
548548
assertThat(post1, isAllowed());
549549

@@ -555,14 +555,15 @@ void testCreateNote() throws Exception {
555555
notebook.processNote(note1Id,
556556
note1 -> {
557557
assertEquals("test1", note1.getName());
558+
assertEquals("/test1", note1.getPath());
558559
assertEquals(1, note1.getParagraphCount());
559560
assertNull(note1.getParagraph(0).getText());
560561
assertNull(note1.getParagraph(0).getTitle());
561562
return null;
562563
});
563564

564565

565-
String message2 = "{\n\t\"name\" : \"test2\"\n}";
566+
String message2 = "{\n\t\"notePath\" : \"test2\"\n}";
566567
CloseableHttpResponse post2 = httpPost("/notebook/", message2);
567568
assertThat(post2, isAllowed());
568569

@@ -576,6 +577,7 @@ void testCreateNote() throws Exception {
576577
return note;
577578
});
578579
assertEquals("test2", note2.getName());
580+
assertEquals("/test2", note2.getPath());
579581
assertEquals(0, note2.getParagraphCount());
580582
}
581583

zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void testNoteCreateNoName() throws IOException {
168168
void testNoteCreateWithParagraphs() throws IOException {
169169
// Call Create Note REST API
170170
String noteName = "test";
171-
String jsonRequest = "{\"name\":\"" + noteName + "\", \"paragraphs\": [" +
171+
String jsonRequest = "{\"notePath\":\"" + noteName + "\", \"paragraphs\": [" +
172172
"{\"title\": \"title1\", \"text\": \"text1\"}," +
173173
"{\"title\": \"title2\", \"text\": \"text2\"}," +
174174
"{\"title\": \"titleConfig\", \"text\": \"text3\", " +
@@ -221,7 +221,7 @@ void testNoteCreateWithParagraphs() throws IOException {
221221

222222
private void testNoteCreate(String noteName) throws IOException {
223223
// Call Create Note REST API
224-
String jsonRequest = "{\"name\":\"" + noteName + "\"}";
224+
String jsonRequest = "{\"notePath\":\"" + noteName + "\"}";
225225
CloseableHttpResponse post = httpPost("/notebook/", jsonRequest);
226226
String postResponse = EntityUtils.toString(post.getEntity(), StandardCharsets.UTF_8);
227227
LOGGER.info("testNoteCreate \n" + postResponse);
@@ -426,7 +426,7 @@ void testCloneNote() throws IOException, IllegalArgumentException {
426426

427427
String noteName = "clone Note Name";
428428
// Call Clone Note REST API
429-
String jsonRequest = "{\"name\":\"" + noteName + "\"}";
429+
String jsonRequest = "{\"notePath\":\"" + noteName + "\"}";
430430
CloseableHttpResponse post = httpPost("/notebook/" + noteId, jsonRequest);
431431
String postResponse = EntityUtils.toString(post.getEntity(), StandardCharsets.UTF_8);
432432
LOGGER.info("testNoteClone \n" + postResponse);

0 commit comments

Comments
 (0)