/projects/OG-Analytics/tests/unit/com/opengamma/math/cube/InterpolatedFromSurfacesDoublesCubeTest.java

https://github.com/gsteri1/OG-Platform · Java · 565 lines · 491 code · 66 blank · 8 comment · 1 complexity · b0d0c28c60264c62774e29ca96435a18 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.cube;
  7. import static org.testng.AssertJUnit.assertEquals;
  8. import static org.testng.AssertJUnit.assertFalse;
  9. import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
  10. import java.util.ArrayList;
  11. import java.util.Arrays;
  12. import java.util.List;
  13. import java.util.Map;
  14. import java.util.TreeMap;
  15. import org.testng.annotations.Test;
  16. import com.opengamma.math.cube.InterpolatedFromSurfacesDoublesCube.SurfacePlane;
  17. import com.opengamma.math.function.Function;
  18. import com.opengamma.math.interpolation.LinearInterpolator1D;
  19. import com.opengamma.math.interpolation.LogLinearInterpolator1D;
  20. import com.opengamma.math.surface.FunctionalDoublesSurface;
  21. import com.opengamma.math.surface.Surface;
  22. import com.opengamma.util.tuple.Triple;
  23. /**
  24. *
  25. */
  26. public class InterpolatedFromSurfacesDoublesCubeTest {
  27. private static final double A0 = 0;
  28. private static final double A1 = 2;
  29. private static final double A2 = 10;
  30. private static final Function<Double, Double> F1 = new Function<Double, Double>() {
  31. @Override
  32. public Double evaluate(final Double... xy) {
  33. return -4.;
  34. }
  35. };
  36. private static final Function<Double, Double> F2 = new Function<Double, Double>() {
  37. @Override
  38. public Double evaluate(final Double... xy) {
  39. final double x = xy[0];
  40. final double y = xy[1];
  41. return x * x + y * y + x * y;
  42. }
  43. };
  44. private static final Surface<Double, Double, Double> S1 = FunctionalDoublesSurface.from(F1, "A");
  45. private static final Surface<Double, Double, Double> S2 = FunctionalDoublesSurface.from(F2, "B");
  46. private static final Surface<Double, Double, Double> S3 = FunctionalDoublesSurface.from(F2, "C");
  47. private static final String NAME = "K";
  48. private static final double[] POINTS_PRIMITIVE = new double[] {A0, A1, A2};
  49. private static final Double[] POINTS_OBJECT;
  50. private static final List<Double> POINTS_LIST;
  51. @SuppressWarnings("unchecked")
  52. private static final Surface<Double, Double, Double>[] SURFACE_ARRAY = new Surface[] {S1, S2, S3};
  53. private static final List<Surface<Double, Double, Double>> SURFACE_LIST;
  54. private static final Map<Double, Surface<Double, Double, Double>> SURFACE_MAP;
  55. private static final double[] UNSORTED_POINTS_PRIMITIVE = new double[] {A0, A2, A1};
  56. private static final Double[] UNSORTED_POINTS_OBJECT;
  57. private static final List<Double> UNSORTED_POINTS_LIST;
  58. @SuppressWarnings("unchecked")
  59. private static final Surface<Double, Double, Double>[] UNSORTED_SURFACE_ARRAY = new Surface[] {S1, S3, S2};
  60. private static final List<Surface<Double, Double, Double>> UNSORTED_SURFACE_LIST;
  61. private static final Map<Double, Surface<Double, Double, Double>> UNSORTED_SURFACE_MAP;
  62. private static final LinearInterpolator1D INTERPOLATOR = new LinearInterpolator1D();
  63. private static final InterpolatedFromSurfacesDoublesCube XY_CUBE;
  64. private static final InterpolatedFromSurfacesDoublesCube XZ_CUBE;
  65. private static final InterpolatedFromSurfacesDoublesCube YZ_CUBE;
  66. static {
  67. final int n = POINTS_PRIMITIVE.length;
  68. POINTS_OBJECT = new Double[n];
  69. POINTS_LIST = new ArrayList<Double>();
  70. SURFACE_LIST = new ArrayList<Surface<Double, Double, Double>>();
  71. SURFACE_MAP = new TreeMap<Double, Surface<Double, Double, Double>>();
  72. UNSORTED_POINTS_OBJECT = new Double[n];
  73. UNSORTED_POINTS_LIST = new ArrayList<Double>();
  74. UNSORTED_SURFACE_LIST = new ArrayList<Surface<Double, Double, Double>>();
  75. UNSORTED_SURFACE_MAP = new TreeMap<Double, Surface<Double, Double, Double>>();
  76. for (int i = 0; i < n; i++) {
  77. POINTS_OBJECT[i] = POINTS_PRIMITIVE[i];
  78. POINTS_LIST.add(POINTS_PRIMITIVE[i]);
  79. SURFACE_LIST.add(SURFACE_ARRAY[i]);
  80. SURFACE_MAP.put(POINTS_PRIMITIVE[i], SURFACE_ARRAY[i]);
  81. UNSORTED_POINTS_OBJECT[i] = UNSORTED_POINTS_PRIMITIVE[i];
  82. UNSORTED_POINTS_LIST.add(UNSORTED_POINTS_PRIMITIVE[i]);
  83. UNSORTED_SURFACE_LIST.add(UNSORTED_SURFACE_ARRAY[i]);
  84. UNSORTED_SURFACE_MAP.put(UNSORTED_POINTS_PRIMITIVE[i], UNSORTED_SURFACE_ARRAY[i]);
  85. }
  86. XY_CUBE = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, SURFACE_MAP, INTERPOLATOR, NAME);
  87. XZ_CUBE = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XZ, SURFACE_MAP, INTERPOLATOR, NAME);
  88. YZ_CUBE = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.YZ, SURFACE_MAP, INTERPOLATOR, NAME);
  89. }
  90. @Test
  91. public void testCubes() {
  92. double x = 3;
  93. double y = 4;
  94. double z = A1;
  95. assertEquals(XY_CUBE.getValue(x, y, z), F2.evaluate(x, y), 0);
  96. assertEquals(XY_CUBE.getValue(new Triple<Double, Double, Double>(x, y, z)), F2.evaluate(x, y), 0);
  97. z = A1 * Math.random();
  98. double lower = F1.evaluate(x, y);
  99. double higher = F2.evaluate(x, y);
  100. double value = (higher - lower) * (z / A1) + lower;
  101. assertEquals(XY_CUBE.getValue(x, y, z), value, 0);
  102. assertEquals(XY_CUBE.getValue(new Triple<Double, Double, Double>(x, y, z)), value, 0);
  103. x = 2.4;
  104. y = A2;
  105. z = 5.6;
  106. assertEquals(XZ_CUBE.getValue(x, y, z), F2.evaluate(x, z), 0);
  107. assertEquals(XZ_CUBE.getValue(new Triple<Double, Double, Double>(x, y, z)), F2.evaluate(x, z), 0);
  108. y = A1 * Math.random();
  109. lower = F1.evaluate(x, z);
  110. higher = F2.evaluate(x, z);
  111. value = (higher - lower) * (y / A1) + lower;
  112. assertEquals(XZ_CUBE.getValue(x, y, z), value, 0);
  113. assertEquals(XZ_CUBE.getValue(new Triple<Double, Double, Double>(x, y, z)), value, 0);
  114. x = A0;
  115. y = 1.34;
  116. z = 5.6;
  117. assertEquals(YZ_CUBE.getValue(x, y, z), F1.evaluate(y, z), 0);
  118. assertEquals(YZ_CUBE.getValue(new Triple<Double, Double, Double>(x, y, z)), F1.evaluate(y, z), 0);
  119. x = A1 * Math.random();
  120. lower = F1.evaluate(y, z);
  121. higher = F2.evaluate(y, z);
  122. value = (higher - lower) * (x / A1) + lower;
  123. assertEquals(YZ_CUBE.getValue(x, y, z), value, 0);
  124. assertEquals(YZ_CUBE.getValue(new Triple<Double, Double, Double>(x, y, z)), value, 0);
  125. }
  126. @Test
  127. public void testHashCodeAndEquals() {
  128. InterpolatedFromSurfacesDoublesCube other = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, SURFACE_MAP, INTERPOLATOR, NAME);
  129. assertEquals(other, XY_CUBE);
  130. assertEquals(other.hashCode(), XY_CUBE.hashCode());
  131. assertEquals(other.getInterpolator(), INTERPOLATOR);
  132. assertArrayEquals(other.getPoints(), POINTS_PRIMITIVE, 0);
  133. assertArrayEquals(other.getSurfaces(), SURFACE_ARRAY);
  134. assertEquals(other.getName(), NAME);
  135. assertEquals(other.getPlane(), SurfacePlane.XY);
  136. assertFalse(other.equals(XZ_CUBE));
  137. TreeMap<Double, Surface<Double, Double, Double>> m = new TreeMap<Double, Surface<Double, Double, Double>>();
  138. m.put(1., S1);
  139. m.put(2.5, S2);
  140. m.put(3., S3);
  141. other = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, m, INTERPOLATOR, NAME);
  142. assertFalse(other.equals(XY_CUBE));
  143. m = new TreeMap<Double, Surface<Double, Double, Double>>();
  144. m.put(1., S1);
  145. m.put(2., S1);
  146. m.put(3., S3);
  147. other = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, m, INTERPOLATOR, NAME);
  148. assertFalse(other.equals(XY_CUBE));
  149. other = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, SURFACE_MAP, new LogLinearInterpolator1D(), NAME);
  150. assertFalse(other.equals(XY_CUBE));
  151. other = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, SURFACE_MAP, INTERPOLATOR, NAME + "_");
  152. assertFalse(other.equals(XY_CUBE));
  153. }
  154. @Test
  155. public void testConstructors() {
  156. final InterpolatedFromSurfacesDoublesCube cube1 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, SURFACE_MAP, INTERPOLATOR, true, NAME);
  157. InterpolatedFromSurfacesDoublesCube cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, SURFACE_MAP, INTERPOLATOR, true);
  158. assertFalse(cube1.equals(cube2));
  159. assertEquals(cube1.getInterpolator(), cube2.getInterpolator());
  160. assertArrayEquals(cube1.getPoints(), cube2.getPoints(), 0);
  161. assertArrayEquals(cube1.getSurfaces(), cube2.getSurfaces());
  162. assertEquals(cube1.getPlane(), cube2.getPlane());
  163. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_PRIMITIVE, SURFACE_ARRAY, INTERPOLATOR, true, NAME);
  164. assertEquals(cube1, cube2);
  165. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_PRIMITIVE, SURFACE_ARRAY, INTERPOLATOR, true);
  166. assertFalse(cube1.equals(cube2));
  167. assertEquals(cube1.getInterpolator(), cube2.getInterpolator());
  168. assertArrayEquals(cube1.getPoints(), cube2.getPoints(), 0);
  169. assertArrayEquals(cube1.getSurfaces(), cube2.getSurfaces());
  170. assertEquals(cube1.getPlane(), cube2.getPlane());
  171. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_OBJECT, SURFACE_ARRAY, INTERPOLATOR, true, NAME);
  172. assertEquals(cube1, cube2);
  173. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_OBJECT, SURFACE_ARRAY, INTERPOLATOR, true);
  174. assertFalse(cube1.equals(cube2));
  175. assertEquals(cube1.getInterpolator(), cube2.getInterpolator());
  176. assertArrayEquals(cube1.getPoints(), cube2.getPoints(), 0);
  177. assertArrayEquals(cube1.getSurfaces(), cube2.getSurfaces());
  178. assertEquals(cube1.getPlane(), cube2.getPlane());
  179. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_LIST, SURFACE_LIST, INTERPOLATOR, true, NAME);
  180. assertEquals(cube1, cube2);
  181. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_LIST, SURFACE_LIST, INTERPOLATOR, true);
  182. assertFalse(cube1.equals(cube2));
  183. assertEquals(cube1.getInterpolator(), cube2.getInterpolator());
  184. assertArrayEquals(cube1.getPoints(), cube2.getPoints(), 0);
  185. assertArrayEquals(cube1.getSurfaces(), cube2.getSurfaces());
  186. assertEquals(cube1.getPlane(), cube2.getPlane());
  187. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, UNSORTED_SURFACE_MAP, INTERPOLATOR, false, NAME);
  188. assertEquals(cube1, cube2);
  189. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, UNSORTED_SURFACE_MAP, INTERPOLATOR, false);
  190. assertFalse(cube1.equals(cube2));
  191. assertEquals(cube1.getInterpolator(), cube2.getInterpolator());
  192. assertArrayEquals(cube1.getPoints(), cube2.getPoints(), 0);
  193. assertArrayEquals(cube1.getSurfaces(), cube2.getSurfaces());
  194. assertEquals(cube1.getPlane(), cube2.getPlane());
  195. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, UNSORTED_POINTS_PRIMITIVE, UNSORTED_SURFACE_ARRAY, INTERPOLATOR, false, NAME);
  196. assertEquals(cube1, cube2);
  197. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, UNSORTED_POINTS_PRIMITIVE, UNSORTED_SURFACE_ARRAY, INTERPOLATOR, false);
  198. assertFalse(cube1.equals(cube2));
  199. assertEquals(cube1.getInterpolator(), cube2.getInterpolator());
  200. assertArrayEquals(cube1.getPoints(), cube2.getPoints(), 0);
  201. assertArrayEquals(cube1.getSurfaces(), cube2.getSurfaces());
  202. assertEquals(cube1.getPlane(), cube2.getPlane());
  203. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, UNSORTED_POINTS_OBJECT, UNSORTED_SURFACE_ARRAY, INTERPOLATOR, false, NAME);
  204. assertEquals(cube1, cube2);
  205. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, UNSORTED_POINTS_OBJECT, UNSORTED_SURFACE_ARRAY, INTERPOLATOR, false);
  206. assertFalse(cube1.equals(cube2));
  207. assertEquals(cube1.getInterpolator(), cube2.getInterpolator());
  208. assertArrayEquals(cube1.getPoints(), cube2.getPoints(), 0);
  209. assertArrayEquals(cube1.getSurfaces(), cube2.getSurfaces());
  210. assertEquals(cube1.getPlane(), cube2.getPlane());
  211. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, UNSORTED_POINTS_LIST, UNSORTED_SURFACE_LIST, INTERPOLATOR, false, NAME);
  212. assertEquals(cube1, cube2);
  213. cube2 = new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, UNSORTED_POINTS_LIST, UNSORTED_SURFACE_LIST, INTERPOLATOR, false);
  214. assertFalse(cube1.equals(cube2));
  215. assertEquals(cube1.getInterpolator(), cube2.getInterpolator());
  216. assertArrayEquals(cube1.getPoints(), cube2.getPoints(), 0);
  217. assertArrayEquals(cube1.getSurfaces(), cube2.getSurfaces());
  218. assertEquals(cube1.getPlane(), cube2.getPlane());
  219. }
  220. @Test
  221. public void testStaticConstruction() {
  222. InterpolatedFromSurfacesDoublesCube cube = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, SURFACE_MAP, INTERPOLATOR, NAME);
  223. assertEquals(cube, XY_CUBE);
  224. cube = InterpolatedFromSurfacesDoublesCube.from(SurfacePlane.XY, UNSORTED_SURFACE_MAP, INTERPOLATOR, NAME);
  225. assertEquals(cube, XY_CUBE);
  226. cube = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, SURFACE_MAP, INTERPOLATOR);
  227. assertFalse(cube.equals(XY_CUBE));
  228. assertEquals(cube.getInterpolator(), XY_CUBE.getInterpolator());
  229. assertArrayEquals(cube.getPoints(), XY_CUBE.getPoints(), 0);
  230. assertArrayEquals(cube.getSurfaces(), XY_CUBE.getSurfaces());
  231. assertEquals(cube.getPlane(), XY_CUBE.getPlane());
  232. cube = InterpolatedFromSurfacesDoublesCube.from(SurfacePlane.XY, UNSORTED_SURFACE_MAP, INTERPOLATOR);
  233. assertFalse(cube.equals(XY_CUBE));
  234. assertEquals(cube.getInterpolator(), XY_CUBE.getInterpolator());
  235. assertArrayEquals(cube.getPoints(), XY_CUBE.getPoints(), 0);
  236. assertArrayEquals(cube.getSurfaces(), XY_CUBE.getSurfaces());
  237. assertEquals(cube.getPlane(), XY_CUBE.getPlane());
  238. cube = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, POINTS_PRIMITIVE, SURFACE_ARRAY, INTERPOLATOR, NAME);
  239. assertEquals(cube, XY_CUBE);
  240. cube = InterpolatedFromSurfacesDoublesCube.from(SurfacePlane.XY, UNSORTED_POINTS_PRIMITIVE, UNSORTED_SURFACE_ARRAY, INTERPOLATOR, NAME);
  241. assertEquals(cube, XY_CUBE);
  242. cube = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, POINTS_PRIMITIVE, SURFACE_ARRAY, INTERPOLATOR);
  243. assertFalse(cube.equals(XY_CUBE));
  244. assertEquals(cube.getInterpolator(), XY_CUBE.getInterpolator());
  245. assertArrayEquals(cube.getPoints(), XY_CUBE.getPoints(), 0);
  246. assertArrayEquals(cube.getSurfaces(), XY_CUBE.getSurfaces());
  247. assertEquals(cube.getPlane(), XY_CUBE.getPlane());
  248. cube = InterpolatedFromSurfacesDoublesCube.from(SurfacePlane.XY, UNSORTED_POINTS_PRIMITIVE, UNSORTED_SURFACE_ARRAY, INTERPOLATOR);
  249. assertFalse(cube.equals(XY_CUBE));
  250. assertEquals(cube.getInterpolator(), XY_CUBE.getInterpolator());
  251. assertArrayEquals(cube.getPoints(), XY_CUBE.getPoints(), 0);
  252. assertArrayEquals(cube.getSurfaces(), XY_CUBE.getSurfaces());
  253. assertEquals(cube.getPlane(), XY_CUBE.getPlane());
  254. cube = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, POINTS_LIST, SURFACE_LIST, INTERPOLATOR, NAME);
  255. assertEquals(cube, XY_CUBE);
  256. cube = InterpolatedFromSurfacesDoublesCube.from(SurfacePlane.XY, UNSORTED_POINTS_LIST, UNSORTED_SURFACE_LIST, INTERPOLATOR, NAME);
  257. assertEquals(cube, XY_CUBE);
  258. cube = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, POINTS_LIST, SURFACE_LIST, INTERPOLATOR);
  259. assertFalse(cube.equals(XY_CUBE));
  260. assertEquals(cube.getInterpolator(), XY_CUBE.getInterpolator());
  261. assertArrayEquals(cube.getPoints(), XY_CUBE.getPoints(), 0);
  262. assertArrayEquals(cube.getSurfaces(), XY_CUBE.getSurfaces());
  263. assertEquals(cube.getPlane(), XY_CUBE.getPlane());
  264. cube = InterpolatedFromSurfacesDoublesCube.from(SurfacePlane.XY, UNSORTED_POINTS_LIST, UNSORTED_SURFACE_LIST, INTERPOLATOR);
  265. assertFalse(cube.equals(XY_CUBE));
  266. assertEquals(cube.getInterpolator(), XY_CUBE.getInterpolator());
  267. assertArrayEquals(cube.getPoints(), XY_CUBE.getPoints(), 0);
  268. assertArrayEquals(cube.getSurfaces(), XY_CUBE.getSurfaces());
  269. assertEquals(cube.getPlane(), XY_CUBE.getPlane());
  270. cube = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, POINTS_OBJECT, SURFACE_ARRAY, INTERPOLATOR, NAME);
  271. assertEquals(cube, XY_CUBE);
  272. cube = InterpolatedFromSurfacesDoublesCube.from(SurfacePlane.XY, UNSORTED_POINTS_OBJECT, UNSORTED_SURFACE_ARRAY, INTERPOLATOR, NAME);
  273. assertEquals(cube, XY_CUBE);
  274. cube = InterpolatedFromSurfacesDoublesCube.fromSorted(SurfacePlane.XY, POINTS_OBJECT, SURFACE_ARRAY, INTERPOLATOR);
  275. assertFalse(cube.equals(XY_CUBE));
  276. assertEquals(cube.getInterpolator(), XY_CUBE.getInterpolator());
  277. assertArrayEquals(cube.getPoints(), XY_CUBE.getPoints(), 0);
  278. assertArrayEquals(cube.getSurfaces(), XY_CUBE.getSurfaces());
  279. assertEquals(cube.getPlane(), XY_CUBE.getPlane());
  280. cube = InterpolatedFromSurfacesDoublesCube.from(SurfacePlane.XY, UNSORTED_POINTS_OBJECT, UNSORTED_SURFACE_ARRAY, INTERPOLATOR);
  281. assertFalse(cube.equals(XY_CUBE));
  282. assertEquals(cube.getInterpolator(), XY_CUBE.getInterpolator());
  283. assertArrayEquals(cube.getPoints(), XY_CUBE.getPoints(), 0);
  284. assertArrayEquals(cube.getSurfaces(), XY_CUBE.getSurfaces());
  285. assertEquals(cube.getPlane(), XY_CUBE.getPlane());
  286. }
  287. @Test(expectedExceptions = IllegalArgumentException.class)
  288. public void testNullPlane1() {
  289. new InterpolatedFromSurfacesDoublesCube(null, POINTS_PRIMITIVE, SURFACE_ARRAY, INTERPOLATOR, true);
  290. }
  291. @Test(expectedExceptions = IllegalArgumentException.class)
  292. public void testNullPlane2() {
  293. new InterpolatedFromSurfacesDoublesCube(null, POINTS_PRIMITIVE, SURFACE_ARRAY, INTERPOLATOR, true, NAME);
  294. }
  295. @Test(expectedExceptions = IllegalArgumentException.class)
  296. public void testNullPlane3() {
  297. new InterpolatedFromSurfacesDoublesCube(null, POINTS_OBJECT, SURFACE_ARRAY, INTERPOLATOR, true);
  298. }
  299. @Test(expectedExceptions = IllegalArgumentException.class)
  300. public void testNullPlane4() {
  301. new InterpolatedFromSurfacesDoublesCube(null, POINTS_OBJECT, SURFACE_ARRAY, INTERPOLATOR, true, NAME);
  302. }
  303. @Test(expectedExceptions = IllegalArgumentException.class)
  304. public void testNullPlane5() {
  305. new InterpolatedFromSurfacesDoublesCube(null, POINTS_LIST, SURFACE_LIST, INTERPOLATOR, true);
  306. }
  307. @Test(expectedExceptions = IllegalArgumentException.class)
  308. public void testNullPlane6() {
  309. new InterpolatedFromSurfacesDoublesCube(null, POINTS_LIST, SURFACE_LIST, INTERPOLATOR, true, NAME);
  310. }
  311. @Test(expectedExceptions = IllegalArgumentException.class)
  312. public void testNullPlane7() {
  313. new InterpolatedFromSurfacesDoublesCube(null, SURFACE_MAP, INTERPOLATOR, true);
  314. }
  315. @Test(expectedExceptions = IllegalArgumentException.class)
  316. public void testNullPlane8() {
  317. new InterpolatedFromSurfacesDoublesCube(null, SURFACE_MAP, INTERPOLATOR, true, NAME);
  318. }
  319. @Test(expectedExceptions = IllegalArgumentException.class)
  320. public void testNullPoints1() {
  321. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, (double[]) null, SURFACE_ARRAY, INTERPOLATOR, true);
  322. }
  323. @Test(expectedExceptions = IllegalArgumentException.class)
  324. public void testNullPoints2() {
  325. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, (double[]) null, SURFACE_ARRAY, INTERPOLATOR, true, NAME);
  326. }
  327. @Test(expectedExceptions = IllegalArgumentException.class)
  328. public void testNullPoints3() {
  329. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, (Double[]) null, SURFACE_ARRAY, INTERPOLATOR, true);
  330. }
  331. @Test(expectedExceptions = IllegalArgumentException.class)
  332. public void testNullPoints4() {
  333. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, (Double[]) null, SURFACE_ARRAY, INTERPOLATOR, true, NAME);
  334. }
  335. @Test(expectedExceptions = IllegalArgumentException.class)
  336. public void testNullPoints5() {
  337. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, (List<Double>) null, SURFACE_LIST, INTERPOLATOR, true);
  338. }
  339. @Test(expectedExceptions = IllegalArgumentException.class)
  340. public void testNullPoints6() {
  341. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, (List<Double>) null, SURFACE_LIST, INTERPOLATOR, true, NAME);
  342. }
  343. @Test(expectedExceptions = IllegalArgumentException.class)
  344. public void testNullSurfaces1() {
  345. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_PRIMITIVE, null, INTERPOLATOR, true);
  346. }
  347. @Test(expectedExceptions = IllegalArgumentException.class)
  348. public void testNullSurfaces2() {
  349. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_PRIMITIVE, null, INTERPOLATOR, true, NAME);
  350. }
  351. @Test(expectedExceptions = IllegalArgumentException.class)
  352. public void testNullSurfaces3() {
  353. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_OBJECT, null, INTERPOLATOR, true);
  354. }
  355. @Test(expectedExceptions = IllegalArgumentException.class)
  356. public void testNullSurfaces4() {
  357. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_OBJECT, null, INTERPOLATOR, true, NAME);
  358. }
  359. @Test(expectedExceptions = IllegalArgumentException.class)
  360. public void testNullSurfaces5() {
  361. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_LIST, null, INTERPOLATOR, true);
  362. }
  363. @Test(expectedExceptions = IllegalArgumentException.class)
  364. public void testNullSurfaces6() {
  365. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_LIST, null, INTERPOLATOR, true, NAME);
  366. }
  367. @Test(expectedExceptions = IllegalArgumentException.class)
  368. public void testNullPointValue1() {
  369. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, new Double[] {1., 2., null}, SURFACE_ARRAY, INTERPOLATOR, true);
  370. }
  371. @Test(expectedExceptions = IllegalArgumentException.class)
  372. public void testNullPointValue2() {
  373. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, new Double[] {1., 2., null}, SURFACE_ARRAY, INTERPOLATOR, true, NAME);
  374. }
  375. @Test(expectedExceptions = IllegalArgumentException.class)
  376. public void testNullPointValue3() {
  377. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, Arrays.asList(1., 2., null), SURFACE_LIST, INTERPOLATOR, true);
  378. }
  379. @Test(expectedExceptions = IllegalArgumentException.class)
  380. public void testNullPointValue4() {
  381. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, Arrays.asList(1., 2., null), SURFACE_LIST, INTERPOLATOR, true, NAME);
  382. }
  383. @Test(expectedExceptions = IllegalArgumentException.class)
  384. public void testNullMap1() {
  385. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, null, INTERPOLATOR, true);
  386. }
  387. @Test(expectedExceptions = IllegalArgumentException.class)
  388. public void testNullMap2() {
  389. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, null, INTERPOLATOR, true, NAME);
  390. }
  391. @Test(expectedExceptions = IllegalArgumentException.class)
  392. public void testNullEntry1() {
  393. final TreeMap<Double, Surface<Double, Double, Double>> m = new TreeMap<Double, Surface<Double, Double, Double>>();
  394. m.put(1., S1);
  395. m.put(2., null);
  396. m.put(3., S3);
  397. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, m, INTERPOLATOR, true);
  398. }
  399. @Test(expectedExceptions = IllegalArgumentException.class)
  400. public void testNullEntry2() {
  401. final TreeMap<Double, Surface<Double, Double, Double>> m = new TreeMap<Double, Surface<Double, Double, Double>>();
  402. m.put(1., S1);
  403. m.put(2., null);
  404. m.put(3., S3);
  405. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, m, INTERPOLATOR, true, NAME);
  406. }
  407. @Test(expectedExceptions = IllegalArgumentException.class)
  408. public void testWrongLength1() {
  409. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, new double[] {1, 2, 3, 4, 5}, SURFACE_ARRAY, INTERPOLATOR, true);
  410. }
  411. @Test(expectedExceptions = IllegalArgumentException.class)
  412. public void testWrongLength2() {
  413. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, new double[] {1, 2, 3, 4, 5}, SURFACE_ARRAY, INTERPOLATOR, true, NAME);
  414. }
  415. @Test(expectedExceptions = IllegalArgumentException.class)
  416. public void testWrongLength3() {
  417. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, new Double[] {1., 2., 3., 4., 5.}, SURFACE_ARRAY, INTERPOLATOR, true);
  418. }
  419. @Test(expectedExceptions = IllegalArgumentException.class)
  420. public void testWrongLength4() {
  421. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, new Double[] {1., 2., 3., 4., 5.}, SURFACE_ARRAY, INTERPOLATOR, true, NAME);
  422. }
  423. @Test(expectedExceptions = IllegalArgumentException.class)
  424. public void testWrongLength5() {
  425. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, Arrays.asList(1., 2., 3., 4.), SURFACE_LIST, INTERPOLATOR, true);
  426. }
  427. @Test(expectedExceptions = IllegalArgumentException.class)
  428. public void testWrongLength6() {
  429. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, Arrays.asList(1., 2., 3., 4.), SURFACE_LIST, INTERPOLATOR, true, NAME);
  430. }
  431. @Test(expectedExceptions = IllegalArgumentException.class)
  432. public void testNullInterpolator1() {
  433. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_PRIMITIVE, SURFACE_ARRAY, null, true);
  434. }
  435. @Test(expectedExceptions = IllegalArgumentException.class)
  436. public void testNullInterpolator2() {
  437. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_PRIMITIVE, SURFACE_ARRAY, null, true, NAME);
  438. }
  439. @Test(expectedExceptions = IllegalArgumentException.class)
  440. public void testNullInterpolator3() {
  441. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_OBJECT, SURFACE_ARRAY, null, true);
  442. }
  443. @Test(expectedExceptions = IllegalArgumentException.class)
  444. public void testNullInterpolator4() {
  445. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_OBJECT, SURFACE_ARRAY, null, true, NAME);
  446. }
  447. @Test(expectedExceptions = IllegalArgumentException.class)
  448. public void testNullInterpolator5() {
  449. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_LIST, SURFACE_LIST, null, true);
  450. }
  451. @Test(expectedExceptions = IllegalArgumentException.class)
  452. public void testNullInterpolator6() {
  453. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, POINTS_LIST, SURFACE_LIST, null, true, NAME);
  454. }
  455. @Test(expectedExceptions = IllegalArgumentException.class)
  456. public void testNullInterpolator7() {
  457. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, SURFACE_MAP, null, true);
  458. }
  459. @Test(expectedExceptions = IllegalArgumentException.class)
  460. public void testNullInterpolator8() {
  461. new InterpolatedFromSurfacesDoublesCube(SurfacePlane.XY, SURFACE_MAP, null, true, NAME);
  462. }
  463. @Test(expectedExceptions = UnsupportedOperationException.class)
  464. public void testGetXData() {
  465. XY_CUBE.getXData();
  466. }
  467. @Test(expectedExceptions = UnsupportedOperationException.class)
  468. public void testGetYData() {
  469. XY_CUBE.getYData();
  470. }
  471. @Test(expectedExceptions = UnsupportedOperationException.class)
  472. public void testGetZData() {
  473. XY_CUBE.getZData();
  474. }
  475. @Test(expectedExceptions = UnsupportedOperationException.class)
  476. public void testGetValues() {
  477. XY_CUBE.getValues();
  478. }
  479. @Test(expectedExceptions = UnsupportedOperationException.class)
  480. public void testSize() {
  481. XY_CUBE.size();
  482. }
  483. @Test(expectedExceptions = IllegalArgumentException.class)
  484. public void testGetValueWithNull1() {
  485. XY_CUBE.getValue(null);
  486. }
  487. @Test(expectedExceptions = IllegalArgumentException.class)
  488. public void testGetValueWithNull2() {
  489. XY_CUBE.getValue(null, 2., 3.);
  490. }
  491. @Test(expectedExceptions = IllegalArgumentException.class)
  492. public void testGetValueWithNull3() {
  493. XY_CUBE.getValue(1., null, 3.);
  494. }
  495. @Test(expectedExceptions = IllegalArgumentException.class)
  496. public void testGetValueWithNull4() {
  497. XY_CUBE.getValue(1., 2., null);
  498. }
  499. }