PaymentTransactionEntryAmountRenderer implements WidgetComponentRenderer<Listcell, ListColumn, Object> { public void render(final Listcell listCell, final ListColumn columnConfiguration, final Object object, final DataType dataType, final WidgetInstanceManager widgetInstanceManager) { final String qualifier = columnConfiguration.getQualifier(); try { final DataType paymentTransactionEntryDataType = typeFacade.load(PaymentTransactionEntryModel._TYPECODE); if (paymentTransactionEntryDataType != null && permissionFacade.canReadProperty(paymentTransactionEntryDataType.getCode(), qualifier)) { final Object amount = propertyValueService.readValue(object, qualifier); if (amount == null) { listCell.setLabel(EMPTY); } else { listCell.setLabel(getPaymentTransactionEntryAmountValue((PaymentTransactionEntryModel) object, amount)); } } } catch (final TypeNotFoundException e) { LOG.error("Could not render row......", e); } }  void render(final Listcell listCell, final ListColumn columnConfiguration, final Object object, final DataType dataType, final WidgetInstanceManager widgetInstanceManager); @Required void setPropertyValueService(final PropertyValueService propertyValueService); @Required void setLabelService(final LabelService labelService); @Required void setPermissionFacade(final PermissionFacade permissionFacade); @Required void setTypeFacade(final TypeFacade typeFacade);  }
@Test public void shouldSetLabelWithAmountValue() { testObj.render(listCellMock, columnConfigurationMock, transactionEntryMock, dataTypeMock, widgetInstanceManagerMock); verify(listCellMock).setLabel(AMOUNT); }
@Test public void shouldNotSetLabelWhenExceptionThrown() throws Exception { doThrow(new TypeNotFoundException("Something went wrong")).when(typeFacadeMock).load(PAYMENT_TRANSACTION_ENTRY); testObj.render(listCellMock, columnConfigurationMock, transactionEntryMock, dataTypeMock, widgetInstanceManagerMock); verify(listCellMock, never()).setLabel(AMOUNT); }
@Test public void shouldNotSetLabelWhenPropertyIsNotReadable() { when(permissionFacadeMock.canReadProperty(DATA_TYPE_CODE, QUALIFIER)).thenReturn(false); testObj.render(listCellMock, columnConfigurationMock, transactionEntryMock, dataTypeMock, widgetInstanceManagerMock); verify(listCellMock, never()).setLabel(AMOUNT); }
@Test public void shouldSetLabelToAuthorisedAmountIfAmountIsBlank() { when(labelServiceMock.getObjectLabel(any())).thenReturn(""); testObj.render(listCellMock, columnConfigurationMock, transactionEntryMock, dataTypeMock, widgetInstanceManagerMock); verify(listCellMock).setLabel(BigDecimal.TEN.toString()); }
@Test public void shouldSetLabelToEmptyStringIfAuthorisedAmountIsNull() { when(propertyValueServiceMock.readValue(transactionEntryMock, QUALIFIER)).thenReturn(null); testObj.render(listCellMock, columnConfigurationMock, transactionEntryMock, dataTypeMock, widgetInstanceManagerMock); verify(listCellMock).setLabel(""); }