Search in sources :

Example 1 with BibleController

use of com.tyndalehouse.step.rest.controllers.BibleController in project step by STEPBible.

the class FrontControllerTest method testInvokeMethod.

/**
 * We check that invoke method calls the correct controller and method with the right arguments
 */
@Test
public void testInvokeMethod() throws Exception {
    final StepRequest sr = new StepRequest("blah", "bible", "getAllFeatures", new String[] {});
    final BibleController testController = mock(BibleController.class);
    final FrontController fc = spy(this.fcUnderTest);
    doReturn(testController).when(fc).getController("bible", false);
    // do test
    fc.invokeMethodWithStepRequest(sr);
    // verify
    verify(testController).getAllFeatures();
}
Also used : BibleController(com.tyndalehouse.step.rest.controllers.BibleController) Test(org.junit.Test)

Example 2 with BibleController

use of com.tyndalehouse.step.rest.controllers.BibleController in project step by STEPBible.

the class FrontControllerTest method testGetController.

/**
 * tests the get controller method
 */
@Test
public void testGetController() {
    final String controllerName = "Bible";
    final BibleController mockController = mock(BibleController.class);
    when(this.guiceInjector.getInstance(BibleController.class)).thenReturn(mockController);
    // when
    final Object controller = this.fcUnderTest.getController(controllerName, false);
    // then
    assertEquals(controller.getClass(), mockController.getClass());
}
Also used : BibleController(com.tyndalehouse.step.rest.controllers.BibleController) Test(org.junit.Test)

Example 3 with BibleController

use of com.tyndalehouse.step.rest.controllers.BibleController in project step by STEPBible.

the class FrontControllerTest method testGetControllerMethod.

/**
 * tests that resolving method works
 *
 * @throws IllegalAccessException    uncaught exception
 * @throws InvocationTargetException uncaught exception
 */
@Test
public void testGetControllerMethod() throws IllegalAccessException, InvocationTargetException {
    final BibleInformationService bibleInfo = mock(BibleInformationService.class);
    final BibleController controllerInstance = new BibleController(bibleInfo, this.clientSessionProvider, null);
    // when
    final Method controllerMethod = this.fcUnderTest.getControllerMethod("getAllFeatures", controllerInstance, null, null);
    // then
    controllerMethod.invoke(controllerInstance);
    verify(bibleInfo).getAllFeatures();
}
Also used : BibleInformationService(com.tyndalehouse.step.core.service.BibleInformationService) Method(java.lang.reflect.Method) BibleController(com.tyndalehouse.step.rest.controllers.BibleController) Test(org.junit.Test)

Aggregations

BibleController (com.tyndalehouse.step.rest.controllers.BibleController)3 Test (org.junit.Test)3 BibleInformationService (com.tyndalehouse.step.core.service.BibleInformationService)1 Method (java.lang.reflect.Method)1