1   /*
2    * Licensed to the Hipparchus project under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF 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.propagation.events;
19  
20  import org.junit.jupiter.api.Assertions;
21  import org.junit.jupiter.api.Test;
22  import org.orekit.propagation.Propagator;
23  import org.orekit.propagation.analytical.KeplerianPropagator;
24  import org.orekit.propagation.events.handlers.RecordAndContinue;
25  
26  
27  /**
28   * Test event handling on a {@link KeplerianPropagator}.
29   *
30   * @author Evan Ward
31   */
32  public class CloseEventsAnalyticalKeplerianTest extends CloseEventsAbstractTest {
33  
34      @Override
35      public Propagator getPropagator(double stepSize) {
36          return new KeplerianPropagator(initialOrbit);
37      }
38  
39      /* Extra test for analytic propagator that take big steps. */
40  
41      /** Test Analytic propagators take big steps. #830 */
42      @Test
43      public void testBigStep() {
44          // setup
45          Propagator propagator = getPropagator(1e100);
46          propagator.setStepHandler(interpolator -> {});
47          double period = 2 * initialOrbit.getKeplerianPeriod();
48  
49          RecordAndContinue handler = new RecordAndContinue();
50          TimeDetector detector = new TimeDetector(1, period - 1)
51                  .withHandler(handler)
52                  .withMaxCheck(1e100)
53                  .withThreshold(1);
54          propagator.addEventDetector(detector);
55  
56          // action
57          propagator.propagate(epoch.shiftedBy(period));
58  
59          // verify no events
60          Assertions.assertEquals(0, handler.getEvents().size());
61      }
62  
63      /** Test Analytic propagators take big steps. #830 */
64      @Test
65      public void testBigStepReverse() {
66          // setup
67          Propagator propagator = getPropagator(1e100);
68          propagator.setStepHandler(interpolator -> {});
69          double period = -2 * initialOrbit.getKeplerianPeriod();
70  
71          RecordAndContinue handler = new RecordAndContinue();
72          TimeDetector detector = new TimeDetector(-1, period + 1)
73                  .withHandler(handler)
74                  .withMaxCheck(1e100)
75                  .withThreshold(1);
76          propagator.addEventDetector(detector);
77  
78          // action
79          propagator.propagate(epoch.shiftedBy(period));
80  
81          // verify no events
82          Assertions.assertEquals(0, handler.getEvents().size());
83      }
84  
85  }