1   /* Copyright 2022-2025 Romain Serra
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.orekit.forces;
19  
20  import org.hipparchus.CalculusFieldElement;
21  import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
22  import org.hipparchus.geometry.euclidean.threed.Vector3D;
23  import org.hipparchus.util.Binary64;
24  import org.junit.jupiter.api.Test;
25  import org.orekit.propagation.FieldSpacecraftState;
26  import org.orekit.propagation.SpacecraftState;
27  import org.orekit.utils.ParameterDriver;
28  
29  import java.util.Collections;
30  import java.util.List;
31  
32  import static org.junit.jupiter.api.Assertions.assertEquals;
33  import static org.mockito.Mockito.mock;
34  import static org.mockito.Mockito.when;
35  
36  class ForceModelTest {
37  
38      @Test
39      void testGetMassDerivative() {
40          // GIVEN
41          final SpacecraftState mockedState = mock();
42          final TestForce force = new TestForce();
43          // WHEN
44          final double massDerivative = force.getMassDerivative(mockedState, new double[0]);
45          // THEN
46          @SuppressWarnings("unchecked")
47          final FieldSpacecraftState<Binary64> mockedFieldState = mock();
48          when(mockedFieldState.getMass()).thenReturn(Binary64.ZERO);
49          final Binary64 fieldMassDerivative = force.getMassDerivative(mockedFieldState, null);
50          assertEquals(fieldMassDerivative.getReal(), massDerivative);
51      }
52  
53      private static class TestForce implements ForceModel {
54  
55          @Override
56          public boolean dependsOnPositionOnly() {
57              return false;
58          }
59  
60          @Override
61          public Vector3D acceleration(SpacecraftState s, double[] parameters) {
62              return null;
63          }
64  
65          @Override
66          public <T extends CalculusFieldElement<T>> FieldVector3D<T> acceleration(FieldSpacecraftState<T> s, T[] parameters) {
67              return null;
68          }
69  
70          @Override
71          public List<ParameterDriver> getParametersDrivers() {
72              return Collections.emptyList();
73          }
74      }
75  }