use of au.gov.asd.tac.constellation.utilities.camera.Camera in project constellation by constellation-app.
the class CameraIOProviderNGTest method testReadObject.
/**
* Test of readObject method, of class CameraIOProvider.
*/
@Test
public void testReadObject() throws Exception {
System.out.println("CameraIOProviderNGTest.testReadObject");
// Create argument captors
ArgumentCaptor<Integer> captorAtributeId = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Integer> captorElementId = ArgumentCaptor.forClass(Integer.class);
ArgumentCaptor<Camera> captorCamera = ArgumentCaptor.forClass(Camera.class);
// Call method under test with JsonNode.isNull=true and show nothing happens
resetMocking();
when(mockJsonNode.isNull()).thenReturn(true);
instance.readObject(attributeId, elementId, mockJsonNode, mockGraphWriteMethods, null, null, null, null);
Mockito.verify(mockJsonNode, times(0)).hasNonNull(anyString());
// Call method under test with JsonNode.isNull=true and show nothing happens
resetMocking();
Camera expected = new Camera();
expected.setVisibilityLow(0.0f);
expected.setVisibilityHigh(1.0f);
expected.setMixRatio(2);
expected.lookAtEye.set(0.0f, 0.1f, 0.2f);
expected.lookAtCentre.set(1.0f, 1.1f, 1.2f);
expected.lookAtUp.set(2.0f, 2.1f, 2.2f);
expected.lookAtRotation.set(3.0f, 3.1f, 3.2f);
expected.lookAtPreviousEye.set(4.0f, 4.1f, 4.2f);
expected.lookAtPreviousCentre.set(5.0f, 5.1f, 5.2f);
expected.lookAtPreviousUp.set(6.0f, 6.1f, 6.2f);
expected.lookAtPreviousRotation.set(7.0f, 7.1f, 7.2f);
Frame objFrame = new Frame();
objFrame.setOrigin(new Vector3f(0.0f, 0.1f, 0.2f));
objFrame.setForwardVector(new Vector3f(1.0f, 1.1f, 1.2f));
objFrame.setUpVector(new Vector3f(2.0f, 2.1f, 2.2f));
expected.setObjectFrame(objFrame);
expected.boundingBox.set(new Vector3f(0.0f, 0.1f, 0.2f), new Vector3f(1.0f, 1.1f, 1.2f), new Vector3f(2.0f, 2.1f, 2.2f), new Vector3f(3.0f, 3.1f, 3.2f));
ObjectMapper mapper = new ObjectMapper();
when(mockJsonNode.isNull()).thenReturn(false);
final JsonNode testNode = mapper.readTree("{\"look_at_eye\": [0.0, 0.1, 0.2],\"look_at_centre\": [1.0, 1.1, 1.2],\"look_at_up\": [2.0, 2.1, 2.2],\"look_at_rotation\": [3.0, 3.1, 3.2],\"look_at_previous_eye\": [4.0, 4.1, 4.2],\"look_at_previous_centre\": [5.0, 5.1, 5.2],\"look_at_previous_up\": [6.0, 6.1, 6.2],\"look_at_previous_rotation\": [7.0, 7.1, 7.2],\"bounding_box\": {\"is_empty\": false, \"min\": [0.0, 0.1, 0.2], \"max\": [1.0, 1.1, 1.2], \"min2\": [2.0, 2.1, 2.2], \"max2\": [3.0, 3.1, 3.2]},\"frame\": {\"origin\": [0.0, 0.1, 0.2], \"forward\": [1.0, 1.1, 1.2], \"up\": [2.0, 2.1, 2.2]}, \"visibility_low\": 0.0, \"visibility_high\": 1.0, \"mix_ratio\": 2}");
instance.readObject(attributeId, elementId, testNode, mockGraphWriteMethods, null, null, null, null);
Mockito.verify(mockGraphWriteMethods, times(1)).setObjectValue(captorAtributeId.capture(), captorElementId.capture(), captorCamera.capture());
assertEquals((int) captorAtributeId.getValue(), attributeId);
assertEquals((int) captorElementId.getValue(), elementId);
assertEquals(expected.areSame(captorCamera.getValue()), true);
}
use of au.gov.asd.tac.constellation.utilities.camera.Camera in project constellation by constellation-app.
the class CameraAttributeDescriptionNGTest method testConvertFromObject.
/**
* Test of convertFromObject method, of class CameraAttributeDescription.
*/
@Test
public void testConvertFromObject() {
System.out.println("convertFromObject");
final CameraAttributeDescription instance = new CameraAttributeDescription();
final Object nullResult = instance.convertFromObject(null);
assertNull(nullResult);
final Object stringResult = instance.convertFromObject("");
assertTrue(stringResult instanceof Camera);
final Camera resultCam = (Camera) stringResult;
assertTrue(resultCam.areSame(new Camera()));
final Object otherResult = instance.convertFromObject(42);
// should return itself
assertEquals(otherResult, 42);
}
Aggregations