1   /* Copyright 2022-2025 Thales Alenia Space
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.gnss;
18  
19  import org.junit.jupiter.api.Assertions;
20  import org.junit.jupiter.api.Test;
21  
22  public class SatInSystemTest {
23  
24      @Test
25      public void testRegularConstructor() {
26          SatInSystem sis = new SatInSystem(SatelliteSystem.GALILEO, 12);
27          Assertions.assertEquals(SatelliteSystem.GALILEO, sis.getSystem());
28          Assertions.assertEquals(12, sis.getPRN());
29      }
30  
31      @Test
32      public void testAnyPRN() {
33          SatInSystem sis = new SatInSystem(SatelliteSystem.QZSS, SatInSystem.ANY_PRN);
34          Assertions.assertEquals(SatelliteSystem.QZSS, sis.getSystem());
35          Assertions.assertEquals(SatInSystem.ANY_PRN, sis.getPRN());
36      }
37  
38      @Test
39      public void testBeidou() {
40          Assertions.assertEquals(SatelliteSystem.BEIDOU, new SatInSystem("C 7").getSystem());
41          Assertions.assertEquals(7, new SatInSystem("C 7").getPRN());
42      }
43  
44      @Test
45      public void testGalileo() {
46          Assertions.assertEquals(SatelliteSystem.GALILEO, new SatInSystem("E11").getSystem());
47          Assertions.assertEquals(11, new SatInSystem("E11").getPRN());
48      }
49  
50      @Test
51      public void testGlonass() {
52          Assertions.assertEquals(SatelliteSystem.GLONASS, new SatInSystem("R05").getSystem());
53          Assertions.assertEquals(5, new SatInSystem("R05").getPRN());
54      }
55  
56      @Test
57      public void testGps() {
58          Assertions.assertEquals(SatelliteSystem.GPS, new SatInSystem("G01").getSystem());
59          Assertions.assertEquals(1, new SatInSystem("G01").getPRN());
60      }
61  
62      @Test
63      public void testNavIC() {
64          Assertions.assertEquals(SatelliteSystem.NAVIC, new SatInSystem("I14").getSystem());
65          Assertions.assertEquals(14, new SatInSystem("I14").getPRN());
66      }
67  
68      @Test
69      public void testQzss() {
70          Assertions.assertEquals(SatelliteSystem.QZSS, new SatInSystem("J03").getSystem());
71          Assertions.assertEquals(195, new SatInSystem("J03").getPRN());
72      }
73  
74      @Test
75      public void testSbas() {
76          Assertions.assertEquals(SatelliteSystem.SBAS, new SatInSystem("S09").getSystem());
77          Assertions.assertEquals(109, new SatInSystem("S09").getPRN());
78      }
79  
80      @Test
81      public void testUserDefined() {
82          Assertions.assertEquals(SatelliteSystem.USER_DEFINED_K, new SatInSystem("K01").getSystem());
83          Assertions.assertEquals(1, new SatInSystem("K01").getPRN());
84      }
85  
86      @Test
87      public void testParseAny() {
88          Assertions.assertEquals(SatelliteSystem.GALILEO, new SatInSystem("E  ").getSystem());
89          Assertions.assertEquals(SatInSystem.ANY_PRN,     new SatInSystem("E  ").getPRN());
90          Assertions.assertEquals(SatelliteSystem.BEIDOU,  new SatInSystem("C").getSystem());
91          Assertions.assertEquals(SatInSystem.ANY_PRN,     new SatInSystem("C").getPRN());
92      }
93  
94      @Test
95      public void testHashcode() {
96          Assertions.assertEquals(78, new SatInSystem("E11").hashCode());
97      }
98  
99      @Test
100     public void testEquals() {
101         Assertions.assertEquals(new SatInSystem(SatelliteSystem.GALILEO, 11), new SatInSystem("E11"));
102         Assertions.assertNotEquals(new SatInSystem(SatelliteSystem.GALILEO, 12), new SatInSystem("E11"));
103         Assertions.assertNotEquals(new SatInSystem(SatelliteSystem.GPS, 11), new SatInSystem("E11"));
104         Assertions.assertNotEquals(new SatInSystem(SatelliteSystem.GALILEO, 11), "E11");
105     }
106 
107     @Test
108     public void testToString() {
109         Assertions.assertEquals("E01", new SatInSystem(SatelliteSystem.GALILEO, 1).toString());
110         Assertions.assertEquals("E  ", new SatInSystem(SatelliteSystem.GALILEO, SatInSystem.ANY_PRN).toString());
111         Assertions.assertEquals("S10", new SatInSystem(SatelliteSystem.SBAS, 110).toString());
112         Assertions.assertEquals("J07", new SatInSystem(SatelliteSystem.QZSS, 199).toString());
113     }
114 
115 }