public void test_getCode() { assertEquals(EtdSettlementType.CASH.getCode(), "C"); assertEquals(EtdSettlementType.PHYSICAL.getCode(), "E"); assertEquals(EtdSettlementType.DERIVATIVE.getCode(), "D"); assertEquals(EtdSettlementType.NOTIONAL.getCode(), "N"); assertEquals(EtdSettlementType.PAYMENT_VS_PAYMENT.getCode(), "P"); assertEquals(EtdSettlementType.STOCK.getCode(), "S"); assertEquals(EtdSettlementType.CASCADE.getCode(), "T"); assertEquals(EtdSettlementType.ALTERNATE.getCode(), "A"); }
/** * Parses the ETD settlement type from the short code or full name. * * @param str the string to parse * @return the settlement type * @throws IllegalArgumentException if the string cannot be parsed */ public static EtdSettlementType parseEtdSettlementType(String str) { String upper = str.toUpperCase(Locale.ENGLISH); EtdSettlementType fromCode = SETTLEMENT_BY_CODE.get(upper); return fromCode != null ? fromCode : EtdSettlementType.of(str); }
@Test(dataProvider = "name") public void test_toString(EtdSettlementType convention, String name) { assertEquals(convention.toString(), name); }
@Test(dataProvider = "name") public void test_of_lookup(EtdSettlementType convention, String name) { assertEquals(EtdSettlementType.of(name), convention); }
"Flex Option must have both settlementType and optionType"); String dateCodeStr = dateCode < 10 ? "0" + dateCode : Integer.toString(dateCode); String settlementCode = settlementType != null ? settlementType.getCode() : ""; String optionCode = optionType != null ? optionType.getCode() : ""; this.code = dateCodeStr + settlementCode + optionCode;
public void test_of_lookup_notFound() { assertThrows(() -> EtdSettlementType.of("Rubbish"), IllegalArgumentException.class); }
public void test_of_lookup_null() { assertThrows(() -> EtdSettlementType.of(null), IllegalArgumentException.class); }