@Test(dataProvider = "factoryNull", expectedExceptions = IllegalArgumentException.class) public void test_of_null(Object first, Object second, Object third) { Triple.of(first, second, third); }
@Test(expectedExceptions = ClassCastException.class) public void test_compareTo_notComparable() { Runnable notComparable = () -> {}; Triple<Integer, Runnable, String> test1 = Triple.of(1, notComparable, "A"); Triple<Integer, Runnable, String> test2 = Triple.of(2, notComparable, "B"); test1.compareTo(test2); }
private Triple<Boolean, Integer, Double> checkFixedCompounded(ResolvedSwapLeg leg) { if (leg.getPaymentEvents().size() != 0) { return Triple.of(false, 0, 0.0d); // No event return Triple.of(false, 0, 0.0d); // Should be compounded for (int i = 0; i < nbAccrualPeriods; i++) { if (!(accrualPeriods.get(i).getRateComputation() instanceof FixedRateComputation)) { return Triple.of(false, 0, 0.0d); // Should be fixed period return Triple.of(false, 0, 0.0d); // All fixed rates should be the same return Triple.of(false, 0, 0.0d); // Should have no spread return Triple.of(false, 0, 0.0d); // Should have a gearing of 1. return Triple.of(false, 0, 0.0d); // Should have a year fraction of 1. return Triple.of(true, nbAccrualPeriods, fixedRate);
public void coverage() { Triple<String, String, String> test = Triple.of("A", "B", "C"); TestHelper.coverImmutableBean(test); }
@Test(dataProvider = "factory") public void test_toString(Object first, Object second, Object third) { Triple<Object, Object, Object> test = Triple.of(first, second, third); String str = "[" + first + ", " + second + ", " + third + "]"; assertEquals(test.toString(), str); }
public void test_toString() { Triple<String, String, String> test = Triple.of("A", "B", "C"); assertEquals("[A, B, C]", test.toString()); }
@Test(dataProvider = "factory") public void test_sizeElements(Object first, Object second, Object third) { Triple<Object, Object, Object> test = Triple.of(first, second, third); assertEquals(test.size(), 3); assertEquals(test.elements(), ImmutableList.of(first, second, third)); }
@Test(dataProvider = "factory") public void test_of_getters(Object first, Object second, Object third) { Triple<Object, Object, Object> test = Triple.of(first, second, third); assertEquals(test.getFirst(), first); assertEquals(test.getSecond(), second); }
public void test_equals_bad() { Triple<Integer, String, String> a = Triple.of(1, "Hello", "Triple"); assertEquals(a.equals(null), false); assertEquals(a.equals(ANOTHER_TYPE), false); }
public void test_hashCode() { Triple<Integer, String, String> a = Triple.of(1, "Hello", "Triple"); assertEquals(a.hashCode(), a.hashCode()); }
private Triple<DoubleArray, DoubleArray, DoubleArray> createCapletNodes( InterpolatedNodalSurface capVolSurface, DoubleArray capletExpiries, DoubleArray strikes) { List<Double> timeCapletList = new ArrayList<>(); List<Double> strikeCapletList = new ArrayList<>(); List<Double> volCapletList = new ArrayList<>(); int nTimes = capletExpiries.size(); int nStrikes = strikes.size(); for (int i = 0; i < nTimes; ++i) { double expiry = capletExpiries.get(i); timeCapletList.addAll(DoubleArray.filled(nStrikes, expiry).toList()); strikeCapletList.addAll(strikes.toList()); volCapletList.addAll(DoubleArray.of(nStrikes, n -> capVolSurface.zValue(expiry, strikes.get(n))).toList()); // initial guess } return Triple.of(DoubleArray.copyOf(timeCapletList), DoubleArray.copyOf(strikeCapletList), DoubleArray.copyOf(volCapletList)); }
private Triple<DoubleArray, DoubleArray, DoubleArray> createCapletNodes( InterpolatedNodalSurface capVolSurface, DoubleArray capletExpiries, DoubleArray strikes, Curve shiftCurve) { List<Double> timeCapletList = new ArrayList<>(); List<Double> strikeCapletList = new ArrayList<>(); List<Double> volCapletList = new ArrayList<>(); int nTimes = capletExpiries.size(); int nStrikes = strikes.size(); for (int i = 0; i < nTimes; ++i) { double expiry = capletExpiries.get(i); double shift = shiftCurve.yValue(expiry); timeCapletList.addAll(DoubleArray.filled(nStrikes, expiry).toList()); strikeCapletList.addAll(strikes.plus(shift).toList()); volCapletList.addAll(DoubleArray.of(nStrikes, n -> capVolSurface.zValue(expiry, strikes.get(n) + shift)).toList()); // initial guess } return Triple.of(DoubleArray.copyOf(timeCapletList), DoubleArray.copyOf(strikeCapletList), DoubleArray.copyOf(volCapletList)); }
public void test_compareTo() { Triple<String, String, String> abc = Triple.of("A", "B", "C"); Triple<String, String, String> adc = Triple.of("A", "D", "C"); Triple<String, String, String> bac = Triple.of("B", "A", "C"); Triple<String, String, String> bad = Triple.of("B", "A", "D"); assertTrue(abc.compareTo(abc) == 0); assertTrue(abc.compareTo(adc) < 0); assertTrue(abc.compareTo(bac) < 0); assertTrue(adc.compareTo(abc) > 0); assertTrue(adc.compareTo(adc) == 0); assertTrue(adc.compareTo(bac) < 0); assertTrue(bac.compareTo(abc) > 0); assertTrue(bac.compareTo(adc) > 0); assertTrue(bac.compareTo(bac) == 0); assertTrue(bad.compareTo(abc) > 0); assertTrue(bad.compareTo(adc) > 0); assertTrue(bad.compareTo(bac) > 0); assertTrue(bad.compareTo(bad) == 0); }
public void test_equals() { Triple<Integer, String, String> a = Triple.of(1, "Hello", "Triple"); Triple<Integer, String, String> a2 = Triple.of(1, "Hello", "Triple"); Triple<Integer, String, String> b = Triple.of(1, "Goodbye", "Triple"); Triple<Integer, String, String> c = Triple.of(2, "Hello", "Triple"); Triple<Integer, String, String> d = Triple.of(2, "Goodbye", "Triple"); Triple<Integer, String, String> e = Triple.of(2, "Goodbye", "Other");
Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> reduceDiscountFactors( ResolvedCds cds, CreditRatesProvider ratesProvider) { Currency currency = cds.getCurrency(); CreditDiscountFactors discountFactors = ratesProvider.discountFactors(currency); ArgChecker.isTrue(discountFactors.isIsdaCompliant(), "discount factors must be IsdaCompliantZeroRateDiscountFactors"); LegalEntitySurvivalProbabilities survivalProbabilities = ratesProvider.survivalProbabilities(cds.getLegalEntityId(), currency); ArgChecker.isTrue(survivalProbabilities.getSurvivalProbabilities().isIsdaCompliant(), "survival probabilities must be IsdaCompliantZeroRateDiscountFactors"); ArgChecker.isTrue(discountFactors.getDayCount().equals(survivalProbabilities.getSurvivalProbabilities().getDayCount()), "day count conventions of discounting curve and credit curve must be the same"); double indexFactor = ((IsdaCreditDiscountFactors) survivalProbabilities.getSurvivalProbabilities()) .getCurve().getMetadata().getInfo(CurveInfoType.CDS_INDEX_FACTOR); return Triple.of(discountFactors, survivalProbabilities, indexFactor); }