View Javadoc
1   package de.dlr.shepard.data.spatialdata.model;
2   
3   import static org.junit.jupiter.api.Assertions.assertEquals;
4   import static org.junit.jupiter.api.Assertions.assertFalse;
5   import static org.junit.jupiter.api.Assertions.assertTrue;
6   
7   import de.dlr.shepard.data.spatialdata.model.geometryFilter.AxisAlignedBoundingBox;
8   import de.dlr.shepard.data.spatialdata.model.geometryFilter.BoundingSphere;
9   import de.dlr.shepard.data.spatialdata.model.geometryFilter.KNearestNeighbor;
10  import org.junit.jupiter.api.Test;
11  
12  public class GeometryFilterTest {
13  
14    @Test
15    public void isValidAxisAlignedBoundingBoxFilter_valid() {
16      AxisAlignedBoundingBox axisAlignedBoundingBox = new AxisAlignedBoundingBox(1, 2, 3, 4, 5, 6);
17      assertTrue(axisAlignedBoundingBox.isValid());
18    }
19  
20    @Test
21    public void isValidAxisAlignedBoundingBoxFilter_notValid() {
22      AxisAlignedBoundingBox axisAlignedBoundingBox = new AxisAlignedBoundingBox(1, 2, 3, -1, 5, 6);
23      assertFalse(axisAlignedBoundingBox.isValid());
24      axisAlignedBoundingBox = new AxisAlignedBoundingBox(1, 2, 3, 4, -1, 6);
25      assertFalse(axisAlignedBoundingBox.isValid());
26      axisAlignedBoundingBox = new AxisAlignedBoundingBox(1, 2, 3, 4, 5, -1);
27      assertFalse(axisAlignedBoundingBox.isValid());
28    }
29  
30    @Test
31    public void isValidBoundingSphereFilter_valid() {
32      BoundingSphere boundingSphere = new BoundingSphere(1, 2, 3, 4);
33      assertTrue(boundingSphere.isValid());
34    }
35  
36    @Test
37    public void isValidBoundingSphereFilter_notValid() {
38      BoundingSphere boundingSphere = new BoundingSphere(-1, 2, 3, 4);
39      assertFalse(boundingSphere.isValid());
40    }
41  
42    @Test
43    public void isValidKNearestNeighborFilter_valid() {
44      KNearestNeighbor nearestNeighbor = new KNearestNeighbor(1, 2, 3, 4);
45      assertTrue(nearestNeighbor.isValid());
46    }
47  
48    @Test
49    public void isValidKNearestNeighborFilter_notValid() {
50      KNearestNeighbor nearestNeighbor = new KNearestNeighbor(-1, 2, 3, 4);
51      assertFalse(nearestNeighbor.isValid());
52    }
53  
54    @Test
55    public void setAxisAlignedBounding_setsValues() {
56      AxisAlignedBoundingBox axisAlignedBoundingBox = new AxisAlignedBoundingBox(1, 2, 3, 4, 5, 6);
57      assertEquals(axisAlignedBoundingBox.getMinX(), 1);
58      assertEquals(axisAlignedBoundingBox.getMinY(), 2);
59      assertEquals(axisAlignedBoundingBox.getMinZ(), 3);
60      assertEquals(axisAlignedBoundingBox.getMaxX(), 4);
61      assertEquals(axisAlignedBoundingBox.getMaxY(), 5);
62      assertEquals(axisAlignedBoundingBox.getMaxZ(), 6);
63    }
64  
65    @Test
66    public void setBoundingSphere_setValues() {
67      BoundingSphere boundingSphere = new BoundingSphere(1, 2, 3, 4);
68      assertEquals(boundingSphere.getRadius(), 1);
69      assertEquals(boundingSphere.getCenterX(), 2);
70      assertEquals(boundingSphere.getCenterY(), 3);
71      assertEquals(boundingSphere.getCenterZ(), 4);
72    }
73  
74    @Test
75    public void setKNN_setValues() {
76      KNearestNeighbor kNearestNeighbor = new KNearestNeighbor(1, 2, 3, 4);
77      assertEquals(kNearestNeighbor.getK(), 1);
78      assertEquals(kNearestNeighbor.getX(), 2);
79      assertEquals(kNearestNeighbor.getY(), 3);
80      assertEquals(kNearestNeighbor.getZ(), 4);
81    }
82  }