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.hipparchus.complex.Complex;
20 import org.hipparchus.complex.ComplexField;
21 import org.junit.jupiter.api.Assertions;
22 import org.junit.jupiter.api.Test;
23 import org.mockito.Mockito;
24 import org.orekit.propagation.FieldSpacecraftState;
25 import org.orekit.propagation.events.handlers.FieldEventHandler;
26 import org.orekit.propagation.events.intervals.FieldAdaptableInterval;
27
28 class FieldAbstractDetectorTest {
29
30 @Test
31 void testWithDetectionSettings() {
32
33 final ComplexField field = ComplexField.getInstance();
34 final FieldEventDetectionSettings<Complex> settings = new FieldEventDetectionSettings<>(field,
35 EventDetectionSettings.getDefaultEventDetectionSettings());
36 final TestFieldDetector testDetector = new TestFieldDetector(settings, null);
37 final FieldAdaptableInterval mockedInterval = Mockito.mock(FieldAdaptableInterval.class);
38 final FieldEventDetectionSettings<Complex> expectedSettings = new FieldEventDetectionSettings<>(mockedInterval,
39 Complex.ONE, 100);
40
41 final TestFieldDetector newDetector = testDetector.withDetectionSettings(expectedSettings);
42
43 Assertions.assertEquals(mockedInterval, newDetector.getDetectionSettings().getMaxCheckInterval());
44 Assertions.assertEquals(expectedSettings.getThreshold(), newDetector.getDetectionSettings().getThreshold());
45 Assertions.assertEquals(expectedSettings.getMaxIterationCount(), newDetector.getDetectionSettings().getMaxIterationCount());
46 }
47
48 private static class TestFieldDetector extends FieldAbstractDetector<TestFieldDetector, Complex> {
49
50 protected TestFieldDetector(FieldEventDetectionSettings<Complex> detectionSettings, FieldEventHandler<Complex> handler) {
51 super(detectionSettings, handler);
52 }
53
54 @Override
55 protected TestFieldDetector create(FieldEventDetectionSettings<Complex> detectionSettings, FieldEventHandler<Complex> newHandler) {
56 return new TestFieldDetector(detectionSettings, newHandler);
57 }
58
59 @Override
60 public Complex g(FieldSpacecraftState<Complex> s) {
61 return null;
62 }
63 }
64 }