1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.propagation.events;
18
19 import org.junit.jupiter.api.Assertions;
20 import org.junit.jupiter.api.Test;
21 import org.mockito.Mockito;
22 import org.orekit.propagation.SpacecraftState;
23 import org.orekit.propagation.events.handlers.EventHandler;
24 import org.orekit.propagation.events.intervals.AdaptableInterval;
25
26 class AbstractDetectorTest {
27
28 @Test
29 void testWithDetectionSettings() {
30
31 final EventDetectionSettings settings = EventDetectionSettings.getDefaultEventDetectionSettings();
32 final TestDetector testDetector = new TestDetector(settings, null);
33 final AdaptableInterval mockedInterval = Mockito.mock(AdaptableInterval.class);
34 final EventDetectionSettings expectedSettings = new EventDetectionSettings(mockedInterval, 10., 100);
35
36 final TestDetector newDetector = testDetector.withDetectionSettings(expectedSettings);
37
38 Assertions.assertEquals(mockedInterval, newDetector.getDetectionSettings().getMaxCheckInterval());
39 Assertions.assertEquals(expectedSettings.getThreshold(), newDetector.getDetectionSettings().getThreshold());
40 Assertions.assertEquals(expectedSettings.getMaxIterationCount(), newDetector.getDetectionSettings().getMaxIterationCount());
41 }
42
43 private static class TestDetector extends AbstractDetector<TestDetector> {
44
45 protected TestDetector(EventDetectionSettings eventDetectionSettings, EventHandler handler) {
46 super(eventDetectionSettings, handler);
47 }
48
49 @Override
50 protected TestDetector create(EventDetectionSettings detectionSettings, EventHandler newHandler) {
51 return new TestDetector(detectionSettings, newHandler);
52 }
53
54 @Override
55 public double g(SpacecraftState s) {
56 return 0;
57 }
58 }
59
60 }