1   /* Copyright 2002-2025 CS GROUP
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.files.ccsds.ndm.adm.apm;
18  
19  import org.hipparchus.geometry.euclidean.threed.RotationOrder;
20  import org.junit.jupiter.api.Test;
21  import org.orekit.errors.OrekitException;
22  import org.orekit.errors.OrekitMessages;
23  
24  import static org.junit.jupiter.api.Assertions.assertEquals;
25  import static org.junit.jupiter.api.Assertions.assertThrows;
26  
27  class EulerTest {
28  
29      @Test
30      // This test was added to increase overall conditions coverage in the scope of issue 1453
31      public void testIssue1453() {
32          // GIVEN
33          final Euler euler = new Euler();
34  
35          final String KEY_ANGLES_V1 = "{X|Y|Z}_ANGLE";
36          final String KEY_ANGLES_V2 = "ANGLE_{1|2|3}";
37  
38          final String KEY_RATES_V1 = "{X|Y|Z}_RATES";
39          final String KEY_RATES_V2 = "ANGLE_{1|2|3}_DOT";
40  
41          // WHEN & THEN
42          // Assert validation method
43          // Assert thrown exceptions for empty angles depending on version
44          assertThrows(OrekitException.class, () -> euler.validate(1),
45                       String.format(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY.getSourceString(), KEY_ANGLES_V1));
46          assertThrows(OrekitException.class, () -> euler.validate(2),
47                       String.format(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY.getSourceString(), KEY_RATES_V2));
48  
49          // Assert thrown exceptions when no angles and rates are defined depending on version
50          assertThrows(OrekitException.class, () -> euler.validate(1),
51                       String.format(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY.getSourceString(), KEY_RATES_V1 + "/" + KEY_RATES_V1));
52          assertThrows(OrekitException.class, () -> euler.validate(2),
53                       String.format(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY.getSourceString(), KEY_ANGLES_V2));
54  
55          // Assert thrown exceptions for empty rates depending on version
56          euler.setIndexedRotationAngle(0, 10);
57          euler.setIndexedRotationAngle(1, 11);
58          euler.setIndexedRotationAngle(2, 12);
59  
60          assertThrows(OrekitException.class, () -> euler.validate(1),
61                       String.format(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY.getSourceString(), KEY_RATES_V1));
62          assertThrows(OrekitException.class, () -> euler.validate(2),
63                       String.format(OrekitMessages.UNINITIALIZED_VALUE_FOR_KEY.getSourceString(), KEY_RATES_V2));
64  
65          // Assert labeled rotation rate setting method
66          euler.setEulerRotSeq(RotationOrder.XYZ);
67          euler.setIndexedRotationRate(0,Double.NaN);
68          euler.setIndexedRotationRate(1,-2);
69          euler.setIndexedRotationRate(2,-3);
70  
71          euler.setLabeledRotationRate('A', 1);
72          euler.setLabeledRotationRate('X', 4);
73          euler.setLabeledRotationRate('X', 5);
74  
75          assertEquals(4, euler.getRotationRates()[0]);
76          assertEquals(-2, euler.getRotationRates()[1]);
77          assertEquals(-3, euler.getRotationRates()[2]);
78      }
79  
80  }