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  package org.orekit.forces.gravity.potential;
18  
19  import org.junit.jupiter.api.Assertions;
20  import org.junit.jupiter.api.Test;
21  import org.orekit.time.AbsoluteDate;
22  
23  class UnnormalizedSphericalHarmonicsProviderTest {
24  
25      @Test
26      void testGetUnnormalizedC20() {
27          // GIVEN
28          final double expectedC20 = 1.;
29          final TestUnnormalizedProvider testUnnormalizedProvider = new TestUnnormalizedProvider(expectedC20);
30          final AbsoluteDate date = AbsoluteDate.ARBITRARY_EPOCH;
31          // WHEN
32          final double actualC20 = testUnnormalizedProvider.getUnnormalizedC20(date);
33          // THEN
34          Assertions.assertEquals(expectedC20, actualC20, 0.);
35      }
36  
37      private static class TestUnnormalizedProvider implements UnnormalizedSphericalHarmonicsProvider {
38  
39          private final double c20;
40  
41          TestUnnormalizedProvider(final double c20) {
42              this.c20 = c20;
43          }
44  
45          @Override
46          public int getMaxDegree() {
47              return 2;
48          }
49  
50          @Override
51          public int getMaxOrder() {
52              return 0;
53          }
54  
55          @Override
56          public double getMu() {
57              return 0;
58          }
59  
60          @Override
61          public double getAe() {
62              return 0;
63          }
64  
65          @Override
66          public AbsoluteDate getReferenceDate() {
67              return null;
68          }
69  
70          @Override
71          public TideSystem getTideSystem() {
72              return null;
73          }
74  
75          @Override
76          public UnnormalizedSphericalHarmonics onDate(AbsoluteDate date) {
77              return new UnnormalizedSphericalHarmonics() {
78                  @Override
79                  public double getUnnormalizedCnm(int n, int m) {
80                      if ((n == 2) && (m == 0)) {
81                          return c20;
82                      }
83                      return 0;
84                  }
85  
86                  @Override
87                  public double getUnnormalizedSnm(int n, int m) {
88                      return 0;
89                  }
90  
91                  @Override
92                  public AbsoluteDate getDate() {
93                      return null;
94                  }
95              };
96          }
97      }
98  
99  }