mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Add more tests
This commit is contained in:
parent
7d7fe2c8f2
commit
8d7c07d005
2 changed files with 89 additions and 0 deletions
|
|
@ -18,6 +18,8 @@
|
|||
package org.apache.zeppelin.display;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
|
@ -73,4 +75,40 @@ public class AngularObjectRegistryTest {
|
|||
registry.add("name1", "global1", null, null);
|
||||
assertEquals("global1", registry.get("name1", null, null).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDependOnScope() {
|
||||
AngularObjectRegistry registry = new AngularObjectRegistry("intpId", null);
|
||||
AngularObject ao1 = registry.add("name1", "o1", "noteId1", "paragraphId1");
|
||||
AngularObject ao2 = registry.add("name2", "o2", "noteId1", "paragraphId1");
|
||||
AngularObject ao3 = registry.add("name2", "o3", "noteId1", "paragraphId2");
|
||||
AngularObject ao4 = registry.add("name3", "o4", "noteId1", null);
|
||||
AngularObject ao5 = registry.add("name4", "o5", null, null);
|
||||
|
||||
|
||||
assertNull(registry.get("name3", "noteId1", "paragraphId1"));
|
||||
assertNull(registry.get("name1", "noteId2", null));
|
||||
assertEquals("o1", registry.get("name1", "noteId1", "paragraphId1").get());
|
||||
assertEquals("o2", registry.get("name2", "noteId1", "paragraphId1").get());
|
||||
assertEquals("o3", registry.get("name2", "noteId1", "paragraphId2").get());
|
||||
assertEquals("o4", registry.get("name3", "noteId1", null).get());
|
||||
assertEquals("o5", registry.get("name4", null, null).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllDependOnScope() {
|
||||
AngularObjectRegistry registry = new AngularObjectRegistry("intpId", null);
|
||||
AngularObject ao1 = registry.add("name1", "o", "noteId1", "paragraphId1");
|
||||
AngularObject ao2 = registry.add("name2", "o", "noteId1", "paragraphId1");
|
||||
AngularObject ao3 = registry.add("name2", "o", "noteId1", "paragraphId2");
|
||||
AngularObject ao4 = registry.add("name3", "o", "noteId1", null);
|
||||
AngularObject ao5 = registry.add("name4", "o", null, null);
|
||||
|
||||
assertEquals(2, registry.getAll("noteId1", "paragraphId1").size());
|
||||
assertEquals(1, registry.getAll("noteId1", "paragraphId2").size());
|
||||
assertEquals(1, registry.getAll("noteId1", null).size());
|
||||
assertEquals(1, registry.getAll(null, null).size());
|
||||
assertEquals(5, registry.getAllWithGlobal("noteId1").size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.zeppelin.display;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
|
@ -26,6 +27,56 @@ import org.junit.Test;
|
|||
|
||||
public class AngularObjectTest {
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
assertEquals(
|
||||
new AngularObject("name", "value", "note1", null, null),
|
||||
new AngularObject("name", "value", "note1", null, null)
|
||||
);
|
||||
|
||||
assertEquals(
|
||||
new AngularObject("name", "value", "note1", "paragraph1", null),
|
||||
new AngularObject("name", "value", "note1", "paragraph1", null)
|
||||
);
|
||||
|
||||
assertEquals(
|
||||
new AngularObject("name", "value", null, null, null),
|
||||
new AngularObject("name", "value", null, null, null)
|
||||
);
|
||||
|
||||
assertEquals(
|
||||
new AngularObject("name", "value1", null, null, null),
|
||||
new AngularObject("name", "value2", null, null, null)
|
||||
);
|
||||
|
||||
assertNotSame(
|
||||
new AngularObject("name1", "value", null, null, null),
|
||||
new AngularObject("name2", "value", null, null, null)
|
||||
);
|
||||
|
||||
assertNotSame(
|
||||
new AngularObject("name1", "value", "note1", null, null),
|
||||
new AngularObject("name2", "value", "note2", null, null)
|
||||
);
|
||||
|
||||
assertNotSame(
|
||||
new AngularObject("name1", "value", "note", null, null),
|
||||
new AngularObject("name2", "value", null, null, null)
|
||||
);
|
||||
|
||||
assertNotSame(
|
||||
new AngularObject("name", "value", "note", "paragraph1", null),
|
||||
new AngularObject("name", "value", "note", "paragraph2", null)
|
||||
);
|
||||
|
||||
assertNotSame(
|
||||
new AngularObject("name", "value", "note1", null, null),
|
||||
new AngularObject("name", "value", "note1", "paragraph1", null)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListener() {
|
||||
final AtomicInteger updated = new AtomicInteger(0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue