JSwordPassageServiceImpl implements JSwordPassageService { @Override public KeyWrapper getSiblingChapter(final String reference, final String version, final boolean previousChapter) { final Book currentBook = this.versificationService.getBookFromVersion(version); final Versification v11n = this.versificationService.getVersificationForVersion(currentBook); try { final Key key = currentBook.getKey(reference); return getSiblingChapter(previousChapter, currentBook, v11n, key); } catch (final NoSuchKeyException e) { throw new TranslatedException(e, "invalid_reference_in_book", reference, version); } } @Inject  JSwordPassageServiceImpl(final JSwordVersificationService versificationService,
                                    final MorphologyServiceImpl morphologyProvider, final VocabularyService vocabProvider,
                                    final ColorCoderProviderImpl colorCoder, final VersionResolver resolver,
                                    final PassageOptionsValidationService optionsValidationService); @Override KeyWrapper getSiblingChapter(final String reference, final String version,
                                        final boolean previousChapter); @Override KeyWrapper getKeyInfo(final String reference, final String sourceVersion, String version); @Override KeyWrapper expandToChapter(final String version, final String reference); @Override String getPlainText(final String version, final String reference, final boolean firstVerse); @Override Key getFirstVerseExcludingZero(final Key key, final Book b); @Override Key getFirstVersesFromRange(final Key range, final int context); @Override OsisWrapper peakOsisText(final Book bible, final Key key, final List<LookupOption> options); @Override OsisWrapper peakOsisText(String[] versions, Key lookupKey, List<LookupOption> options, String interlinearMode); OsisWrapper getPassageByDisplayMode(List<String> versionsInput, Key reference, List<LookupOption> options, final String interlinearMode); @Override OsisWrapper getOsisText(final String version, final String reference); @Override OsisWrapper getOsisTextByVerseNumbers(final String version, final String numberedVersion,
                                                 final int startVerseId, final int endVerseId, final List<LookupOption> lookupOptions,
                                                 final String interlinearVersion, final Boolean roundReference, final boolean ignoreVerse0); @Override OsisWrapper getOsisText(final String version, final String reference,
                                   final List<LookupOption> options, final String interlinearVersion,
                                   final InterlinearMode displayMode); @Override OsisWrapper getInterleavedVersions(final String[] versions, final String reference,
                                              final List<LookupOption> options, final InterlinearMode displayMode); @Override String getAllReferences(final String references, final String version); @Override StringAndCount getAllReferencesAndCounts(final String references, final String version);  }
@Test public void testGetSiblingChapter() { org.crosswire.jsword.versification.BookName.setFullBookName(false); assertEquals("Gen 1", this.jsi.getSiblingChapter("Genesis 2", "ESV_th", true).getName()); assertEquals("Gen 1", this.jsi.getSiblingChapter("Genesis 2:5", "ESV_th", true).getName()); assertEquals("Gen 1", this.jsi.getSiblingChapter("Genesis 2-3:17", "ESV_th", true).getName()); assertEquals("Gen 1", this.jsi.getSiblingChapter("Genesis 2:3-3:17", "ESV_th", true).getName()); assertEquals("Gen 4", this.jsi.getSiblingChapter("Genesis 2-3:17", "ESV_th", false).getName()); assertEquals("Gen 4", this.jsi.getSiblingChapter("Genesis 2-3:24", "ESV_th", false).getName()); assertEquals("Gen 4", this.jsi.getSiblingChapter("Genesis 3:17", "ESV_th", false).getName()); assertEquals("Gen 4", this.jsi.getSiblingChapter("Genesis 3:24", "ESV_th", false).getName()); assertEquals("Gen 3", this.jsi.getSiblingChapter("Genesis 2", "ESV_th", false).getName()); assertEquals("Mal 4", this.jsi.getSiblingChapter("Mat 1", "ESV_th", true).getName()); assertEquals("Mat 1", this.jsi.getSiblingChapter("Mal 4", "ESV_th", false).getName()); assertEquals("Mar 16", this.jsi.getSiblingChapter("Luke 1", "ESV_th", true).getName()); assertEquals("Luk 1", this.jsi.getSiblingChapter("Mark 16", "ESV_th", false).getName()); assertEquals("Gen 1", this.jsi.getSiblingChapter("Genesis 1:2", "ESV_th", true).getName()); assertEquals("Rev 22", this.jsi.getSiblingChapter("Revelation 22:5", "ESV_th", false).getName()); }