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