Merge pull request #7386 from thecockatiel/fix_misc

fix: some issues in EditOfferOptionParser
This commit is contained in:
Alejandro García 2025-02-10 00:45:22 +00:00 committed by GitHub
commit 631d0f9222
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 7 deletions

View file

@ -123,11 +123,9 @@ public class EditOfferOptionParser extends OfferIdOptionParser implements Method
if (options.has(mktPriceMarginPctOpt)) { if (options.has(mktPriceMarginPctOpt)) {
if (valueNotSpecified.test(mktPriceMarginPctOpt)) if (valueNotSpecified.test(mktPriceMarginPctOpt))
throw new IllegalArgumentException("no mkt price margin specified"); throw new IllegalArgumentException("no market price margin specified");
String priceMarginPctAsString = options.valueOf(mktPriceMarginPctOpt); String priceMarginPctAsString = options.valueOf(mktPriceMarginPctOpt);
if (priceMarginPctAsString.isEmpty())
throw new IllegalArgumentException("no market price margin specified");
verifyStringIsValidDouble(priceMarginPctAsString); verifyStringIsValidDouble(priceMarginPctAsString);
@ -140,6 +138,7 @@ public class EditOfferOptionParser extends OfferIdOptionParser implements Method
} }
boolean mktPriceMarginOptAndEnableOptAreOnlyOpts = options.has(enableOpt) boolean mktPriceMarginOptAndEnableOptAreOnlyOpts = options.has(enableOpt)
&& !options.has(fixedPriceOpt)
&& !options.has(triggerPriceOpt); && !options.has(triggerPriceOpt);
if (mktPriceMarginOptAndEnableOptAreOnlyOpts) { if (mktPriceMarginOptAndEnableOptAreOnlyOpts) {
offerEditType = MKT_PRICE_MARGIN_AND_ACTIVATION_STATE; offerEditType = MKT_PRICE_MARGIN_AND_ACTIVATION_STATE;
@ -151,9 +150,7 @@ public class EditOfferOptionParser extends OfferIdOptionParser implements Method
if (valueNotSpecified.test(triggerPriceOpt)) if (valueNotSpecified.test(triggerPriceOpt))
throw new IllegalArgumentException("no trigger price specified"); throw new IllegalArgumentException("no trigger price specified");
String triggerPriceAsString = options.valueOf(fixedPriceOpt); String triggerPriceAsString = options.valueOf(triggerPriceOpt);
if (triggerPriceAsString.isEmpty())
throw new IllegalArgumentException("trigger price not specified");
verifyStringIsValidDouble(triggerPriceAsString); verifyStringIsValidDouble(triggerPriceAsString);

View file

@ -217,7 +217,7 @@ public class EditOfferOptionParserTest {
}; };
Throwable exception = assertThrows(RuntimeException.class, () -> Throwable exception = assertThrows(RuntimeException.class, () ->
new EditOfferOptionParser(args).parse()); new EditOfferOptionParser(args).parse());
assertEquals("no mkt price margin specified", assertEquals("no market price margin specified",
exception.getMessage()); exception.getMessage());
} }