### Question:
BerlinGroupLinksRewriter implements LinksRewriter { protected Optional<String> retrievePaymentProduct(String link) { String[] linkPaths = getLinkPathsAsArray(link); if (linkPaths.length < 2) { return Optional.empty(); } return Optional.of(linkPaths[1]); } BerlinGroupLinksRewriter(LinksTemplate linksTemplate,
                                    String host,
                                    String version); void registerPlaceholder(String placeholder,
                                    Function<String, Optional<String>> paramRetriever); @Override Map<String, HrefType> rewrite(Map<String, HrefType> links);  }### Answer:
@Test void retrievePaymentProduct_success_existsInLink() { String link = String.format( "https: PAYMENT_SERVICE, PAYMENT_PRODUCT ); Optional<String> actualPaymentProductOptional = berlinGroupLinksRewriter.retrievePaymentProduct(link); assertThat(actualPaymentProductOptional).contains(PAYMENT_PRODUCT); }
@Test void retrievePaymentProduct_failure_notExistsInLink() { String link = "https: Optional<String> actualPaymentProductOptional = berlinGroupLinksRewriter.retrievePaymentProduct(link); assertThat(actualPaymentProductOptional).isNotPresent(); }