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