WorldpayNullSafeCellRenderer implements WidgetComponentRenderer<Listcell, ListColumn, Object> { public void render(final Listcell parent, final ListColumn columnConfiguration, final Object object, final DataType dataType, final WidgetInstanceManager widgetInstanceManager) { final String qualifier = columnConfiguration.getQualifier(); Object nestedObject = object; Object targetField = object; try { final List tokenMap = this.getNestedAttributeUtils().splitQualifier(qualifier); int e; for (e = 0; e < tokenMap.size() - 1; ++e) { nestedObject = this.getNestedAttributeUtils().getNestedObject(nestedObject, (String) tokenMap.get(e)); } if (nestedObject != null) { for (e = 0; e < tokenMap.size(); ++e) { targetField = this.getNestedAttributeUtils().getNestedObject(targetField, (String) tokenMap.get(e)); } } if (nestedObject != null && targetField != null && !this.checkIfObjectIsEmptyCollection(targetField)) { this.getDefaultListCellRenderer().render(parent, columnConfiguration, object, dataType, widgetInstanceManager); } else if (LOG.isWarnEnabled()) { LOG.warn("Either Property " + nestedObject + " is null or the field " + qualifier + " is null, skipping render of " + qualifier); } } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | InvalidNestedAttributeException e) { if (LOG.isInfoEnabled()) { LOG.info(e.getMessage(), e); } } }  void render(final Listcell parent, final ListColumn columnConfiguration, final Object object, final DataType dataType, final WidgetInstanceManager widgetInstanceManager); @Required void setDefaultListCellRenderer(final WidgetComponentRenderer<Listcell, ListColumn, Object> defaultListCellRenderer); @Required void setNestedAttributeUtils(final NestedAttributeUtils nestedAttributeUtils);  }
@Test public void shouldNotRenderOnNullAavResponse() { PaymentTransactionEntryModel paymentTransactionEntryModel = new PaymentTransactionEntryModel(); testObj.render(listCellMock, columnConfigurationMock, paymentTransactionEntryModel, dataTypeMock, widgetInstanceManagerMock); verifyZeroInteractions(defaultListCellRenderer); }
@Test public void shouldNotRenderOnNullAavAddressResultCode() { PaymentTransactionEntryModel paymentTransactionEntryModel = new PaymentTransactionEntryModel(); WorldpayAavResponseModel worldpayAavResponseModel = new WorldpayAavResponseModel(); paymentTransactionEntryModel.setAavResponse(worldpayAavResponseModel); testObj.render(listCellMock, columnConfigurationMock, paymentTransactionEntryModel, dataTypeMock, widgetInstanceManagerMock); verifyZeroInteractions(defaultListCellRenderer); }
@Test public void shouldRenderOnNonNullAavAddressResultCode() { PaymentTransactionEntryModel paymentTransactionEntryModel = new PaymentTransactionEntryModel(); WorldpayAavResponseModel worldpayAavResponseModel = new WorldpayAavResponseModel(); worldpayAavResponseModel.setAavAddressResultCode("B"); paymentTransactionEntryModel.setAavResponse(worldpayAavResponseModel); testObj.render(listCellMock, columnConfigurationMock, paymentTransactionEntryModel, dataTypeMock, widgetInstanceManagerMock); verify(defaultListCellRenderer).render(listCellMock, columnConfigurationMock, paymentTransactionEntryModel, dataTypeMock, widgetInstanceManagerMock); }