Commit 0a172779 authored by Luc Maisonobe's avatar Luc Maisonobe
Browse files

Improved test coverage.

parent 40d0e8a3
Pipeline #1052 passed with stages
in 30 minutes and 4 seconds
......@@ -183,14 +183,6 @@ public class CommonMetadata extends OdmMetadata {
this.referenceFrame = referenceFrame;
}
/** Get epoch of reference frame, if not intrinsic to the definition of the
* reference frame.
* @return epoch of reference frame
*/
String getFrameEpochString() {
return frameEpochString;
}
/** Set epoch of reference frame, if not intrinsic to the definition of the
* reference frame.
* @param frameEpochString the epoch of reference frame to be set
......
......@@ -138,36 +138,6 @@ public class OemMetadata extends CommonMetadata {
this.useableStopTime = useableStopTime;
}
/**
* Get the start date of this ephemeris segment.
*
* @return ephemeris segment start date.
*/
public AbsoluteDate getStart() {
// useable start time overrides start time if it is set
final AbsoluteDate start = this.getUseableStartTime();
if (start != null) {
return start;
} else {
return this.getStartTime();
}
}
/**
* Get the stop date of this ephemeris segment.
*
* @return ephemeris segment stop date.
*/
public AbsoluteDate getStop() {
// useable stop time overrides stop time if it is set
final AbsoluteDate stop = this.getUseableStopTime();
if (stop != null) {
return stop;
} else {
return this.getStopTime();
}
}
/** Get the interpolation method to be used.
* @return the interpolation method
*/
......@@ -216,9 +186,7 @@ public class OemMetadata extends CommonMetadata {
// copy object
copy.setObjectName(getObjectName());
copy.setObjectID(getObjectID());
if (getCenter().getName() != null) {
copy.setCenter(getCenter());
}
copy.setCenter(getCenter());
// copy frames
copy.setFrameEpoch(getFrameEpoch());
......
......@@ -1189,8 +1189,7 @@ public class NRLMSISE00 implements Atmosphere {
final Frame frame) {
// check if data are available :
final AbsoluteDate dateD = date.toAbsoluteDate();
if (dateD.compareTo(inputParams.getMaxDate()) > 0 ||
dateD.compareTo(inputParams.getMinDate()) < 0) {
if (!dateD.isBetweenOrEqualTo(inputParams.getMinDate(), inputParams.getMaxDate())) {
throw new OrekitException(OrekitMessages.NO_SOLAR_ACTIVITY_AT_DATE,
dateD, inputParams.getMinDate(), inputParams.getMaxDate());
}
......
......@@ -426,11 +426,11 @@ public class AbsoluteDate
final SumAndResidual sumAndResidual = MathUtils.twoSum(since.offset, elapsedDuration);
if (Double.isInfinite(sumAndResidual.getSum())) {
offset = sumAndResidual.getSum();
epoch = (sumAndResidual.getSum() < 0) ? Long.MIN_VALUE : Long.MAX_VALUE;
epoch = (sumAndResidual.getSum() < 0) ? Long.MIN_VALUE : Long.MAX_VALUE;
} else {
final long dl = (long) FastMath.floor(sumAndResidual.getSum());
offset = (sumAndResidual.getSum() - dl) + sumAndResidual.getResidual();
epoch = since.epoch + dl;
epoch = since.epoch + dl;
}
}
......
......@@ -249,7 +249,7 @@ public class EphemerisWriterTest {
++count;
}
}
assertEquals(79, count);
assertEquals(80, count);
}
......@@ -353,6 +353,7 @@ public class EphemerisWriterTest {
private OemMetadata dummyMetadata() {
OemMetadata metadata = new OemMetadata(4);
metadata.addComment("dummy comment");
metadata.setTimeSystem(TimeSystem.TT);
metadata.setObjectID("9999-999ZZZ");
metadata.setObjectName("transgalactic");
......
......@@ -589,6 +589,24 @@ public class OpmParserTest {
validate6(parser.parseMessage(source));
}
@Test
public void testParseOPM7() {
final String ex = "/ccsds/odm/opm/OPMExample7.txt";
final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
final OpmFile file = new ParserBuilder().buildOpmParser().parseMessage(source);
Frame frame = file.getMetadata().getFrame();
Assert.assertSame(CelestialBodyFactory.getMars().getInertiallyOrientedFrame(), frame);
}
@Test
public void testParseOPM8() {
final String ex = "/ccsds/odm/opm/OPMExample8.txt";
final DataSource source = new DataSource(ex, () -> getClass().getResourceAsStream(ex));
final OpmFile file = new ParserBuilder().buildOpmParser().parseMessage(source);
Frame frame = file.getMetadata().getFrame();
Assert.assertSame(CelestialBodyFactory.getSolarSystemBarycenter().getInertiallyOrientedFrame(), frame);
}
@Test
public void testParseNonStandardUnits() throws URISyntaxException {
// this file is similar to OPMExample6.txt but uses non-standard units
......
......@@ -278,7 +278,9 @@ public class NRLMSISE00Test {
// Run
try {
atm.getDensity(date.shiftedBy(2 * Constants.JULIAN_YEAR), pos, itrf);
atm.getDensity(new FieldAbsoluteDate<>(field, date).shiftedBy(2 * Constants.JULIAN_YEAR),
new FieldVector3D<>(field.getOne(), pos),
itrf);
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertEquals(OrekitMessages.NO_SOLAR_ACTIVITY_AT_DATE, oe.getSpecifier());
......
/* Copyright 2002-2021 CS GROUP
* Licensed to CS GROUP (CS) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* CS licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.orekit.propagation.analytical.tle;
import org.hipparchus.util.Precision;
import org.junit.Assert;
import org.junit.Test;
public class TLEConstantsTest {
@Test
public void testCoverage() {
// this test is specially awkward
// it doesn't really test anything…
// its *sole* purpose is to work around a false positive coverage in SonarQube
Assert.assertTrue(Precision.equals(1.0 / 3.0, TLEConstants.ONE_THIRD, 1));
Assert.assertTrue(Precision.equals(2.0 / 3.0, TLEConstants.TWO_THIRD, 1));
Assert.assertTrue(Precision.equals(6378.135, TLEConstants.EARTH_RADIUS, 1));
Assert.assertTrue(Precision.equals(1.0, TLEConstants.NORMALIZED_EQUATORIAL_RADIUS, 1));
Assert.assertTrue(Precision.equals(1440.0, TLEConstants.MINUTES_PER_DAY, 1));
Assert.assertTrue(Precision.equals(0.0743669161331734132, TLEConstants.XKE, 1));
Assert.assertTrue(Precision.equals(-2.53881e-6, TLEConstants.XJ3, 1));
Assert.assertTrue(Precision.equals(1.082616e-3, TLEConstants.XJ2, 1));
Assert.assertTrue(Precision.equals(-1.65597e-6, TLEConstants.XJ4, 1));
Assert.assertTrue(Precision.equals(0.5 * TLEConstants.XJ2, TLEConstants.CK2, 1));
Assert.assertTrue(Precision.equals(-0.375 * TLEConstants.XJ4, TLEConstants.CK4, 1));
Assert.assertTrue(Precision.equals(1. + 78. / TLEConstants.EARTH_RADIUS, TLEConstants.S, 1));
Assert.assertTrue(Precision.equals(1.880279159015270643865e-9, TLEConstants.QOMS2T, 1));
Assert.assertTrue(Precision.equals(-TLEConstants.XJ3 / TLEConstants.CK2, TLEConstants.A3OVK2, 1));
Assert.assertTrue(Precision.equals(1.19459E-5, TLEConstants.ZNS, 1));
Assert.assertTrue(Precision.equals(0.01675, TLEConstants.ZES, 1));
Assert.assertTrue(Precision.equals(1.5835218E-4, TLEConstants.ZNL, 1));
Assert.assertTrue(Precision.equals(0.05490, TLEConstants.ZEL, 1));
Assert.assertTrue(Precision.equals(4.3752691E-3, TLEConstants.THDT, 1));
Assert.assertTrue(Precision.equals(2.9864797E-6, TLEConstants.C1SS, 1));
Assert.assertTrue(Precision.equals(4.7968065E-7, TLEConstants.C1L, 1));
Assert.assertTrue(Precision.equals(1.7891679E-6, TLEConstants.ROOT22, 1));
Assert.assertTrue(Precision.equals(3.7393792E-7, TLEConstants.ROOT32, 1));
Assert.assertTrue(Precision.equals(7.3636953E-9, TLEConstants.ROOT44, 1));
Assert.assertTrue(Precision.equals(1.1428639E-7, TLEConstants.ROOT52, 1));
Assert.assertTrue(Precision.equals(2.1765803E-9, TLEConstants.ROOT54, 1));
Assert.assertTrue(Precision.equals(1.7891679E-6, TLEConstants.Q22, 1));
Assert.assertTrue(Precision.equals(2.1460748E-6, TLEConstants.Q31, 1));
Assert.assertTrue(Precision.equals(2.2123015E-7, TLEConstants.Q33, 1));
Assert.assertTrue(Precision.equals(0.99139134268488593, TLEConstants.C_FASX2, 1));
Assert.assertTrue(Precision.equals(0.13093206501640101, TLEConstants.S_FASX2, 1));
Assert.assertTrue(Precision.equals(0.87051638752972937, TLEConstants.C_2FASX4, 1));
Assert.assertTrue(Precision.equals(-0.49213943048915526, TLEConstants.S_2FASX4, 1));
Assert.assertTrue(Precision.equals(0.43258117585763334, TLEConstants.C_3FASX6, 1));
Assert.assertTrue(Precision.equals(0.90159499016666422, TLEConstants.S_3FASX6, 1));
Assert.assertTrue(Precision.equals(0.87051638752972937, TLEConstants.C_G22, 1));
Assert.assertTrue(Precision.equals(-0.49213943048915526, TLEConstants.S_G22, 1));
Assert.assertTrue(Precision.equals(0.57972190187001149, TLEConstants.C_G32, 1));
Assert.assertTrue(Precision.equals(0.81481440616389245, TLEConstants.S_G32, 1));
Assert.assertTrue(Precision.equals(-0.22866241528815548, TLEConstants.C_G44, 1));
Assert.assertTrue(Precision.equals(0.97350577801807991, TLEConstants.S_G44, 1));
Assert.assertTrue(Precision.equals(0.49684831179884198, TLEConstants.C_G52, 1));
Assert.assertTrue(Precision.equals(0.86783740128127729, TLEConstants.S_G52, 1));
Assert.assertTrue(Precision.equals(-0.29695209575316894, TLEConstants.C_G54, 1));
Assert.assertTrue(Precision.equals(-0.95489237761529999, TLEConstants.S_G54, 1));
}
}
\ No newline at end of file
......@@ -656,6 +656,12 @@ public class AbsoluteDateTest {
Assert.assertEquals(true, AbsoluteDate.PAST_INFINITY.equals(AbsoluteDate.PAST_INFINITY));
Assert.assertEquals(false, AbsoluteDate.PAST_INFINITY.equals(AbsoluteDate.FUTURE_INFINITY));
Assert.assertEquals(false, AbsoluteDate.FUTURE_INFINITY.equals(AbsoluteDate.PAST_INFINITY));
Assert.assertTrue(AbsoluteDate.J2000_EPOCH.durationFrom(AbsoluteDate.ARBITRARY_EPOCH.shiftedBy(Double.NEGATIVE_INFINITY))
== Double.POSITIVE_INFINITY);
Assert.assertTrue(AbsoluteDate.J2000_EPOCH.durationFrom(AbsoluteDate.ARBITRARY_EPOCH.shiftedBy(Double.POSITIVE_INFINITY))
== Double.NEGATIVE_INFINITY);
}
@Test
......
......@@ -974,6 +974,18 @@ public class FieldAbsoluteDateTest {
Assert.assertTrue(Double.isInfinite(FieldAbsoluteDate.getPastInfinity(field).durationFrom(FieldAbsoluteDate.getJ2000Epoch(field)).getReal()));
Assert.assertEquals("5881610-07-11T23:59:59.999", FieldAbsoluteDate.getFutureInfinity(field).toString());
Assert.assertEquals("-5877490-03-03T00:00:00.000", FieldAbsoluteDate.getPastInfinity(field).toString());
final FieldAbsoluteDate<T> j2000 = FieldAbsoluteDate.getJ2000Epoch(field);
final FieldAbsoluteDate<T> arbitrary = FieldAbsoluteDate.getArbitraryEpoch(field);
Assert.assertTrue(j2000.durationFrom(arbitrary.shiftedBy(Double.NEGATIVE_INFINITY)).getReal()
== Double.POSITIVE_INFINITY);
Assert.assertTrue(j2000.durationFrom(arbitrary.shiftedBy(Double.POSITIVE_INFINITY)).getReal()
== Double.NEGATIVE_INFINITY);
Assert.assertTrue(j2000.durationFrom(arbitrary.shiftedBy(field.getZero().add(Double.NEGATIVE_INFINITY))).getReal()
== Double.POSITIVE_INFINITY);
Assert.assertTrue(j2000.durationFrom(arbitrary.shiftedBy(field.getZero().add(Double.POSITIVE_INFINITY))).getReal()
== Double.NEGATIVE_INFINITY);
}
private <T extends RealFieldElement<T>> void doTestAccuracy(final Field<T> field) {
......
CCSDS_OPM_VERS = 3.0
CREATION_DATE = 1998-11-06T09:23:57
ORIGINATOR = JAXA
COMMENT GEOCENTRIC, CARTESIAN, EARTH FIXED
OBJECT_NAME = GODZILLA 5
OBJECT_ID = 1998-999A
CENTER_NAME = MARS
REF_FRAME = MCI
TIME_SYSTEM = UTC
EPOCH = 1998-12-18T14:28:15.1172
X = 6503.514000
Y = 1239.647000
Z = -717.490000
X_DOT = -0.873160
Y_DOT = 8.740420
Z_DOT = -4.191076
MASS = 3000.000000
SOLAR_RAD_AREA = 18.770000
SOLAR_RAD_COEFF = 1.000000
DRAG_AREA = 18.770000
DRAG_COEFF = 2.500000
CCSDS_OPM_VERS = 3.0
CREATION_DATE = 1998-11-06T09:23:57
ORIGINATOR = JAXA
COMMENT GEOCENTRIC, CARTESIAN, EARTH FIXED
OBJECT_NAME = GODZILLA 5
OBJECT_ID = 1998-999A
CENTER_NAME = SSB
REF_FRAME = ICRF
TIME_SYSTEM = UTC
EPOCH = 1998-12-18T14:28:15.1172
X = 6503.514000
Y = 1239.647000
Z = -717.490000
X_DOT = -0.873160
Y_DOT = 8.740420
Z_DOT = -4.191076
MASS = 3000.000000
SOLAR_RAD_AREA = 18.770000
SOLAR_RAD_COEFF = 1.000000
DRAG_AREA = 18.770000
DRAG_COEFF = 2.500000
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment