/projects/OG-Analytics/tests/unit/com/opengamma/math/surface/InterpolatedFromCurvesDoublesSurfaceTest.java

https://github.com/gsteri1/OG-Platform · Java · 585 lines · 502 code · 75 blank · 8 comment · 1 complexity · 20b21a8bc2ea1f988fe54e5d1c6fd031 MD5 · raw file

  1. /**
  2. * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
  3. *
  4. * Please see distribution for license.
  5. */
  6. package com.opengamma.math.surface;
  7. import static org.testng.AssertJUnit.assertEquals;
  8. import static org.testng.AssertJUnit.assertFalse;
  9. import static org.testng.AssertJUnit.assertTrue;
  10. import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
  11. import java.util.ArrayList;
  12. import java.util.Arrays;
  13. import java.util.Collections;
  14. import java.util.HashMap;
  15. import java.util.List;
  16. import java.util.Map;
  17. import java.util.TreeMap;
  18. import org.testng.annotations.Test;
  19. import com.opengamma.math.curve.ConstantDoublesCurve;
  20. import com.opengamma.math.curve.Curve;
  21. import com.opengamma.math.interpolation.LinearInterpolator1D;
  22. import com.opengamma.math.interpolation.StepInterpolator1D;
  23. import com.opengamma.util.tuple.Pair;
  24. /**
  25. *
  26. */
  27. public class InterpolatedFromCurvesDoublesSurfaceTest {
  28. private static final String NAME = "L";
  29. private static final ConstantDoublesCurve C1 = ConstantDoublesCurve.from(3.);
  30. private static final ConstantDoublesCurve C2 = ConstantDoublesCurve.from(5.);
  31. private static final ConstantDoublesCurve C3 = ConstantDoublesCurve.from(7.);
  32. private static final ConstantDoublesCurve C4 = ConstantDoublesCurve.from(9.);
  33. private static final ConstantDoublesCurve C5 = ConstantDoublesCurve.from(11.);
  34. private static final ConstantDoublesCurve C6 = ConstantDoublesCurve.from(12.);
  35. private static final LinearInterpolator1D INTERPOLATOR = new LinearInterpolator1D();
  36. private static final double[] POINT_PRIMITIVE = new double[] {1, 2, 4, 5, 6, 3};
  37. private static final double[] POINT_PRIMITIVE_SORTED = new double[] {1, 2, 3, 4, 5, 6};
  38. private static final Double[] POINT_OBJECT;
  39. private static final Double[] POINT_OBJECT_SORTED;
  40. @SuppressWarnings("unchecked")
  41. private static final Curve<Double, Double>[] CURVES = new Curve[] {C1, C2, C4, C5, C6, C3};
  42. @SuppressWarnings("unchecked")
  43. private static final Curve<Double, Double>[] CURVES_SORTED = new Curve[] {C1, C2, C3, C4, C5, C6};
  44. private static final List<Double> POINT_LIST;
  45. private static final List<Double> POINT_LIST_SORTED;
  46. private static final List<Curve<Double, Double>> CURVES_LIST;
  47. private static final List<Curve<Double, Double>> CURVES_LIST_SORTED;
  48. private static final Map<Double, Curve<Double, Double>> MAP;
  49. private static final Map<Double, Curve<Double, Double>> MAP_SORTED;
  50. private static final InterpolatedFromCurvesDoublesSurface SURFACE = InterpolatedFromCurvesDoublesSurface.from(true, POINT_PRIMITIVE, CURVES, INTERPOLATOR, NAME);
  51. static {
  52. final int n = 6;
  53. POINT_OBJECT = new Double[n];
  54. POINT_OBJECT_SORTED = new Double[n];
  55. POINT_LIST = new ArrayList<Double>();
  56. POINT_LIST_SORTED = new ArrayList<Double>();
  57. CURVES_LIST = new ArrayList<Curve<Double, Double>>();
  58. CURVES_LIST_SORTED = new ArrayList<Curve<Double, Double>>();
  59. MAP = new HashMap<Double, Curve<Double, Double>>();
  60. MAP_SORTED = new TreeMap<Double, Curve<Double, Double>>();
  61. for (int i = 0; i < n; i++) {
  62. final double x1 = POINT_PRIMITIVE[i];
  63. final double x2 = POINT_PRIMITIVE_SORTED[i];
  64. final Curve<Double, Double> c1 = CURVES[i];
  65. final Curve<Double, Double> c2 = CURVES_SORTED[i];
  66. POINT_OBJECT[i] = x1;
  67. POINT_OBJECT_SORTED[i] = x2;
  68. POINT_LIST.add(x1);
  69. POINT_LIST_SORTED.add(x2);
  70. CURVES_LIST.add(c1);
  71. CURVES_LIST_SORTED.add(c2);
  72. MAP.put(x1, c1);
  73. MAP_SORTED.put(x2, c2);
  74. }
  75. }
  76. @Test
  77. public void testXZCurves() {
  78. assertEquals(SURFACE.getZValue(3.5, 1.), 3., 0);
  79. assertEquals(SURFACE.getZValue(3.5, 1.5), 4., 0);
  80. assertEquals(SURFACE.getZValue(3.5, 2.), 5., 0);
  81. assertEquals(SURFACE.getZValue(3.5, 2.5), 6., 0);
  82. assertEquals(SURFACE.getZValue(3.5, 3.), 7., 0);
  83. assertEquals(SURFACE.getZValue(3.5, 3.5), 8., 0);
  84. assertEquals(SURFACE.getZValue(3.5, 4.), 9., 0);
  85. assertEquals(SURFACE.getZValue(3.5, 4.5), 10., 0);
  86. assertEquals(SURFACE.getZValue(3.5, 5.), 11., 0);
  87. assertEquals(SURFACE.getZValue(3.5, 5.5), 11.5, 0);
  88. assertEquals(SURFACE.getZValue(3.5, 6.), 12., 0);
  89. assertEquals(SURFACE.getZValue(3., 1.), 3., 0);
  90. assertEquals(SURFACE.getZValue(3., 1.5), 4., 0);
  91. assertEquals(SURFACE.getZValue(3., 2.), 5., 0);
  92. assertEquals(SURFACE.getZValue(3., 2.5), 6., 0);
  93. assertEquals(SURFACE.getZValue(3., 3.), 7., 0);
  94. assertEquals(SURFACE.getZValue(3., 3.5), 8., 0);
  95. assertEquals(SURFACE.getZValue(3., 4.), 9., 0);
  96. assertEquals(SURFACE.getZValue(3., 4.5), 10., 0);
  97. assertEquals(SURFACE.getZValue(3., 5.), 11., 0);
  98. assertEquals(SURFACE.getZValue(3., 5.5), 11.5, 0);
  99. assertEquals(SURFACE.getZValue(3., 6.), 12., 0);
  100. }
  101. @Test
  102. public void testYZCurves() {
  103. final InterpolatedFromCurvesDoublesSurface surface = InterpolatedFromCurvesDoublesSurface.fromSorted(false, MAP_SORTED, INTERPOLATOR);
  104. assertEquals(surface.getZValue(1., 3.5), 3., 0);
  105. assertEquals(surface.getZValue(1.5, 3.5), 4., 0);
  106. assertEquals(surface.getZValue(2., 3.5), 5., 0);
  107. assertEquals(surface.getZValue(2.5, 3.5), 6., 0);
  108. assertEquals(surface.getZValue(3., 3.5), 7., 0);
  109. assertEquals(surface.getZValue(3.5, 3.5), 8., 0);
  110. assertEquals(surface.getZValue(4., 3.5), 9., 0);
  111. assertEquals(surface.getZValue(4.5, 3.5), 10., 0);
  112. assertEquals(surface.getZValue(5., 3.5), 11., 0);
  113. assertEquals(surface.getZValue(5.5, 3.5), 11.5, 0);
  114. assertEquals(surface.getZValue(6., 3.5), 12., 0);
  115. assertEquals(surface.getZValue(1., 3.), 3., 0);
  116. assertEquals(surface.getZValue(1.5, 3.), 4., 0);
  117. assertEquals(surface.getZValue(2., 3.), 5., 0);
  118. assertEquals(surface.getZValue(2.5, 3.), 6., 0);
  119. assertEquals(surface.getZValue(3., 3.), 7., 0);
  120. assertEquals(surface.getZValue(3.5, 3.), 8., 0);
  121. assertEquals(surface.getZValue(4., 3.), 9., 0);
  122. assertEquals(surface.getZValue(4.5, 3.), 10., 0);
  123. assertEquals(surface.getZValue(5., 3.), 11., 0);
  124. assertEquals(surface.getZValue(5.5, 3.), 11.5, 0);
  125. assertEquals(surface.getZValue(6., 3.), 12., 0);
  126. }
  127. @Test
  128. public void testGetters() {
  129. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  130. assertEquals(SURFACE.getInterpolator(), INTERPOLATOR);
  131. assertEquals(SURFACE.getName(), NAME);
  132. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  133. assertTrue(SURFACE.isXZCurves());
  134. }
  135. @SuppressWarnings("unchecked")
  136. @Test
  137. public void testHashCodeEqualsAndConstruction() {
  138. InterpolatedFromCurvesDoublesSurface other = InterpolatedFromCurvesDoublesSurface.from(true, POINT_PRIMITIVE, CURVES, INTERPOLATOR, NAME);
  139. assertEquals(SURFACE, other);
  140. assertEquals(SURFACE.hashCode(), other.hashCode());
  141. other = InterpolatedFromCurvesDoublesSurface.from(false, POINT_PRIMITIVE, CURVES, INTERPOLATOR, NAME);
  142. assertFalse(SURFACE.equals(other));
  143. other = InterpolatedFromCurvesDoublesSurface.from(true, new double[] {1, 3, 4, 5, 6, 7}, CURVES, INTERPOLATOR, NAME);
  144. assertFalse(SURFACE.equals(other));
  145. other = InterpolatedFromCurvesDoublesSurface.from(true, POINT_PRIMITIVE, new Curve[] {C1, C2, C3, C4, C5, ConstantDoublesCurve.from(3.)}, INTERPOLATOR, NAME);
  146. assertFalse(SURFACE.equals(other));
  147. other = InterpolatedFromCurvesDoublesSurface.from(true, POINT_PRIMITIVE, CURVES, new StepInterpolator1D(), NAME);
  148. assertFalse(SURFACE.equals(other));
  149. other = InterpolatedFromCurvesDoublesSurface.from(true, POINT_PRIMITIVE, CURVES, INTERPOLATOR, "E");
  150. assertFalse(SURFACE.equals(other));
  151. other = InterpolatedFromCurvesDoublesSurface.fromSorted(true, POINT_PRIMITIVE_SORTED, CURVES_SORTED, INTERPOLATOR, NAME);
  152. assertEquals(SURFACE, other);
  153. other = InterpolatedFromCurvesDoublesSurface.from(true, POINT_OBJECT, CURVES, INTERPOLATOR, NAME);
  154. assertEquals(SURFACE, other);
  155. other = InterpolatedFromCurvesDoublesSurface.fromSorted(true, POINT_OBJECT_SORTED, CURVES_SORTED, INTERPOLATOR, NAME);
  156. assertEquals(SURFACE, other);
  157. other = InterpolatedFromCurvesDoublesSurface.from(true, POINT_LIST, CURVES_LIST, INTERPOLATOR, NAME);
  158. assertEquals(SURFACE, other);
  159. other = InterpolatedFromCurvesDoublesSurface.fromSorted(true, POINT_LIST_SORTED, CURVES_LIST_SORTED, INTERPOLATOR, NAME);
  160. assertEquals(SURFACE, other);
  161. other = InterpolatedFromCurvesDoublesSurface.from(true, MAP, INTERPOLATOR, NAME);
  162. assertEquals(SURFACE, other);
  163. other = InterpolatedFromCurvesDoublesSurface.fromSorted(true, MAP_SORTED, INTERPOLATOR, NAME);
  164. assertEquals(SURFACE, other);
  165. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE, CURVES, INTERPOLATOR, false, NAME);
  166. assertEquals(SURFACE, other);
  167. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE_SORTED, CURVES_SORTED, INTERPOLATOR, true, NAME);
  168. assertEquals(SURFACE, other);
  169. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, CURVES, INTERPOLATOR, false, NAME);
  170. assertEquals(SURFACE, other);
  171. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT_SORTED, CURVES_SORTED, INTERPOLATOR, true, NAME);
  172. assertEquals(SURFACE, other);
  173. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_LIST, CURVES_LIST, INTERPOLATOR, false, NAME);
  174. assertEquals(SURFACE, other);
  175. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_LIST_SORTED, CURVES_LIST_SORTED, INTERPOLATOR, true, NAME);
  176. assertEquals(SURFACE, other);
  177. other = new InterpolatedFromCurvesDoublesSurface(true, MAP, INTERPOLATOR, false, NAME);
  178. assertEquals(SURFACE, other);
  179. other = new InterpolatedFromCurvesDoublesSurface(true, MAP_SORTED, INTERPOLATOR, true, NAME);
  180. assertEquals(SURFACE, other);
  181. other = InterpolatedFromCurvesDoublesSurface.from(true, POINT_PRIMITIVE, CURVES, INTERPOLATOR);
  182. assertFalse(SURFACE.equals(other));
  183. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  184. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  185. other = InterpolatedFromCurvesDoublesSurface.fromSorted(true, POINT_PRIMITIVE_SORTED, CURVES_SORTED, INTERPOLATOR);
  186. assertFalse(SURFACE.equals(other));
  187. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  188. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  189. other = InterpolatedFromCurvesDoublesSurface.from(true, POINT_OBJECT, CURVES, INTERPOLATOR);
  190. assertFalse(SURFACE.equals(other));
  191. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  192. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  193. other = InterpolatedFromCurvesDoublesSurface.fromSorted(true, POINT_OBJECT_SORTED, CURVES_SORTED, INTERPOLATOR);
  194. assertFalse(SURFACE.equals(other));
  195. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  196. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  197. other = InterpolatedFromCurvesDoublesSurface.from(true, POINT_LIST, CURVES_LIST, INTERPOLATOR);
  198. assertFalse(SURFACE.equals(other));
  199. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  200. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  201. other = InterpolatedFromCurvesDoublesSurface.fromSorted(true, POINT_LIST_SORTED, CURVES_LIST_SORTED, INTERPOLATOR);
  202. assertFalse(SURFACE.equals(other));
  203. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  204. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  205. other = InterpolatedFromCurvesDoublesSurface.from(true, MAP, INTERPOLATOR);
  206. assertFalse(SURFACE.equals(other));
  207. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  208. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  209. other = InterpolatedFromCurvesDoublesSurface.fromSorted(true, MAP_SORTED, INTERPOLATOR);
  210. assertFalse(SURFACE.equals(other));
  211. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  212. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  213. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE_SORTED, CURVES_SORTED, INTERPOLATOR, true);
  214. assertFalse(SURFACE.equals(other));
  215. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  216. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  217. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, CURVES, INTERPOLATOR, false);
  218. assertFalse(SURFACE.equals(other));
  219. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  220. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  221. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT_SORTED, CURVES_SORTED, INTERPOLATOR, true);
  222. assertFalse(SURFACE.equals(other));
  223. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  224. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  225. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_LIST, CURVES_LIST, INTERPOLATOR, false);
  226. assertFalse(SURFACE.equals(other));
  227. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  228. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  229. other = new InterpolatedFromCurvesDoublesSurface(true, POINT_LIST_SORTED, CURVES_LIST_SORTED, INTERPOLATOR, true);
  230. assertFalse(SURFACE.equals(other));
  231. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  232. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  233. other = new InterpolatedFromCurvesDoublesSurface(true, MAP, INTERPOLATOR, false);
  234. assertFalse(SURFACE.equals(other));
  235. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  236. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  237. other = new InterpolatedFromCurvesDoublesSurface(true, MAP_SORTED, INTERPOLATOR, true);
  238. assertFalse(SURFACE.equals(other));
  239. assertArrayEquals(SURFACE.getPoints(), POINT_PRIMITIVE_SORTED, 0);
  240. assertArrayEquals(SURFACE.getCurves(), CURVES_SORTED);
  241. }
  242. @Test(expectedExceptions = UnsupportedOperationException.class)
  243. public void testGetX() {
  244. SURFACE.getXData();
  245. }
  246. @Test(expectedExceptions = UnsupportedOperationException.class)
  247. public void testGetY() {
  248. SURFACE.getYData();
  249. }
  250. @Test(expectedExceptions = UnsupportedOperationException.class)
  251. public void testGetZ() {
  252. SURFACE.getZData();
  253. }
  254. @Test(expectedExceptions = UnsupportedOperationException.class)
  255. public void testSize() {
  256. SURFACE.size();
  257. }
  258. @Test(expectedExceptions = IllegalArgumentException.class)
  259. public void testNullX1() {
  260. SURFACE.getZValue(null, 2.);
  261. }
  262. @Test(expectedExceptions = IllegalArgumentException.class)
  263. public void testNullY1() {
  264. SURFACE.getZValue(1., null);
  265. }
  266. @Test(expectedExceptions = IllegalArgumentException.class)
  267. public void testNullPair() {
  268. SURFACE.getZValue(null);
  269. }
  270. @Test(expectedExceptions = IllegalArgumentException.class)
  271. public void testNullX2() {
  272. SURFACE.getZValue(Pair.of((Double) null, 2.));
  273. }
  274. @Test(expectedExceptions = IllegalArgumentException.class)
  275. public void testNullY2() {
  276. SURFACE.getZValue(Pair.of(1., (Double) null));
  277. }
  278. @Test(expectedExceptions = IllegalArgumentException.class)
  279. public void testNull1() {
  280. new InterpolatedFromCurvesDoublesSurface(true, (double[]) null, CURVES, INTERPOLATOR, false);
  281. }
  282. @Test(expectedExceptions = IllegalArgumentException.class)
  283. public void testNull2() {
  284. new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE, (Curve<Double, Double>[]) null, INTERPOLATOR, false);
  285. }
  286. @Test(expectedExceptions = IllegalArgumentException.class)
  287. public void testNull3() {
  288. new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE, CURVES, null, false);
  289. }
  290. @SuppressWarnings("unchecked")
  291. @Test(expectedExceptions = IllegalArgumentException.class)
  292. public void testNull4() {
  293. new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE, new Curve[] {C1, C2, C3, C4, C5, null}, INTERPOLATOR, false);
  294. }
  295. @Test(expectedExceptions = IllegalArgumentException.class)
  296. public void testNull5() {
  297. new InterpolatedFromCurvesDoublesSurface(true, (Double[]) null, CURVES, INTERPOLATOR, false);
  298. }
  299. @Test(expectedExceptions = IllegalArgumentException.class)
  300. public void testNull6() {
  301. new InterpolatedFromCurvesDoublesSurface(true, new Double[] {1., 2., 3., 4., 5., null}, CURVES, INTERPOLATOR, false);
  302. }
  303. @Test(expectedExceptions = IllegalArgumentException.class)
  304. public void testNull7() {
  305. new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, (Curve<Double, Double>[]) null, INTERPOLATOR, false);
  306. }
  307. @SuppressWarnings("unchecked")
  308. @Test(expectedExceptions = IllegalArgumentException.class)
  309. public void testNull8() {
  310. new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, new Curve[] {C1, C2, C3, C4, C5, null}, INTERPOLATOR, false);
  311. }
  312. @Test(expectedExceptions = IllegalArgumentException.class)
  313. public void testNull9() {
  314. new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, CURVES, null, false);
  315. }
  316. @Test(expectedExceptions = IllegalArgumentException.class)
  317. public void testNull10() {
  318. new InterpolatedFromCurvesDoublesSurface(true, (List<Double>) null, CURVES_LIST, INTERPOLATOR, false);
  319. }
  320. @Test(expectedExceptions = IllegalArgumentException.class)
  321. public void testNull11() {
  322. new InterpolatedFromCurvesDoublesSurface(true, Arrays.asList(1., 2., 3., 4., 5., null), CURVES_LIST, INTERPOLATOR, false);
  323. }
  324. @Test(expectedExceptions = IllegalArgumentException.class)
  325. public void testNull12() {
  326. new InterpolatedFromCurvesDoublesSurface(true, POINT_LIST, (List<Curve<Double, Double>>) null, INTERPOLATOR, false);
  327. }
  328. @Test(expectedExceptions = IllegalArgumentException.class)
  329. public void testNull13() {
  330. new InterpolatedFromCurvesDoublesSurface(true, (Map<Double, Curve<Double, Double>>) null, INTERPOLATOR, false);
  331. }
  332. @Test(expectedExceptions = IllegalArgumentException.class)
  333. public void testNull14() {
  334. final Map<Double, Curve<Double, Double>> m = new HashMap<Double, Curve<Double, Double>>();
  335. m.put(null, C1);
  336. new InterpolatedFromCurvesDoublesSurface(true, m, INTERPOLATOR, false);
  337. }
  338. @Test(expectedExceptions = IllegalArgumentException.class)
  339. public void testNull15() {
  340. final Map<Double, Curve<Double, Double>> m = new HashMap<Double, Curve<Double, Double>>();
  341. m.put(2., null);
  342. new InterpolatedFromCurvesDoublesSurface(true, m, INTERPOLATOR, false);
  343. }
  344. @Test(expectedExceptions = IllegalArgumentException.class)
  345. public void testNull16() {
  346. new InterpolatedFromCurvesDoublesSurface(true, MAP, null, false);
  347. }
  348. @Test(expectedExceptions = IllegalArgumentException.class)
  349. public void testNull17() {
  350. new InterpolatedFromCurvesDoublesSurface(true, (double[]) null, CURVES, INTERPOLATOR, false, NAME);
  351. }
  352. @Test(expectedExceptions = IllegalArgumentException.class)
  353. public void testNull18() {
  354. new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE, (Curve<Double, Double>[]) null, INTERPOLATOR, false, NAME);
  355. }
  356. @Test(expectedExceptions = IllegalArgumentException.class)
  357. public void testNull19() {
  358. new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE, CURVES, null, false, NAME);
  359. }
  360. @SuppressWarnings("unchecked")
  361. @Test(expectedExceptions = IllegalArgumentException.class)
  362. public void testNull20() {
  363. new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE, new Curve[] {C1, C2, C3, C4, C5, null}, INTERPOLATOR, false, NAME);
  364. }
  365. @Test(expectedExceptions = IllegalArgumentException.class)
  366. public void testNull21() {
  367. new InterpolatedFromCurvesDoublesSurface(true, (Double[]) null, CURVES, INTERPOLATOR, false, NAME);
  368. }
  369. @Test(expectedExceptions = IllegalArgumentException.class)
  370. public void testNull22() {
  371. new InterpolatedFromCurvesDoublesSurface(true, new Double[] {1., 2., 3., 4., 5., null}, CURVES, INTERPOLATOR, false, NAME);
  372. }
  373. @Test(expectedExceptions = IllegalArgumentException.class)
  374. public void testNull23() {
  375. new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, (Curve<Double, Double>[]) null, INTERPOLATOR, false, NAME);
  376. }
  377. @SuppressWarnings("unchecked")
  378. @Test(expectedExceptions = IllegalArgumentException.class)
  379. public void testNull24() {
  380. new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, new Curve[] {C1, C2, C3, C4, C5, null}, INTERPOLATOR, false, NAME);
  381. }
  382. @Test(expectedExceptions = IllegalArgumentException.class)
  383. public void testNull25() {
  384. new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, CURVES, null, false, NAME);
  385. }
  386. @Test(expectedExceptions = IllegalArgumentException.class)
  387. public void testNull26() {
  388. new InterpolatedFromCurvesDoublesSurface(true, (List<Double>) null, CURVES_LIST, INTERPOLATOR, false, NAME);
  389. }
  390. @Test(expectedExceptions = IllegalArgumentException.class)
  391. public void testNull27() {
  392. new InterpolatedFromCurvesDoublesSurface(true, Arrays.asList(1., 2., 3., 4., 5., null), CURVES_LIST, INTERPOLATOR, false, NAME);
  393. }
  394. @Test(expectedExceptions = IllegalArgumentException.class)
  395. public void testNull28() {
  396. new InterpolatedFromCurvesDoublesSurface(true, POINT_LIST, (List<Curve<Double, Double>>) null, INTERPOLATOR, false, NAME);
  397. }
  398. @Test(expectedExceptions = IllegalArgumentException.class)
  399. public void testNull29() {
  400. new InterpolatedFromCurvesDoublesSurface(true, (Map<Double, Curve<Double, Double>>) null, INTERPOLATOR, false, NAME);
  401. }
  402. @Test(expectedExceptions = IllegalArgumentException.class)
  403. public void testNull30() {
  404. final Map<Double, Curve<Double, Double>> m = new HashMap<Double, Curve<Double, Double>>();
  405. m.put(null, C1);
  406. new InterpolatedFromCurvesDoublesSurface(true, m, INTERPOLATOR, false, NAME);
  407. }
  408. @Test(expectedExceptions = IllegalArgumentException.class)
  409. public void testNull31() {
  410. final Map<Double, Curve<Double, Double>> m = new HashMap<Double, Curve<Double, Double>>();
  411. m.put(2., null);
  412. new InterpolatedFromCurvesDoublesSurface(true, m, INTERPOLATOR, false, NAME);
  413. }
  414. @Test(expectedExceptions = IllegalArgumentException.class)
  415. public void testNull32() {
  416. new InterpolatedFromCurvesDoublesSurface(true, MAP, null, false, NAME);
  417. }
  418. @SuppressWarnings("unchecked")
  419. @Test(expectedExceptions = IllegalArgumentException.class)
  420. public void testEmpty1() {
  421. new InterpolatedFromCurvesDoublesSurface(true, new double[0], new Curve[0], INTERPOLATOR, false);
  422. }
  423. @SuppressWarnings("unchecked")
  424. @Test(expectedExceptions = IllegalArgumentException.class)
  425. public void testEmpty2() {
  426. new InterpolatedFromCurvesDoublesSurface(true, new Double[0], new Curve[0], INTERPOLATOR, false);
  427. }
  428. @Test(expectedExceptions = IllegalArgumentException.class)
  429. public void testEmpty3() {
  430. new InterpolatedFromCurvesDoublesSurface(true, new ArrayList<Double>(), new ArrayList<Curve<Double, Double>>(), INTERPOLATOR, false);
  431. }
  432. @Test(expectedExceptions = IllegalArgumentException.class)
  433. public void testEmpty4() {
  434. new InterpolatedFromCurvesDoublesSurface(true, Collections.<Double, Curve<Double, Double>> emptyMap(), INTERPOLATOR, false);
  435. }
  436. @SuppressWarnings("unchecked")
  437. @Test(expectedExceptions = IllegalArgumentException.class)
  438. public void testEmpty5() {
  439. new InterpolatedFromCurvesDoublesSurface(true, new double[0], new Curve[0], INTERPOLATOR, false, NAME);
  440. }
  441. @SuppressWarnings("unchecked")
  442. @Test(expectedExceptions = IllegalArgumentException.class)
  443. public void testEmpty6() {
  444. new InterpolatedFromCurvesDoublesSurface(true, new Double[0], new Curve[0], INTERPOLATOR, false, NAME);
  445. }
  446. @Test(expectedExceptions = IllegalArgumentException.class)
  447. public void testEmpty7() {
  448. new InterpolatedFromCurvesDoublesSurface(true, new ArrayList<Double>(), new ArrayList<Curve<Double, Double>>(), INTERPOLATOR, false, NAME);
  449. }
  450. @Test(expectedExceptions = IllegalArgumentException.class)
  451. public void testEmpty8() {
  452. new InterpolatedFromCurvesDoublesSurface(true, Collections.<Double, Curve<Double, Double>> emptyMap(), INTERPOLATOR, false, NAME);
  453. }
  454. @Test(expectedExceptions = IllegalArgumentException.class)
  455. public void testWrongLength1() {
  456. new InterpolatedFromCurvesDoublesSurface(true, new double[] {1}, CURVES, INTERPOLATOR, false);
  457. }
  458. @SuppressWarnings("unchecked")
  459. @Test(expectedExceptions = IllegalArgumentException.class)
  460. public void testWrongLength2() {
  461. new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE, new Curve[] {C1}, INTERPOLATOR, false);
  462. }
  463. @Test(expectedExceptions = IllegalArgumentException.class)
  464. public void testWrongLength3() {
  465. new InterpolatedFromCurvesDoublesSurface(true, new Double[] {1.}, CURVES, INTERPOLATOR, false);
  466. }
  467. @SuppressWarnings("unchecked")
  468. @Test(expectedExceptions = IllegalArgumentException.class)
  469. public void testWrongLength4() {
  470. new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, new Curve[] {C1}, INTERPOLATOR, false);
  471. }
  472. @Test(expectedExceptions = IllegalArgumentException.class)
  473. public void testWrongLength5() {
  474. new InterpolatedFromCurvesDoublesSurface(true, Arrays.asList(2.), CURVES_LIST, INTERPOLATOR, false);
  475. }
  476. @Test(expectedExceptions = IllegalArgumentException.class)
  477. public void testWrongLength6() {
  478. final List<Curve<Double, Double>> l = new ArrayList<Curve<Double, Double>>();
  479. l.add(C1);
  480. new InterpolatedFromCurvesDoublesSurface(true, POINT_LIST, l, INTERPOLATOR, false);
  481. }
  482. @Test(expectedExceptions = IllegalArgumentException.class)
  483. public void testWrongLength7() {
  484. new InterpolatedFromCurvesDoublesSurface(true, new double[] {1}, CURVES, INTERPOLATOR, false, NAME);
  485. }
  486. @SuppressWarnings("unchecked")
  487. @Test(expectedExceptions = IllegalArgumentException.class)
  488. public void testWrongLength8() {
  489. new InterpolatedFromCurvesDoublesSurface(true, POINT_PRIMITIVE, new Curve[] {C1}, INTERPOLATOR, false, NAME);
  490. }
  491. @Test(expectedExceptions = IllegalArgumentException.class)
  492. public void testWrongLength9() {
  493. new InterpolatedFromCurvesDoublesSurface(true, new Double[] {1.}, CURVES, INTERPOLATOR, false, NAME);
  494. }
  495. @SuppressWarnings("unchecked")
  496. @Test(expectedExceptions = IllegalArgumentException.class)
  497. public void testWrongLength10() {
  498. new InterpolatedFromCurvesDoublesSurface(true, POINT_OBJECT, new Curve[] {C1}, INTERPOLATOR, false, NAME);
  499. }
  500. @Test(expectedExceptions = IllegalArgumentException.class)
  501. public void testWrongLength11() {
  502. new InterpolatedFromCurvesDoublesSurface(true, Arrays.asList(2.), CURVES_LIST, INTERPOLATOR, false, NAME);
  503. }
  504. @Test(expectedExceptions = IllegalArgumentException.class)
  505. public void testWrongLength12() {
  506. final List<Curve<Double, Double>> l = new ArrayList<Curve<Double, Double>>();
  507. l.add(C1);
  508. new InterpolatedFromCurvesDoublesSurface(true, POINT_LIST, l, INTERPOLATOR, false, NAME);
  509. }
  510. }