File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
main/java/ru/mystamps/web/feature/series/importing/extractor Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,10 @@ protected String extractPrice(Element body) {
216
216
}
217
217
218
218
String price = elem .ownText ();
219
+ if (StringUtils .isBlank (price )) {
220
+ price = elem .text ();
221
+ }
222
+
219
223
LOG .debug ("Extracted price: '{}'" , price );
220
224
return price ;
221
225
}
Original file line number Diff line number Diff line change @@ -648,6 +648,24 @@ public void extractPriceShouldIgnoreTextOfChildrenTags() {
648
648
.isEqualTo (expectedValue );
649
649
}
650
650
651
+ @ Test
652
+ public void extractPriceShouldFallbackToTextOfChildrenTags () {
653
+ parser .setPriceLocator ("#price" );
654
+
655
+ String expectedPrice = String .valueOf (Random .price ());
656
+ String expectedValue = "price:" + expectedPrice ;
657
+ String html = String .format (
658
+ "<span id='price'><b>price:</b><b>%s</b></span>" ,
659
+ expectedPrice
660
+ );
661
+ Element doc = createDocumentFromText (html );
662
+
663
+ String price = parser .extractPrice (doc );
664
+
665
+ assertThat (price ).as ("couldn't extract price from '%s'" , doc )
666
+ .isEqualTo (expectedValue );
667
+ }
668
+
651
669
//
652
670
// Tests for extractCurrency()
653
671
//
You can’t perform that action at this time.
0 commit comments