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 @SuppressWarnings("unchecked")
32 void testWithDetectionSettings() {
33
34 final ComplexField field = ComplexField.getInstance();
35 final FieldEventDetectionSettings<Complex> settings = new FieldEventDetectionSettings<>(field,
36 EventDetectionSettings.getDefaultEventDetectionSettings());
37 final TestFieldDetector testDetector = new TestFieldDetector(settings, null);
38 final FieldAdaptableInterval mockedInterval = Mockito.mock(FieldAdaptableInterval.class);
39 final FieldEventDetectionSettings<Complex> expectedSettings = new FieldEventDetectionSettings<>(mockedInterval,
40 Complex.ONE, 100);
41
42 final TestFieldDetector newDetector = testDetector.withDetectionSettings(expectedSettings);
43
44 Assertions.assertEquals(mockedInterval, newDetector.getDetectionSettings().getMaxCheckInterval());
45 Assertions.assertEquals(expectedSettings.getThreshold(), newDetector.getDetectionSettings().getThreshold());
46 Assertions.assertEquals(expectedSettings.getMaxIterationCount(), newDetector.getDetectionSettings().getMaxIterationCount());
47 }
48
49 private static class TestFieldDetector extends FieldAbstractDetector<TestFieldDetector, Complex> {
50
51 protected TestFieldDetector(FieldEventDetectionSettings<Complex> detectionSettings, FieldEventHandler<Complex> handler) {
52 super(detectionSettings, handler);
53 }
54
55 @Override
56 protected TestFieldDetector create(FieldEventDetectionSettings<Complex> detectionSettings, FieldEventHandler<Complex> newHandler) {
57 return new TestFieldDetector(detectionSettings, newHandler);
58 }
59
60 @Override
61 public Complex g(FieldSpacecraftState<Complex> s) {
62 return null;
63 }
64 }
65 }