Search in sources :

Example 1 with JSwordVersificationService

use of com.tyndalehouse.step.core.service.jsword.JSwordVersificationService in project step by STEPBible.

the class LoaderTest method getLoader.

/**
 * Gets a loader to be tested
 *
 * @param key the key to the properties
 * @param file where the file that should be tested is
 * @return the loader
 */
private Loader getLoader(final String key, final String file) {
    final Properties coreProperties = new Properties();
    coreProperties.put(key, file);
    final JSwordVersificationService versificationService = TestUtils.mockVersificationService();
    return new Loader(new JSwordPassageServiceImpl(versificationService, null, null, null, mock(VersionResolver.class), null), null, coreProperties, this.entityManager, this.clientSessionProvider, mock(AppManagerService.class));
}
Also used : JSwordPassageServiceImpl(com.tyndalehouse.step.core.service.jsword.impl.JSwordPassageServiceImpl) JSwordVersificationService(com.tyndalehouse.step.core.service.jsword.JSwordVersificationService) Properties(java.util.Properties) AppManagerService(com.tyndalehouse.step.core.service.AppManagerService)

Example 2 with JSwordVersificationService

use of com.tyndalehouse.step.core.service.jsword.JSwordVersificationService in project step by STEPBible.

the class JSwordSearchServiceImplTest method setUp.

/**
 * sets up search service
 */
@Before
public void setUp() {
    final JSwordVersificationService mockVersificationService = TestUtils.mockVersificationService();
    final PassageOptionsValidationService mockOptionsService = mock(PassageOptionsValidationService.class);
    when(mockOptionsService.getAvailableFeaturesForVersion(any(String.class), any(List.class), any(String.class), any(InterlinearMode.class))).thenReturn(new AvailableFeatures());
    this.search = new JSwordSearchServiceImpl(mockVersificationService, null, new JSwordPassageServiceImpl(mockVersificationService, null, null, null, TestUtils.mockVersionResolver(), mockOptionsService));
}
Also used : JSwordVersificationService(com.tyndalehouse.step.core.service.jsword.JSwordVersificationService) AvailableFeatures(com.tyndalehouse.step.core.models.AvailableFeatures) List(java.util.List) InterlinearMode(com.tyndalehouse.step.core.models.InterlinearMode) PassageOptionsValidationService(com.tyndalehouse.step.core.service.PassageOptionsValidationService) Before(org.junit.Before)

Example 3 with JSwordVersificationService

use of com.tyndalehouse.step.core.service.jsword.JSwordVersificationService in project step by STEPBible.

the class InterleavingProviderImplTest method testInterleavingCompareWithSameVersion.

/**
 * Tests that the main version obliterates the presence of the same version within the list.
 */
@Test
public void testInterleavingCompareWithSameVersion() {
    final JSwordVersificationService versification = mock(JSwordVersificationService.class);
    when(versification.getBookFromVersion(anyString())).thenAnswer(new Answer<Book>() {

        @Override
        public Book answer(final InvocationOnMock invocation) {
            return Books.installed().getBook((String) invocation.getArguments()[0]);
        }
    });
    final InterleavingProviderImpl interleavingProviderImpl = new InterleavingProviderImpl(versification, new String[] { "KJV", "ESV_th", "KJV", "ESV_th" }, true);
    assertEqualVersions(new String[] { "KJV", "ESV_th", "KJV", "ESV_th" }, interleavingProviderImpl);
}
Also used : JSwordVersificationService(com.tyndalehouse.step.core.service.jsword.JSwordVersificationService) Book(org.crosswire.jsword.book.Book) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with JSwordVersificationService

use of com.tyndalehouse.step.core.service.jsword.JSwordVersificationService in project step by STEPBible.

the class InterleavingProviderImplTest method testInterleavingCompare.

/**
 * check that comparing adds the right set of versions
 */
@Test
public void testInterleavingCompare() {
    final JSwordVersificationService versification = mock(JSwordVersificationService.class);
    when(versification.getBookFromVersion(anyString())).thenAnswer(new Answer<Book>() {

        @Override
        public Book answer(final InvocationOnMock invocation) {
            return Books.installed().getBook((String) invocation.getArguments()[0]);
        }
    });
    final InterleavingProviderImpl interleavingProviderImpl = new InterleavingProviderImpl(versification, new String[] { "KJV", "ESV_th", "NETfree", "Byz", "Tisch", "YLT", "ASV", "Montgomery", "FreCrampon" }, true);
    final String[] expected = new String[] { "KJV", "ESV_th", "KJV", "NETfree", "KJV", "YLT", "KJV", "ASV", "KJV", "Montgomery" };
    assertEqualVersions(expected, interleavingProviderImpl);
}
Also used : JSwordVersificationService(com.tyndalehouse.step.core.service.jsword.JSwordVersificationService) Book(org.crosswire.jsword.book.Book) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 5 with JSwordVersificationService

use of com.tyndalehouse.step.core.service.jsword.JSwordVersificationService in project step by STEPBible.

the class SearchServiceImplTest method getSearchServiceUnderTest.

/**
 * @return the search service to test
 */
private SearchServiceImpl getSearchServiceUnderTest() {
    final JSwordMetadataService meta = mock(JSwordMetadataService.class);
    final JSwordModuleService module = mock(JSwordModuleService.class);
    final JSwordVersificationService versificationService = TestUtils.mockVersificationService();
    final PassageOptionsValidationService optionsValidationService = mock(PassageOptionsValidationService.class);
    final JSwordPassageServiceImpl jsword = new JSwordPassageServiceImpl(versificationService, null, null, null, TestUtils.mockVersionResolver(), optionsValidationService);
    when(optionsValidationService.getAvailableFeaturesForVersion(any(String.class), any(List.class), any(String.class), any(InterlinearMode.class))).thenReturn(new AvailableFeatures());
    when(module.isInstalled("ESV_th")).thenReturn(true);
    when(module.isIndexed(any(String.class))).thenReturn(true);
    when(meta.supportsFeature(any(String.class), any(LookupOption.class))).thenReturn(true);
    final JSwordSearchServiceImpl jswordSearch = new JSwordSearchServiceImpl(versificationService, null, jsword);
    subjects = new SubjectSearchServiceImpl(entityManager, jswordSearch, meta, module, versificationService);
    return new SearchServiceImpl(jswordSearch, meta, versificationService, subjects, new TimelineServiceImpl(entityManager, jsword), null, entityManager, TestUtils.mockVersionResolver(), mock(LexiconDefinitionServiceImpl.class), null, null);
}
Also used : JSwordPassageServiceImpl(com.tyndalehouse.step.core.service.jsword.impl.JSwordPassageServiceImpl) LexiconDefinitionServiceImpl(com.tyndalehouse.step.core.service.impl.LexiconDefinitionServiceImpl) LookupOption(com.tyndalehouse.step.core.models.LookupOption) JSwordVersificationService(com.tyndalehouse.step.core.service.jsword.JSwordVersificationService) TimelineServiceImpl(com.tyndalehouse.step.core.service.impl.TimelineServiceImpl) PassageOptionsValidationService(com.tyndalehouse.step.core.service.PassageOptionsValidationService) JSwordModuleService(com.tyndalehouse.step.core.service.jsword.JSwordModuleService) JSwordMetadataService(com.tyndalehouse.step.core.service.jsword.JSwordMetadataService) AvailableFeatures(com.tyndalehouse.step.core.models.AvailableFeatures) List(java.util.List) InterlinearMode(com.tyndalehouse.step.core.models.InterlinearMode) JSwordSearchServiceImpl(com.tyndalehouse.step.core.service.jsword.impl.JSwordSearchServiceImpl) JSwordSearchServiceImpl(com.tyndalehouse.step.core.service.jsword.impl.JSwordSearchServiceImpl)

Aggregations

JSwordVersificationService (com.tyndalehouse.step.core.service.jsword.JSwordVersificationService)6 AvailableFeatures (com.tyndalehouse.step.core.models.AvailableFeatures)2 InterlinearMode (com.tyndalehouse.step.core.models.InterlinearMode)2 PassageOptionsValidationService (com.tyndalehouse.step.core.service.PassageOptionsValidationService)2 JSwordPassageServiceImpl (com.tyndalehouse.step.core.service.jsword.impl.JSwordPassageServiceImpl)2 List (java.util.List)2 Book (org.crosswire.jsword.book.Book)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 LookupOption (com.tyndalehouse.step.core.models.LookupOption)1 AppManagerService (com.tyndalehouse.step.core.service.AppManagerService)1 VersionResolver (com.tyndalehouse.step.core.service.helpers.VersionResolver)1 LexiconDefinitionServiceImpl (com.tyndalehouse.step.core.service.impl.LexiconDefinitionServiceImpl)1 TimelineServiceImpl (com.tyndalehouse.step.core.service.impl.TimelineServiceImpl)1 JSwordMetadataService (com.tyndalehouse.step.core.service.jsword.JSwordMetadataService)1 JSwordModuleService (com.tyndalehouse.step.core.service.jsword.JSwordModuleService)1 JSwordSearchServiceImpl (com.tyndalehouse.step.core.service.jsword.impl.JSwordSearchServiceImpl)1 JSwordVersificationServiceImpl (com.tyndalehouse.step.core.service.jsword.impl.JSwordVersificationServiceImpl)1 Properties (java.util.Properties)1