1   /* Copyright 2002-2022 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.definitions;
18  
19  import java.util.Arrays;
20  
21  import org.junit.Assert;
22  import org.junit.Before;
23  import org.junit.Test;
24  import org.orekit.Utils;
25  import org.orekit.data.DataContext;
26  import org.orekit.utils.IERSConventions;
27  
28  
29  public class FacadeFrameTest {
30  
31      @Test
32      public void testMapCelestial() {
33          for (CelestialBodyFrame cbf : CelestialBodyFrame.values()) {
34              FrameFacade ff = FrameFacade.parse(cbf.name(),
35                                                 IERSConventions.IERS_2010, true, DataContext.getDefault(),
36                                                 true, true, true);
37              Assert.assertSame(cbf, ff.asCelestialBodyFrame());
38              Assert.assertNull(ff.asOrbitRelativeFrame());
39              Assert.assertNull(ff.asSpacecraftBodyFrame());
40          }
41      }
42  
43      @Test
44      public void testMapLOF() {
45          for (OrbitRelativeFrame orf : OrbitRelativeFrame.values()) {
46              FrameFacade ff = FrameFacade.parse(orf.name(),
47                                                 IERSConventions.IERS_2010, true, DataContext.getDefault(),
48                                                 true, true, true);
49              Assert.assertNull(ff.asCelestialBodyFrame());
50              Assert.assertSame(orf, ff.asOrbitRelativeFrame());
51              Assert.assertNull(ff.asSpacecraftBodyFrame());
52          }
53      }
54  
55      @Test
56      public void testMapSpacecraft() {
57          for (SpacecraftBodyFrame.BaseEquipment be : SpacecraftBodyFrame.BaseEquipment.values()) {
58              for (String label : Arrays.asList("1", "2", "A", "B")) {
59                  SpacecraftBodyFrame sbf = new SpacecraftBodyFrame(be, label);
60                  FrameFacade ff = FrameFacade.parse(sbf.toString(),
61                                                     IERSConventions.IERS_2010, true, DataContext.getDefault(),
62                                                     true, true, true);
63              Assert.assertNull(ff.asCelestialBodyFrame());
64              Assert.assertNull(ff.asOrbitRelativeFrame());
65              Assert.assertEquals(be,    ff.asSpacecraftBodyFrame().getBaseEquipment());
66              Assert.assertEquals(label, ff.asSpacecraftBodyFrame().getLabel());
67              }
68          }
69      }
70  
71      @Test
72      public void testUnknownFrame() {
73          final String name = "unknown";
74          FrameFacade ff = FrameFacade.parse(name,
75                                             IERSConventions.IERS_2010, true, DataContext.getDefault(),
76                                             true, true, true);
77          Assert.assertNull(ff.asFrame());
78          Assert.assertNull(ff.asCelestialBodyFrame());
79          Assert.assertNull(ff.asOrbitRelativeFrame());
80          Assert.assertNull(ff.asSpacecraftBodyFrame());
81          Assert.assertEquals(name, ff.getName());
82      }
83  
84      @Before
85      public void setUp() {
86          Utils.setDataRoot("regular-data");
87      }
88  
89  }