OcrResponseParser { @Nullable public String getTotalAmount() { if (ocrResponse != null && ocrResponse.getTotalAmount() != null && ocrResponse.getTotalAmount().getData() != null) { return ModelUtils.getDecimalFormattedValue(BigDecimal.valueOf(ocrResponse.getTotalAmount().getData())); } else { return null; } } OcrResponseParser(@Nullable OcrResponse ocrResponse); @Nullable String getMerchant(); @Nullable String getTotalAmount(); @Nullable String getTaxAmount(); @Nullable Date getDate();  }
@Test public void getTotalAmount() { assertNull(new OcrResponseParser(null).getTotalAmount()); assertNull(new OcrResponseParser(new OcrResponse(null, null, null, null, null, null, null, null)).getTotalAmount()); assertNull(new OcrResponseParser(new OcrResponse(new OcrResponseField<>(null, null), null, null, null, null, null, null, null)).getTotalAmount()); assertEquals("23.30", new OcrResponseParser(new OcrResponse(new OcrResponseField<>(23.3, null), null, null, null, null, null, null, null)).getTotalAmount()); }