1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.propagation;
18
19 import org.hipparchus.linear.MatrixUtils;
20 import org.hipparchus.linear.RealMatrix;
21 import org.junit.jupiter.api.Test;
22 import org.mockito.Mockito;
23
24 import static org.junit.jupiter.api.Assertions.*;
25 import static org.mockito.Mockito.mock;
26 import static org.mockito.Mockito.when;
27
28 class AbstractMatricesHarvesterTest {
29
30 @Test
31 void testToArray() {
32
33 final int stateDimension = 7;
34 final AbstractMatricesHarvester moockedHarvester = mock();
35 when(moockedHarvester.toArray(Mockito.any())).thenCallRealMethod();
36 when(moockedHarvester.toSquareMatrix(Mockito.any())).thenCallRealMethod();
37 when(moockedHarvester.getStateDimension()).thenReturn(stateDimension);
38 final RealMatrix expectedMatrix = MatrixUtils.createRealIdentityMatrix(stateDimension);
39 expectedMatrix.setEntry(0, 2, 42);
40 expectedMatrix.setEntry(1, 2, 42);
41 expectedMatrix.setEntry(4, 3, 42);
42
43 final double[] array = moockedHarvester.toArray(expectedMatrix.getData());
44 final RealMatrix actualMatrix = moockedHarvester.toSquareMatrix(array);
45
46 assertEquals(0., actualMatrix.subtract(expectedMatrix).getNorm1());
47 }
48 }