WorldpayAPMComponentController extends GenericCMSAddOnComponentController { @Override protected void fillModel(final HttpServletRequest request, final Model model, final AbstractCMSComponentModel component) { invokeSuperFillModel(request, model, component); if (component instanceof WorldpayAPMComponentModel) { final WorldpayAPMConfigurationModel apmConfiguration = ((WorldpayAPMComponentModel) component).getApmConfiguration(); model.addAttribute(IS_AVAILABLE, apmAvailabilityFacade.isAvailable(apmConfiguration)); } }    }
@Test public void fillModelShouldNotAddAvailabilityAttributeForWorldpayAPMComponent() { testObj.fillModel(requestMock, modelMock, componentMock); verify(apmAvailabilityFacadeMock, never()).isAvailable(any(WorldpayAPMConfigurationModel.class)); }
@Test public void fillModelShouldAddAvailabilityAttributeForWorldpayAPMComponent() { when(worldpayAPMComponentMock.getApmConfiguration()).thenReturn(apmConfigurationMock); when(apmAvailabilityFacadeMock.isAvailable(apmConfigurationMock)).thenReturn(true); testObj.fillModel(requestMock, modelMock, worldpayAPMComponentMock); verify(modelMock).addAttribute(IS_AVAILABLE, true); verify(apmAvailabilityFacadeMock).isAvailable(apmConfigurationMock); }