Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,13 @@ public Note getUserNote(String user) {
Note newNote = new Note();
newNote.name = getName();
newNote.id = getId();
newNote.path = path;
newNote.defaultInterpreterGroup = defaultInterpreterGroup;
newNote.version = version;
newNote.setConfig(getConfig());
newNote.info = getInfo();
newNote.noteParams = getNoteParams();
newNote.noteForms = getNoteForms();
newNote.angularObjects = getAngularObjects();
newNote.setZeppelinConfiguration(zConf);
newNote.setNoteParser(noteParser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.mockito.ArgumentCaptor;

import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -221,4 +223,44 @@ public void testNoteJson() throws IOException {
Note note2 = noteParser.fromJson(null, note.toJson());
assertEquals(note2, note);
}

@Test
void userNoteKeepsThePath() {
Note note = personalizedNote();

assertEquals("/folder/my note", note.getUserNote("user1").getPath());
}

@Test
void userNoteKeepsEveryPersistedField() throws IllegalAccessException {
Note note = personalizedNote();

Note userNote = note.getUserNote("user1");

for (Field field : Note.class.getDeclaredFields()) {
int modifiers = field.getModifiers();
if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) {
continue;
}
// The one field a user note is meant to differ in.
if ("paragraphs".equals(field.getName())) {
continue;
}
field.setAccessible(true);
assertEquals(field.get(note), field.get(userNote),
"getUserNote dropped Note." + field.getName());
}
}

private Note personalizedNote() {
Note note = new Note("/folder/my note", "spark", interpreterFactory, interpreterSettingManager,
paragraphJobListener, credentials, noteEventListener, zConf, noteParser);
note.setPersonalizedMode(true);
note.getConfig().put("config_1", "value_1");
note.getInfo().put("info_1", "value_1");
note.getNoteParams().put("param_1", "value_1");
note.getNoteForms().put("form_1", new TextBox("name", "default_name"));
note.addNewParagraph(AuthenticationInfo.ANONYMOUS);
return note;
}
}
Loading