BucketedGreekResultCollection implements Iterable<Pair<Greek, double[][]>> { public void put(final Greek greek, final double[][] result) { ArgumentChecker.notNull(greek, "greek"); if (result != null) { ArgumentChecker.isTrue(result.length == _nExpiries, "Wrong number of expiry buckets; have {}, need {}", result.length, _nExpiries); for (int i = 0; i < result.length; i++) { ArgumentChecker.isTrue(result[i].length == _strikes[i].length, "Wrong number of strike buckets; have {}, need {}", result[i].length, _strikes[i].length); } } _dataMap.put(greek, result); } BucketedGreekResultCollection(final double[] expiries, final double[][] strikes); double[][] getBucketedGreeks(final Greek greek); void put(final Greek greek, final double[][] result); boolean isEmpty(); boolean contains(final Greek greek); int size(); Set<Greek> keySet(); Collection<double[][]> values(); double[][] getStrikes(); double[] getExpiries(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override Iterator<Pair<Greek, double[][]>> iterator(); static final Greek BUCKETED_VEGA; }
@Test(expectedExceptions = IllegalArgumentException.class) public void testPutNullGreek() { RESULTS.put(null, VEGA); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testWrongStrikeNumber1() { final double[][] result = new double[][] { new double[] {0.1, 0.2, 0.3}, }; RESULTS.put(BucketedGreekResultCollection.BUCKETED_VEGA, result); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testWrongStrikeNumber2() { final double[][] result = new double[][] { new double[] {0.1, 0.2, 0.3}, new double[] {10.1, 10.2, 10.3}, new double[] {20.1, 20.2, 20.3}, new double[] {30.1, 30.2, 30.3} }; RESULTS.put(BucketedGreekResultCollection.BUCKETED_VEGA, result); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testWrongExpiryNumber() { final double[][] result = new double[][] { new double[] {0.1, 0.2, 0.3, 0.4}, new double[] {10.1, 10.2, 10.3, 10.4}, new double[] {20.1, 20.2, 20.3, 20.4}, new double[] {30.1, 30.2, 30.3, 30.4} }; RESULTS.put(BucketedGreekResultCollection.BUCKETED_VEGA, result); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNonRectangular() { final double[][] result = new double[][] { new double[] {0.1, 0.2, 0.3}, new double[] {10.1, 10.2}, new double[] {20.1, 20.2, 20.3}, new double[] {30.1, 30.2, 30.3} }; RESULTS.put(BucketedGreekResultCollection.BUCKETED_VEGA, result); }