Search in sources :

Example 1 with Angle

use of org.spongepowered.api.util.Angle in project SpongeCommon by SpongePowered.

the class TransformationTest method testRotatingAroundOrigin180DegreesAroundYAxisWithTwoSteps.

@ParameterizedTest
@MethodSource("testRotatingAroundOrigin180DegreesAroundYAxis")
void testRotatingAroundOrigin180DegreesAroundYAxisWithTwoSteps(final Vector3d original, final Vector3d expected) {
    // and this rotation
    final Rotation mockRotation = Mockito.mock(Rotation.class, Mockito.withSettings().defaultAnswer(Mockito.CALLS_REAL_METHODS));
    Mockito.when(mockRotation.angle()).thenReturn(Angle.fromDegrees(90));
    Mockito.when(mockRotation.and(Mockito.any(Rotation.class))).thenAnswer((Answer<Rotation>) invocation -> {
        final Rotation rotation = invocation.getArgument(0);
        final Rotation newMock = Mockito.mock(Rotation.class, Mockito.withSettings().defaultAnswer(Mockito.CALLS_REAL_METHODS));
        Mockito.when(newMock.angle()).thenAnswer((Answer<Angle>) x -> Angle.fromDegrees(rotation.angle().degrees() + 90));
        return newMock;
    });
    final Transformation transformation = this.performRotationTest(mockRotation, original, expected, Vector3d.ZERO, 2);
    Assertions.assertEquals(180, transformation.rotation().angle().degrees(), "Did not get expected angle.");
}
Also used : Transformation(org.spongepowered.api.util.transformation.Transformation) Mockito(org.mockito.Mockito) Answer(org.mockito.stubbing.Answer) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Rotation(org.spongepowered.api.util.rotation.Rotation) Stream(java.util.stream.Stream) Vector3d(org.spongepowered.math.vector.Vector3d) Assertions(org.junit.jupiter.api.Assertions) Axis(org.spongepowered.api.util.Axis) Arguments(org.junit.jupiter.params.provider.Arguments) MethodSource(org.junit.jupiter.params.provider.MethodSource) Angle(org.spongepowered.api.util.Angle) Answer(org.mockito.stubbing.Answer) Transformation(org.spongepowered.api.util.transformation.Transformation) Rotation(org.spongepowered.api.util.rotation.Rotation) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

Stream (java.util.stream.Stream)1 Assertions (org.junit.jupiter.api.Assertions)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 Arguments (org.junit.jupiter.params.provider.Arguments)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 Mockito (org.mockito.Mockito)1 Answer (org.mockito.stubbing.Answer)1 Angle (org.spongepowered.api.util.Angle)1 Axis (org.spongepowered.api.util.Axis)1 Rotation (org.spongepowered.api.util.rotation.Rotation)1 Transformation (org.spongepowered.api.util.transformation.Transformation)1 Vector3d (org.spongepowered.math.vector.Vector3d)1