Skip to content

Commit c89fd0f

Browse files
committed
JsoupSiteParser.extractCurrency(): add unit tests.
Fix #844
1 parent ebe7721 commit c89fd0f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/main/java/ru/mystamps/web/util/extractor/JsoupSiteParser.java

-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ protected String extractPrice(Element body) {
282282
return price;
283283
}
284284

285-
// @todo #695 JsoupSiteParser.extractCurrency(): add unit tests
286285
protected String extractCurrency(Element body) {
287286
if (currencyValue == null) {
288287
return null;

src/test/java/ru/mystamps/web/util/extractor/JsoupSiteParserTest.java

+23
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,29 @@ public void extractPriceShouldReturnTextOfPriceLocator() {
863863
assertThat(msg, price, equalTo(expectedValue));
864864
}
865865

866+
//
867+
// Tests for extractCurrency()
868+
//
869+
870+
@Test
871+
public void extractCurrencyShouldReturnNullWhenCurrencyValueIsNotSet() {
872+
parser.setCurrencyValue(null);
873+
874+
String currency = parser.extractCurrency(null);
875+
876+
assertThat(currency, is(nullValue()));
877+
}
878+
879+
@Test
880+
public void extractCurrencyShouldReturnCurrencyValue() {
881+
String expectedCurrency = Random.currency().toString();
882+
parser.setCurrencyValue(expectedCurrency);
883+
884+
String currency = parser.extractCurrency(null);
885+
886+
assertThat(currency, equalTo(expectedCurrency));
887+
}
888+
866889
private static String describe(JsoupSiteParser parser) {
867890
StringBuilder sb = new StringBuilder();
868891
sb.append("JsoupSiteParser[name=")

0 commit comments

Comments
 (0)