Skip to content

Commit

Permalink
Added unit test for DetectedObjectInteraction
Browse files Browse the repository at this point in the history
Moved unit tests for mosiac objects into object lib
  • Loading branch information
paulbourelly999 committed Jul 28, 2023
1 parent c699981 commit d552372
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.eclipse.mosaic.interactions.detector;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

import org.eclipse.mosaic.lib.geo.CartesianPoint;
import org.eclipse.mosaic.lib.math.Vector3d;
import org.eclipse.mosaic.lib.objects.detector.DetectedObject;
import org.eclipse.mosaic.lib.objects.detector.DetectionType;
import org.eclipse.mosaic.lib.objects.detector.Size;
import org.junit.Before;
import org.junit.Test;

public class DetectedObjectInteractionTest {

private DetectedObjectInteraction interaction;
@Before
public void setUp() throws Exception {
interaction = new DetectedObjectInteraction(0, null);
}

@Test
public void testGetterSetterConstructor() {
DetectedObject detectedObject = new DetectedObject(
DetectionType.CAR,
0.7,
"sensor2",
"projection String2",
"Object7",
CartesianPoint.xyz(-1.1, -2, -3.2),
new Vector3d(1, 1, 1),
new Vector3d(.1, .2, .3),
new Size(2, 1, .5));
Double[] covarianceMatrix = new Double[] { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 };
detectedObject.setPositionCovariance(covarianceMatrix);
detectedObject.setVelocityCovariance(covarianceMatrix);
detectedObject.setAngularVelocityCovariance(covarianceMatrix);

interaction.setDetectedObject(detectedObject);

assertEquals(detectedObject, interaction.getDetectedObject());

DetectedObjectInteraction interaction2 = new DetectedObjectInteraction(0, detectedObject);

assertNotEquals(interaction, interaction2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.eclipse.mosaic.interactions.sensor;
package org.eclipse.mosaic.lib.objects.detector;

import static org.junit.Assert.assertEquals;

Expand All @@ -27,7 +27,7 @@

import com.google.gson.Gson;

public class DetectedObjectInteractionTest {
public class DetectedObjectTest {
@Before
public void setUp() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,24 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.eclipse.mosaic.interactions.sensor;
package org.eclipse.mosaic.lib.objects.detector;

import static org.junit.Assert.assertEquals;

import org.eclipse.mosaic.lib.geo.CartesianPoint;
import org.eclipse.mosaic.lib.objects.detector.Detector;
import org.eclipse.mosaic.lib.objects.detector.DetectorType;
import org.eclipse.mosaic.lib.objects.detector.Orientation;
import org.junit.Before;
import org.junit.Test;

import com.google.gson.Gson;

public class SensorRegistrationTest {
public class DetectorTest {
@Before
public void setUp() throws Exception {

}

@Test
public void testSensorRegistrationJsonSerialization() {
public void testDetectorJsonSerialization() {
Detector sensor = new Detector("something", DetectorType.SEMANTIC_LIDAR, new Orientation(23.0, 0, 0),
CartesianPoint.xyz(1, 2, 3));
Gson gson = new Gson();
Expand All @@ -58,7 +55,7 @@ public void testSensorRegistrationJsonSerialization() {
}

@Test
public void testSensorRegistrationJsonDeserialization() {
public void testDetectorJsonDeserialization() {
String predictedSensorJson = "{"
+ "\"sensorId\":\"something\","
+ "\"type\":\"SemanticLidar\","
Expand Down

0 comments on commit d552372

Please sign in to comment.