Details
-
Type: Bug
-
Status: Open (View Workflow)
-
Priority: Critical
-
Resolution: Unresolved
-
Affects Version/s: 1.6.1
-
Fix Version/s: None
-
Component/s: o.c.jsword.passage
-
Labels:None
-
Environment:
All
Description
It could be that TreeKey comparison should also compare parents because some books like Pilgrim's Progress can have keys with identical names but different parents.
Here is a junit
Book book = getBook("Pilgrim");
// flatten and cache all the keys
List<Key> cachedKeyList = new ArrayList<Key>();
for (Key key : book.getGlobalKeyList())
// get Part II/First Stage key
Key partIIFirstStage = cachedKeyList.get(20);
assertEquals("wrong key", "THE FIRST STAGE", partIIFirstStage.getName()); // these 2 tests pass fine
assertEquals("wrong key", "PART II", partIIFirstStage.getParent().getName()); // they just clarify which key we have
// now try to find the above key in our cached list of keys but the wrong key is returned
int indexOfKey = cachedKeyList.indexOf(partIIFirstStage);
// this test fails because Part I/First Stage is returned instead of Part II/First Stage
assertEquals("Wrong index", 20, indexOfKey);