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.propagation.events.handlers;
18
19 import org.hipparchus.ode.events.Action;
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.orekit.frames.FramesFactory;
23 import org.orekit.orbits.KeplerianOrbit;
24 import org.orekit.orbits.PositionAngle;
25 import org.orekit.propagation.SpacecraftState;
26 import org.orekit.propagation.events.EventDetector;
27 import org.orekit.time.AbsoluteDate;
28 import org.orekit.utils.Constants;
29
30 public class StopOnIncreasingTest {
31
32 @Test
33 public void testNoReset() {
34 SpacecraftState s = new SpacecraftState(new KeplerianOrbit(24464560.0, 0.7311, 0.122138, 3.10686, 1.00681,
35 0.048363, PositionAngle.MEAN,
36 FramesFactory.getEME2000(),
37 AbsoluteDate.J2000_EPOCH,
38 Constants.EIGEN5C_EARTH_MU));
39 Assert.assertSame(s, new StopOnIncreasing<EventDetector>().resetState(null, s));
40 }
41
42 @Test
43 public void testIncreasing() {
44 SpacecraftState s = new SpacecraftState(new KeplerianOrbit(24464560.0, 0.7311, 0.122138, 3.10686, 1.00681,
45 0.048363, PositionAngle.MEAN,
46 FramesFactory.getEME2000(),
47 AbsoluteDate.J2000_EPOCH,
48 Constants.EIGEN5C_EARTH_MU));
49 Assert.assertSame(Action.STOP, new StopOnIncreasing<EventDetector>().eventOccurred(s, null, true));
50 }
51
52 @Test
53 public void testDecreasing() {
54 SpacecraftState s = new SpacecraftState(new KeplerianOrbit(24464560.0, 0.7311, 0.122138, 3.10686, 1.00681,
55 0.048363, PositionAngle.MEAN,
56 FramesFactory.getEME2000(),
57 AbsoluteDate.J2000_EPOCH,
58 Constants.EIGEN5C_EARTH_MU));
59 Assert.assertSame(Action.CONTINUE, new StopOnIncreasing<EventDetector>().eventOccurred(s, null, false));
60 }
61
62 }
63