DefaultWorldpayDDCFacade implements WorldpayDDCFacade { @Override public String getEventOriginDomainForDDC() { return Optional.ofNullable(worldpayMerchantConfigDataFacade.getCurrentSiteMerchantConfigData()) .map(WorldpayMerchantConfigData::getThreeDSFlexJsonWebTokenSettings) .map(ThreeDSFlexJsonWebTokenCredentials::getEventOriginDomain) .orElse(null); } DefaultWorldpayDDCFacade(final WorldpayJsonWebTokenService worldpayJsonWebTokenService, final WorldpayMerchantConfigDataFacade worldpayMerchantConfigDataFacade); @Override String createJsonWebTokenForDDC(); @Override String getEventOriginDomainForDDC();  }
@Test public void getOriginEventDomain() { when(worldpayMerchantConfigDataFacadeMock.getCurrentSiteMerchantConfigData()).thenReturn(merchantConfigDataMock); when(merchantConfigDataMock.getThreeDSFlexJsonWebTokenSettings()).thenReturn(threeDSJsonWebTokenCredentialsMock); when(threeDSJsonWebTokenCredentialsMock.getEventOriginDomain()).thenReturn(EVENT_ORIGIN_DOMAIN); final String result = testObj.getEventOriginDomainForDDC(); assertThat(result).isEqualTo(EVENT_ORIGIN_DOMAIN); }