Some more cleaning up

This commit is contained in:
SiboVG 2024-02-25 04:11:37 +01:00
parent 4d597715f4
commit f728357655
137 changed files with 863 additions and 865 deletions

View File

@ -4,12 +4,19 @@ plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java'
id 'checkstyle'
id 'org.javamodularity.moduleplugin' version '1.8.14'
}
java {
modularity.inferModulePath = true
// Must be disabled in order to use the gradle-modules-plugin
modularity.inferModulePath = false
}
/*moduleOptions {
addModules = ['java.scripting']
}*/
// Fetch the build version from the build.properties file
Properties props = new Properties()
try {
props.load(file('./core/src/main/resources/build.properties').newDataInputStream())
@ -28,6 +35,43 @@ allprojects {
}
}
subprojects {
apply plugin: 'java'
apply plugin: "org.javamodularity.moduleplugin"
// Configure the gradle-modules-plugin
modularity {
standardJavaRelease(17) // For targeting Java 17
modularity.patchModule("hamcrest", "hamcrest-2.2.jar")
modularity.patchModule("hamcrest.core", "hamcrest-core-2.2.jar")
modularity.patchModule("hamcrest.library", "hamcrest-library-2.2.jar")
}
test {
useJUnitPlatform()
testLogging {
events 'PASSED', 'FAILED', 'SKIPPED', 'STANDARD_OUT'
stackTraceFilters = []
}
}
dependencies {
// Common dependencies
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.2'
testImplementation group: 'org.hamcrest', name: 'hamcrest-core', version: '2.2'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.2'
//testImplementation group: 'org.hamcrest', name: 'hamcrest-internal', version: '2.2'
//testImplementation group: 'org.hamcrest', name: 'hamcrest-xml', version: '2.2'
testImplementation group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.10.2'
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.10.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.10.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.0'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '5.10.0'
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '5.10.0'
}
}
dependencies {
implementation project(':core')
implementation project(':swing')
@ -38,7 +82,7 @@ dependencies {
//}
jar {
archiveBaseName.set('openrocket')
archiveBaseName.set('OpenRocket')
manifest {
attributes (
@ -49,7 +93,7 @@ jar {
}
shadowJar {
archiveBaseName.set('openrocket')
archiveBaseName.set('OpenRocket')
archiveClassifier.set(null)
}

View File

@ -7,11 +7,10 @@ plugins {
}
java {
modularity.inferModulePath = true
// Must be disabled in order to use the gradle-modules-plugin
modularity.inferModulePath = false
}
group 'info.openrocket.core'
Properties props = new Properties()
try {
props.load(file('./src/main/resources/build.properties').newDataInputStream())
@ -43,13 +42,14 @@ dependencies {
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.5.0'
//implementation group: 'org.slf4j', name: 'logback-classic', version: '2.0.12'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1' // 3.12.0
implementation group: 'com.google.inject', name: 'guice', version: '5.1.0'
implementation group: 'com.google.inject', name: 'guice', version: '7.0.0'
implementation group: 'com.opencsv', name: 'opencsv', version: '5.7.1'
implementation group: 'eu.infomas', name: 'annotation-detector', version: '3.0.5'
implementation group: 'org.graalvm.sdk', name: 'graal-sdk', version: '22.1.0.1' // 22.3.1
implementation group: 'org.graalvm.js', name: 'js-scriptengine', version: '22.1.0.1' // 22.3.1
implementation group: 'org.graalvm.sdk', name: 'graal-sdk', version: '23.0.3'
implementation group: 'org.graalvm.js', name: 'js-scriptengine', version: '23.0.3'
implementation group: 'org.graalvm.js', name: 'js', version: '23.0.3'
//implementation group: 'javax.script', name: 'script-api', version: '1.0-osgi'
implementation group: 'org.graalvm.truffle', name: 'truffle-api', version: '22.1.0.1' // 22.3.1
implementation group: 'org.graalvm.truffle', name: 'truffle-api', version: '23.0.3'
implementation group: 'com.ibm.icu', name: 'icu4j', version: '71.1' // 72.1
implementation group: 'com.sun.istack', name: 'istack-commons-tools', version: '4.1.1' // TODO: Should be gotten rid of?
implementation group: 'com.sun.istack', name: 'istack-commons-runtime', version: '4.1.1' // TODO: Should be gotten rid of?
@ -62,13 +62,6 @@ dependencies {
implementation 'org.eclipse:yasson:1.0.2' // 2.0.1
implementation group: 'javax.activation', name: 'javax.activation-api', version: '1.2.0'
implementation group: 'jakarta.activation', name: 'jakarta.activation-api', version: '2.1.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.3.1' // 5.9.2
testImplementation group: 'org.jmock', name: 'jmock', version: '2.9.0' // 2.12.0
testImplementation group: 'org.jmock', name: 'jmock-junit4', version: '2.9.0' // 2.12.0
testImplementation 'junit:junit:4.12' // 4.3.1 org.junit.jupiter
// testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
// testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
def serializedEnginesPath = './src/main/resources/datafiles/thrustcurves/thrustcurves.ser'

View File

@ -2,6 +2,7 @@ package info.openrocket.core.scripting;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptException;
import java.util.*;
import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine;
@ -29,11 +30,18 @@ public class GraalJSScriptEngineFactory implements ScriptEngineFactory {
public ScriptEngine getScriptEngine() {
// https://github.com/oracle/graaljs/blob/master/docs/user/RunOnJDK.md
// https://github.com/oracle/graaljs/blob/master/docs/user/ScriptEngine.md#setting-options-via-bindings
return GraalJSScriptEngine.create(null,
ScriptEngine engine = GraalJSScriptEngine.create(null,
Context.newBuilder("js")
.allowHostAccess(HostAccess.ALL)
.allowHostClassLookup(s -> true)
.option("js.ecmascript-version", "2021"));
.option("js.ecmascript-version", "2022"));
engine.put("javaObj", new Object());
try {
engine.eval("(javaObj instanceof Java.type('java.lang.Object'));");
} catch (ScriptException e) {
throw new RuntimeException(e);
}
return engine;
}
public String getEngineName() {

View File

@ -1,18 +1,30 @@
module openrocket.core {
open module openrocket.core {
uses javax.script.ScriptEngineFactory;
uses javax.script.ScriptEngine;
uses javax.script.Bindings;
uses javax.script.ScriptContext;
uses info.openrocket.core.optimization.services.OptimizableParameterService;
uses info.openrocket.core.optimization.services.SimulationModifierService;
// Libraries
requires com.google.guice;
requires java.desktop;
requires java.scripting;
requires org.graalvm.js.scriptengine;
requires org.graalvm.sdk;
requires org.graalvm.js;
requires org.graalvm.truffle;
requires transitive de.javagl.obj;
requires com.sun.istack.runtime;
requires jakarta.activation;
requires jakarta.inject;
requires java.prefs;
requires java.xml.bind;
requires transitive eu.infomas.annotation.detector;
requires java.json;
requires org.slf4j;
requires com.opencsv;
requires org.commonmark;
// TODO: I'm a JPMS noob, so I just exported each package. Should really check which ones are actually needed.
exports info.openrocket.core.aerodynamics;
@ -85,5 +97,6 @@ module openrocket.core {
exports info.openrocket.core.util.enums;
exports info.openrocket.core.utils;
opens info.openrocket.core.formatting to com.google.guice;
//opens info.openrocket.core.formatting to com.google.guice;
//opens info.openrocket.core.startup to com.google.guice;
}

View File

@ -1,12 +1,12 @@
package info.openrocket.core.aerodynamics;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import info.openrocket.core.logging.WarningSet;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
@ -35,7 +35,7 @@ public class BarrowmanCalculatorTest {
private static Injector injector;
@BeforeClass
@BeforeAll
public static void setup() {
Module applicationModule = new ServicesForTesting();
Module pluginModule = new PluginModule();
@ -65,10 +65,10 @@ public class BarrowmanCalculatorTest {
Coordinate cp_calc = calc.getCP(config, conditions, warnings);
assertEquals(" Empty rocket CNa value is incorrect:", 0.0, cp_calc.weight, 0.0);
assertEquals(" Empty rocket cp x value is incorrect:", 0.0, cp_calc.x, 0.0);
assertEquals(" Empty rocket cp y value is incorrect:", 0.0, cp_calc.y, 0.0);
assertEquals(" Empty rocket cp z value is incorrect:", 0.0, cp_calc.z, 0.0);
assertEquals(0.0, cp_calc.weight, 0.0, " Empty rocket CNa value is incorrect:");
assertEquals(0.0, cp_calc.x, 0.0, " Empty rocket cp x value is incorrect:");
assertEquals(0.0, cp_calc.y, 0.0, " Empty rocket cp y value is incorrect:");
assertEquals(0.0, cp_calc.z, 0.0, " Empty rocket cp z value is incorrect:");
}
@Test

View File

@ -1,10 +1,10 @@
package info.openrocket.core.aerodynamics;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.logging.WarningSet;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
@ -25,7 +25,7 @@ public class FinSetCalcTest {
private static Injector injector;
@BeforeClass
@BeforeAll
public static void setup() {
Module applicationModule = new ServicesForTesting();
Module pluginModule = new PluginModule();

View File

@ -1,10 +1,10 @@
package info.openrocket.core.aerodynamics;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.logging.WarningSet;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
@ -28,7 +28,7 @@ public class RailButtonCalcTest {
private static Injector injector;
@BeforeClass
@BeforeAll
public static void setup() {
Module applicationModule = new ServicesForTesting();
Module pluginModule = new PluginModule();

View File

@ -1,10 +1,10 @@
package info.openrocket.core.aerodynamics;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.logging.WarningSet;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
@ -27,7 +27,7 @@ public class SymmetricComponentCalcTest {
private static Injector injector;
@BeforeClass
@BeforeAll
public static void setup() {
Module applicationModule = new ServicesForTesting();
Module pluginModule = new PluginModule();

View File

@ -1,10 +1,10 @@
package info.openrocket.core.arch;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/*
* Note: These tests have not been tested on Windows, they might fail there

View File

@ -1,15 +1,15 @@
package info.openrocket.core.communication;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.IOException;
import info.openrocket.core.util.BuildProperties;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class BugReportTest {

View File

@ -1,16 +1,16 @@
package info.openrocket.core.communication;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.Arrays;
import java.util.List;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import javax.json.Json;
import javax.json.JsonArray;

View File

@ -1,11 +1,11 @@
package info.openrocket.core.communication;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class WelcomeInfoTest extends BaseTestCase {

View File

@ -1,11 +1,5 @@
package info.openrocket.core.database;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.Collections;
@ -15,7 +9,12 @@ import info.openrocket.core.motor.Motor;
import info.openrocket.core.motor.ThrustCurveMotor;
import info.openrocket.core.util.Coordinate;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.Test;
public class ThrustCurveMotorSetTest {

View File

@ -4,7 +4,7 @@ import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestDirectoryIterator {

View File

@ -1,6 +1,6 @@
package info.openrocket.core.file.iterator;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import java.io.ByteArrayInputStream;
import java.io.File;
@ -8,7 +8,7 @@ import java.io.InputStream;
import info.openrocket.core.util.Pair;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestFileIterator {

View File

@ -1,8 +1,8 @@
package info.openrocket.core.file.motor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.io.InputStream;
@ -11,7 +11,7 @@ import java.util.List;
import info.openrocket.core.motor.ThrustCurveMotor;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestMotorLoader {

View File

@ -1,10 +1,10 @@
package info.openrocket.core.file.openrocket;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.io.FileFilter;
@ -45,8 +45,8 @@ import info.openrocket.core.util.Coordinate;
import info.openrocket.core.util.TestRockets;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
@ -64,7 +64,7 @@ public class OpenRocketSaverTest {
private static Injector injector;
@BeforeClass
@BeforeAll
public static void setup() {
Module applicationModule = new ServicesForTesting();
Module pluginModule = new PluginModule();

View File

@ -1,10 +1,10 @@
package info.openrocket.core.file.openrocket.importt;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.file.openrocket.OpenRocketSaver;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class DocumentConfigTest extends BaseTestCase {

View File

@ -1,6 +1,6 @@
package info.openrocket.core.file.rasaero.export;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class RASAeroMotorExportTest {
// TODO: check correct name after export

View File

@ -27,8 +27,8 @@ import info.openrocket.core.rocketcomponent.Rocket;
import info.openrocket.core.rocketcomponent.RocketComponent;
import info.openrocket.core.startup.Application;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.BufferedInputStream;
import java.io.File;
@ -40,16 +40,16 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
public class RASAeroSaverTest {
// TODO: export a complex design
// TODO: check recovery
// TODO: check sims (including weights and CG)
@BeforeClass
@BeforeAll
public static void setup() {
Module applicationModule = new ServicesForTesting();

View File

@ -15,13 +15,13 @@ import info.openrocket.core.rocketcomponent.RocketComponent;
import info.openrocket.core.rocketcomponent.Transition;
import info.openrocket.core.rocketcomponent.TrapezoidFinSet;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import java.io.BufferedInputStream;
import java.io.IOException;

View File

@ -40,8 +40,8 @@ import info.openrocket.core.rocketcomponent.TubeCoupler;
import info.openrocket.core.rocketcomponent.position.AxialMethod;
import info.openrocket.core.rocketcomponent.position.RadiusMethod;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
/**
*/

View File

@ -11,7 +11,7 @@ import info.openrocket.core.rocketcomponent.BodyTube;
import info.openrocket.core.rocketcomponent.ExternalComponent;
import info.openrocket.core.rocketcomponent.AxialStage;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.HashMap;

View File

@ -3,16 +3,16 @@
*/
package info.openrocket.core.file.rocksim.importt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.lang.reflect.Method;
import java.util.HashMap;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
@ -41,7 +41,7 @@ public class FinSetHandlerTest {
final static double EPSILON = MathUtil.EPSILON;
@BeforeClass
@BeforeAll
public static void setup() {
Module applicationModule = new ServicesForTesting();
@ -140,7 +140,7 @@ public class FinSetHandlerTest {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testToCoordinates() throws Exception {
FinSetHandler holder = new FinSetHandler(null, new BodyTube());
Method method = FinSetHandler.class.getDeclaredMethod("toCoordinates", String.class, WarningSet.class);

View File

@ -25,7 +25,7 @@ public class InnerBodyTubeHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testConstructor() throws Exception {
try {
@ -47,7 +47,7 @@ public class InnerBodyTubeHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testOpenElement() throws Exception {
Assert.assertEquals(PlainTextHandler.INSTANCE,
new InnerBodyTubeHandler(null, new BodyTube(), new WarningSet()).openElement(null, null, null));
@ -62,7 +62,7 @@ public class InnerBodyTubeHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
InnerBodyTubeHandler handler = new InnerBodyTubeHandler(null, tube, new WarningSet());
@ -131,7 +131,7 @@ public class InnerBodyTubeHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetComponent() throws Exception {
Assert.assertTrue(
new InnerBodyTubeHandler(null, new BodyTube(), new WarningSet()).getComponent() instanceof InnerTube);
@ -142,7 +142,7 @@ public class InnerBodyTubeHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetMaterialType() throws Exception {
Assert.assertEquals(Material.Type.BULK,
new InnerBodyTubeHandler(null, new BodyTube(), new WarningSet()).getMaterialType());

View File

@ -26,7 +26,7 @@ public class LaunchLugHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testConstructor() throws Exception {
try {
@ -48,7 +48,7 @@ public class LaunchLugHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testOpenElement() throws Exception {
Assert.assertEquals(PlainTextHandler.INSTANCE,
new LaunchLugHandler(null, new BodyTube(), new WarningSet()).openElement(null, null, null));
@ -61,7 +61,7 @@ public class LaunchLugHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
LaunchLugHandler handler = new LaunchLugHandler(null, tube, new WarningSet());
@ -118,7 +118,7 @@ public class LaunchLugHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetComponent() throws Exception {
Assert.assertTrue(
new LaunchLugHandler(null, new BodyTube(), new WarningSet()).getComponent() instanceof LaunchLug);
@ -129,7 +129,7 @@ public class LaunchLugHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetMaterialType() throws Exception {
Assert.assertEquals(Material.Type.BULK,
new LaunchLugHandler(null, new BodyTube(), new WarningSet()).getMaterialType());

View File

@ -25,7 +25,7 @@ public class MassObjectHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testConstructor() throws Exception {
try {
@ -48,7 +48,7 @@ public class MassObjectHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testOpenElement() throws Exception {
Assert.assertEquals(PlainTextHandler.INSTANCE,
new MassObjectHandler(null, new BodyTube(), new WarningSet()).openElement(null, null, null));
@ -61,7 +61,7 @@ public class MassObjectHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
HashMap<String, String> attributes = new HashMap<String, String>();
@ -96,7 +96,7 @@ public class MassObjectHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetComponent() throws Exception {
Assert.assertTrue(
new MassObjectHandler(null, new BodyTube(), new WarningSet()).getComponent() instanceof MassComponent);
@ -107,7 +107,7 @@ public class MassObjectHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetMaterialType() throws Exception {
Assert.assertEquals(Material.Type.LINE,
new MassObjectHandler(null, new BodyTube(), new WarningSet()).getMaterialType());

View File

@ -13,7 +13,7 @@ import info.openrocket.core.rocketcomponent.NoseCone;
import info.openrocket.core.rocketcomponent.AxialStage;
import info.openrocket.core.rocketcomponent.Transition;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.HashMap;

View File

@ -26,7 +26,7 @@ public class ParachuteHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testOpenElement() throws Exception {
Assert.assertEquals(PlainTextHandler.INSTANCE,
new ParachuteHandler(null, new BodyTube(), new WarningSet()).openElement(null, null, null));
@ -38,7 +38,7 @@ public class ParachuteHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
@ -90,7 +90,7 @@ public class ParachuteHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testConstructor() throws Exception {
try {
@ -111,7 +111,7 @@ public class ParachuteHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testSetAxialMethod() throws Exception {
BodyTube tube = new BodyTube();
ParachuteHandler handler = new ParachuteHandler(null, tube, new WarningSet());
@ -125,7 +125,7 @@ public class ParachuteHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetComponent() throws Exception {
Assert.assertTrue(
new ParachuteHandler(null, new BodyTube(), new WarningSet()).getComponent() instanceof Parachute);
@ -136,7 +136,7 @@ public class ParachuteHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetMaterialType() throws Exception {
Assert.assertEquals(Material.Type.SURFACE,
new ParachuteHandler(null, new BodyTube(), new WarningSet()).getMaterialType());
@ -147,7 +147,7 @@ public class ParachuteHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testEndHandler() throws Exception {
BodyTube tube = new BodyTube();
ParachuteHandler handler = new ParachuteHandler(null, tube, new WarningSet());

View File

@ -6,7 +6,7 @@ package info.openrocket.core.file.rocksim.importt;
import java.util.HashMap;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.logging.WarningSet;
import info.openrocket.core.file.rocksim.RockSimCommonConstants;
@ -31,7 +31,7 @@ public class RingHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testOpenElement() throws Exception {
Assert.assertEquals(PlainTextHandler.INSTANCE,
new RingHandler(null, new BodyTube(), new WarningSet()).openElement(null, null, null));
@ -43,7 +43,7 @@ public class RingHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testCloseElement() throws Exception {
BodyTube tube = new BodyTube();
@ -233,7 +233,7 @@ public class RingHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testConstructor() throws Exception {
try {
@ -255,7 +255,7 @@ public class RingHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetComponent() throws Exception {
Assert.assertTrue(
new RingHandler(null, new BodyTube(), new WarningSet()).getComponent() instanceof CenteringRing);
@ -266,7 +266,7 @@ public class RingHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetMaterialType() throws Exception {
Assert.assertEquals(Material.Type.BULK,
new RingHandler(null, new BodyTube(), new WarningSet()).getMaterialType());

View File

@ -33,7 +33,7 @@ import info.openrocket.core.rocketcomponent.BodyTube;
import info.openrocket.core.rocketcomponent.LaunchLug;
import info.openrocket.core.rocketcomponent.Rocket;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* RockSimLoader Tester.
@ -46,7 +46,7 @@ public class RockSimLoaderTest extends BaseTestCase {
* a Rocksim file using Rocksim. The bug is reproducible when manually modifying
* the Rocksim file, which is what is tested here.
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testFinsOnInnerTube() throws Exception {
RockSimLoader loader = new RockSimLoader();
InputStream stream = this.getClass().getResourceAsStream("/file/rocksim/importt/PodFins.rkt");
@ -164,7 +164,7 @@ public class RockSimLoaderTest extends BaseTestCase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testLoadFromStream() throws Exception {
RockSimLoader loader = new RockSimLoader();
// Stupid single stage rocket
@ -292,7 +292,7 @@ public class RockSimLoaderTest extends BaseTestCase {
Assert.assertEquals(0.5d, stage3.getOverrideCG().x, 0.001);
}
@org.junit.Test
@org.junit.jupiter.api.Test
public void testBodyTubeChildrenRocket() throws IOException, RocketLoadException {
RockSimLoader loader = new RockSimLoader();
// Stupid single stage rocket

View File

@ -6,7 +6,7 @@ package info.openrocket.core.file.rocksim.importt;
import java.util.HashMap;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.logging.WarningSet;
import info.openrocket.core.file.rocksim.RockSimCommonConstants;

View File

@ -25,7 +25,7 @@ public class TransitionHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testConstructor() throws Exception {
try {
@ -47,7 +47,7 @@ public class TransitionHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testOpenElement() throws Exception {
Assert.assertEquals(PlainTextHandler.INSTANCE,
new TransitionHandler(null, new AxialStage(), new WarningSet()).openElement(null, null, null));
@ -59,7 +59,7 @@ public class TransitionHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testCloseElement() throws Exception {
AxialStage stage = new AxialStage();
@ -224,7 +224,7 @@ public class TransitionHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetComponent() throws Exception {
Assert.assertTrue(
new TransitionHandler(null, new AxialStage(), new WarningSet()).getComponent() instanceof Transition);
@ -235,7 +235,7 @@ public class TransitionHandlerTest extends RockSimTestBase {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testGetMaterialType() throws Exception {
Assert.assertEquals(Material.Type.BULK,
new TransitionHandler(null, new AxialStage(), new WarningSet()).getMaterialType());

View File

@ -19,7 +19,7 @@ public class TubeFinSetHandlerTest {
*
* @throws Exception thrown if something goes awry
*/
@org.junit.Test
@org.junit.jupiter.api.Test
public void testAsOpenRocket() throws Exception {
WarningSet warnings = new WarningSet();

View File

@ -2,9 +2,9 @@ package info.openrocket.core.file.wavefrontobj;
import de.javagl.obj.FloatTuple;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class OBJUtilsTest extends BaseTestCase {
public static final float EPSILON = 0.0001f;

View File

@ -29,8 +29,8 @@ import info.openrocket.core.rocketcomponent.Transition;
import info.openrocket.core.rocketcomponent.TrapezoidFinSet;
import info.openrocket.core.rocketcomponent.TubeFinSet;
import info.openrocket.core.startup.Application;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
@ -38,13 +38,13 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class OBJExporterFactoryTest {
private static final File TMP_DIR = new File("./tmp/");
@BeforeClass
@BeforeAll
public static void setup() {
Module applicationModule = new ServicesForTesting();
Module pluginModule = new PluginModule();

View File

@ -1,31 +1,24 @@
package info.openrocket.core.l10n;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.when;
import java.util.MissingResourceException;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.auto.Mock;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(JMock.class)
@ExtendWith(MockitoExtension.class)
public class TestClassBasedTranslator {
Mockery context = new JUnit4Mockery();
@Mock
Translator translator;
@Test
public void testClassName() {
// @formatter:off
context.checking(new Expectations() {{
oneOf(translator).get("TestClassBasedTranslator.fake.key1"); will(returnValue("foobar"));
}});
// @formatter:on
// Mock setup
when(translator.get("TestClassBasedTranslator.fake.key1")).thenReturn("foobar");
ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0);
cbt.get("fake.key1");
@ -39,11 +32,7 @@ public class TestClassBasedTranslator {
public void testGetWithClassName() {
ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0);
// @formatter:off
context.checking(new Expectations() {{
oneOf(translator).get("TestClassBasedTranslator.fake.key1"); will(returnValue("foobar"));
}});
// @formatter:on
when(translator.get("TestClassBasedTranslator.fake.key1")).thenReturn("foobar");
assertEquals("foobar", cbt.get("fake.key1"));
}
@ -53,11 +42,8 @@ public class TestClassBasedTranslator {
ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0);
// @formatter:off
context.checking(new Expectations() {{
oneOf(translator).get("TestClassBasedTranslator.fake.key2"); will(throwException(new MissingResourceException("a", "b", "c")));
oneOf(translator).get("fake.key2"); will(returnValue("barbaz"));
}});
// @formatter:on
when(translator.get("TestClassBasedTranslator.fake.key2")).thenThrow(new MissingResourceException("a", "b", "c"));
when(translator.get("fake.key2")).thenReturn("barbaz");
assertEquals("barbaz", cbt.get("fake.key2"));
}
@ -66,12 +52,8 @@ public class TestClassBasedTranslator {
public void testMissing() {
ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0);
// @formatter:off
context.checking(new Expectations() {{
oneOf(translator).get("TestClassBasedTranslator.fake.key3"); will(throwException(new MissingResourceException("a", "b", "c")));
oneOf(translator).get("fake.key3"); will(throwException(new MissingResourceException("a", "b", "c")));
}});
// @formatter:on
when(translator.get("TestClassBasedTranslator.fake.key3")).thenThrow(new MissingResourceException("a", "b", "c"));
when(translator.get("fake.key3")).thenThrow(new MissingResourceException("a", "b", "c"));
try {
fail("Returned: " + cbt.get("fake.key3"));
@ -85,11 +67,7 @@ public class TestClassBasedTranslator {
public void testGetWithSubClass() {
ClassBasedTranslator cbt = new ClassBasedTranslator(translator, 0);
// @formatter:off
context.checking(new Expectations() {{
oneOf(translator).get("TestClassBasedTranslator.fake.key1"); will(returnValue("foobar"));
}});
// @formatter:on
when(translator.get("TestClassBasedTranslator.fake.key1")).thenReturn("foobar");
assertEquals("foobar", new Subclass().get(cbt, "fake.key1"));
assertEquals("TestClassBasedTranslator", cbt.getClassName());

View File

@ -1,8 +1,8 @@
package info.openrocket.core.l10n;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestDebugTranslator {

View File

@ -1,23 +1,22 @@
package info.openrocket.core.l10n;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.MissingResourceException;
import info.openrocket.core.startup.Application;
import info.openrocket.core.startup.ExceptionHandler;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.auto.Mock;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(JMock.class)
@ExtendWith(MockitoExtension.class)
public class TestExceptionSuppressingTranslator {
Mockery context = new JUnit4Mockery();
@Mock
Translator translator;
@ -30,11 +29,7 @@ public class TestExceptionSuppressingTranslator {
Application.setExceptionHandler(exceptionHandler);
ExceptionSuppressingTranslator est = new ExceptionSuppressingTranslator(translator);
// @formatter:off
context.checking(new Expectations() {{
oneOf(translator).get("fake.key4"); will(returnValue("foobar"));
}});
// @formatter:on
when(translator.get("fake.key4")).thenReturn("foobar");
assertEquals("foobar", est.get("fake.key4"));
}
@ -46,14 +41,8 @@ public class TestExceptionSuppressingTranslator {
assertFalse("Prerequisite failed", ExceptionSuppressingTranslator.errorReported);
// @formatter:off
context.checking(new Expectations() {{
oneOf(exceptionHandler).handleErrorCondition(with(any(String.class)), with(any(MissingResourceException.class)));
oneOf(translator).get("fake.key5"); will(throwException(new MissingResourceException("a", "b", "c")));
oneOf(translator).get("fake.key5"); will(throwException(new MissingResourceException("a", "b", "c")));
oneOf(translator).get("fake.key6"); will(throwException(new MissingResourceException("a", "b", "c")));
}});
// @formatter:on
when(translator.get("fake.key5")).thenThrow(new MissingResourceException("a", "b", "c"));
when(translator.get("fake.key6")).thenThrow(new MissingResourceException("a", "b", "c"));
// Test first failure
assertEquals("fake.key5", est.get("fake.key5"));
@ -66,6 +55,9 @@ public class TestExceptionSuppressingTranslator {
// Test failure with other key
assertEquals("fake.key6", est.get("fake.key6"));
assertTrue(ExceptionSuppressingTranslator.errorReported);
// Verify that handleErrorCondition is called with any string and any MissingResourceException
verify(exceptionHandler).handleErrorCondition(any(String.class), any(MissingResourceException.class));
}
}

View File

@ -1,9 +1,9 @@
package info.openrocket.core.l10n;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.util.Chars;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestL10N {

View File

@ -1,13 +1,13 @@
package info.openrocket.core.l10n;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Locale;
import java.util.MissingResourceException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestResourceBundleTranslator {

View File

@ -1,8 +1,8 @@
package info.openrocket.core.masscalc;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.rocketcomponent.Rocket;
import info.openrocket.core.util.TestRockets;

View File

@ -1,6 +1,6 @@
package info.openrocket.core.masscalc;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List;
@ -10,7 +10,7 @@ import info.openrocket.core.rocketcomponent.position.AngleMethod;
import info.openrocket.core.rocketcomponent.position.AxialMethod;
import info.openrocket.core.rocketcomponent.position.RadiusMethod;
import info.openrocket.core.util.MathUtil;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.motor.Motor;
import info.openrocket.core.simulation.MotorClusterState;

View File

@ -1,9 +1,9 @@
package info.openrocket.core.masscalc;
//import junit.framework.TestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.util.Coordinate;
import info.openrocket.core.util.MathUtil;

View File

@ -1,9 +1,9 @@
package info.openrocket.core.models.gravity;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.util.WorldCoordinate;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class WGSGravityModelTest {

View File

@ -1,8 +1,8 @@
package info.openrocket.core.motor;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class ManufacturerTest {

View File

@ -1,6 +1,6 @@
package info.openrocket.core.motor;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
@ -10,7 +10,7 @@ import java.security.NoSuchAlgorithmException;
import info.openrocket.core.motor.MotorDigest.DataType;
import info.openrocket.core.util.TextUtil;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class MotorDigestTest {

View File

@ -1,9 +1,9 @@
package info.openrocket.core.motor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.util.Coordinate;
import info.openrocket.core.util.Pair;

View File

@ -1,13 +1,13 @@
package info.openrocket.core.optimization;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import java.util.List;
import info.openrocket.core.optimization.general.Point;
import info.openrocket.core.optimization.general.multidim.SearchPattern;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestSearchPattern {

View File

@ -1,15 +1,16 @@
package info.openrocket.core.optimization.rocketoptimization;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.auto.Mock;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import info.openrocket.core.document.Simulation;
@ -21,10 +22,12 @@ import info.openrocket.core.unit.UnitGroup;
import info.openrocket.core.unit.Value;
import info.openrocket.core.util.Pair;
import info.openrocket.core.util.BaseTestCase;
import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(JMock.class)
@ExtendWith(MockitoExtension.class)
public class TestRocketOptimizationFunction extends BaseTestCase {
Mockery context = new JUnit4Mockery();
@Mock
OptimizableParameter parameter;
@ -53,34 +56,15 @@ public class TestRocketOptimizationFunction extends BaseTestCase {
final double gvalue = 8.81;
final Point point = new Point(p1, p2);
// @formatter:off
context.checking(new Expectations() {
{
oneOf(modifier1).modify(simulation, p1);
oneOf(modifier2).modify(simulation, p2);
oneOf(domain).getDistanceToDomain(simulation);
will(returnValue(new Pair<Double, Value>(ddist, dref)));
oneOf(parameter).computeValue(simulation);
will(returnValue(pvalue));
oneOf(parameter).getUnitGroup();
will(returnValue(UnitGroup.UNITS_NONE));
oneOf(goal).getMinimizationParameter(pvalue);
will(returnValue(gvalue));
oneOf(modifier1).getCurrentSIValue(simulation);
will(returnValue(0.2));
oneOf(modifier1).getUnitGroup();
will(returnValue(UnitGroup.UNITS_LENGTH));
oneOf(modifier2).getCurrentSIValue(simulation);
will(returnValue(0.3));
oneOf(modifier2).getUnitGroup();
will(returnValue(UnitGroup.UNITS_LENGTH));
oneOf(listener).evaluated(point, new Value[] {
new Value(0.2, UnitGroup.UNITS_LENGTH.getDefaultUnit()),
new Value(0.3, UnitGroup.UNITS_LENGTH.getDefaultUnit())
}, dref, pvalueValue, gvalue);
}
});
// @formatter:on
// Setup stubbing for methods that return values
when(domain.getDistanceToDomain(simulation)).thenReturn(new Pair<Double, Value>(ddist, dref));
when(parameter.computeValue(simulation)).thenReturn(pvalue);
when(parameter.getUnitGroup()).thenReturn(UnitGroup.UNITS_NONE);
when(goal.getMinimizationParameter(pvalue)).thenReturn(gvalue);
when(modifier1.getCurrentSIValue(simulation)).thenReturn(0.2);
when(modifier1.getUnitGroup()).thenReturn(UnitGroup.UNITS_LENGTH);
when(modifier2.getCurrentSIValue(simulation)).thenReturn(0.3);
when(modifier2.getUnitGroup()).thenReturn(UnitGroup.UNITS_LENGTH);
RocketOptimizationFunction function = new RocketOptimizationFunction(simulation,
parameter, goal, domain, modifier1, modifier2) {
@ -93,6 +77,26 @@ public class TestRocketOptimizationFunction extends BaseTestCase {
double value = function.evaluate(point);
assertEquals(gvalue, value, 0);
// Verify the interactions
verify(modifier1, times(1)).modify(simulation, p1);
verify(modifier2, times(1)).modify(simulation, p2);
verify(domain, times(1)).getDistanceToDomain(simulation);
verify(parameter, times(1)).computeValue(simulation);
verify(parameter, times(1)).getUnitGroup();
verify(goal, times(1)).getMinimizationParameter(pvalue);
verify(modifier1, times(1)).getCurrentSIValue(simulation);
verify(modifier1, times(1)).getUnitGroup();
verify(modifier2, times(1)).getCurrentSIValue(simulation);
verify(modifier2, times(1)).getUnitGroup();
verify(listener, times(1)).evaluated(eq(point), argThat(new ArgumentMatcher<Value[]>() {
@Override
public boolean matches(Value[] argument) {
// Customize this as necessary to match the expected Value[] array
return argument[0].getValue() == 0.2 && argument[1].getValue() == 0.3;
}
}), eq(dref), eq(pvalueValue), eq(gvalue));
}
@Test
@ -106,22 +110,11 @@ public class TestRocketOptimizationFunction extends BaseTestCase {
final Value dref = new Value(0.33, Unit.NOUNIT);
final double pvalue = 9.81;
// @formatter:off
context.checking(new Expectations() {
{
oneOf(modifier1).modify(simulation, p1);
oneOf(modifier2).modify(simulation, p2);
oneOf(domain).getDistanceToDomain(simulation);
will(returnValue(new Pair<Double, Value>(ddist, dref)));
oneOf(parameter).computeValue(simulation);
will(returnValue(pvalue));
oneOf(parameter).getUnitGroup();
will(returnValue(UnitGroup.UNITS_NONE));
oneOf(goal).getMinimizationParameter(pvalue);
will(returnValue(Double.NaN));
}
});
// @formatter:on
// Setup stubbing for methods that return values
when(domain.getDistanceToDomain(simulation)).thenReturn(new Pair<>(ddist, dref));
when(parameter.computeValue(simulation)).thenReturn(pvalue);
when(parameter.getUnitGroup()).thenReturn(UnitGroup.UNITS_NONE);
when(goal.getMinimizationParameter(pvalue)).thenReturn(Double.NaN);
RocketOptimizationFunction function = new RocketOptimizationFunction(simulation,
parameter, goal, domain, modifier1, modifier2) {
@ -133,6 +126,14 @@ public class TestRocketOptimizationFunction extends BaseTestCase {
double value = function.evaluate(new Point(p1, p2));
assertEquals(Double.MAX_VALUE, value, 0);
// Verify that the methods have been called with the specified parameters
verify(modifier1).modify(simulation, p1);
verify(modifier2).modify(simulation, p2);
verify(domain).getDistanceToDomain(simulation);
verify(parameter).computeValue(simulation);
verify(parameter).getUnitGroup();
verify(goal).getMinimizationParameter(pvalue);
}
@Test
@ -146,28 +147,12 @@ public class TestRocketOptimizationFunction extends BaseTestCase {
final Value dref = new Value(ddist, Unit.NOUNIT);
final Point point = new Point(p1, p2);
// @formatter:off
context.checking(new Expectations() {
{
oneOf(modifier1).modify(simulation, p1);
oneOf(modifier2).modify(simulation, p2);
oneOf(domain).getDistanceToDomain(simulation);
will(returnValue(new Pair<Double, Value>(ddist, dref)));
oneOf(modifier1).getCurrentSIValue(simulation);
will(returnValue(0.2));
oneOf(modifier1).getUnitGroup();
will(returnValue(UnitGroup.UNITS_LENGTH));
oneOf(modifier2).getCurrentSIValue(simulation);
will(returnValue(0.3));
oneOf(modifier2).getUnitGroup();
will(returnValue(UnitGroup.UNITS_LENGTH));
oneOf(listener).evaluated(point, new Value[] {
new Value(0.2, UnitGroup.UNITS_LENGTH.getDefaultUnit()),
new Value(0.3, UnitGroup.UNITS_LENGTH.getDefaultUnit())
}, dref, null, 1.98E200);
}
});
// @formatter:on
// Setup stubbing for methods that return values
when(domain.getDistanceToDomain(simulation)).thenReturn(new Pair<>(ddist, dref));
when(modifier1.getCurrentSIValue(simulation)).thenReturn(0.2);
when(modifier1.getUnitGroup()).thenReturn(UnitGroup.UNITS_LENGTH);
when(modifier2.getCurrentSIValue(simulation)).thenReturn(0.3);
when(modifier2.getUnitGroup()).thenReturn(UnitGroup.UNITS_LENGTH);
RocketOptimizationFunction function = new RocketOptimizationFunction(simulation,
parameter, goal, domain, modifier1, modifier2) {
@ -180,6 +165,27 @@ public class TestRocketOptimizationFunction extends BaseTestCase {
double value = function.evaluate(new Point(p1, p2));
assertTrue(value > 1e100);
// Verify the interactions
verify(modifier1).modify(simulation, p1);
verify(modifier2).modify(simulation, p2);
verify(domain).getDistanceToDomain(simulation);
verify(modifier1).getCurrentSIValue(simulation);
verify(modifier1).getUnitGroup();
verify(modifier2).getCurrentSIValue(simulation);
verify(modifier2).getUnitGroup();
// For verifying the call to listener.evaluated with complex arguments
verify(listener).evaluated(eq(point), argThat(new ArgumentMatcher<Value[]>() {
@Override
public boolean matches(Value[] argument) {
// Adjust the logic here based on how specific you need to be about the values
return argument != null && argument.length == 2
&& argument[0].getValue() == 0.2 && argument[1].getValue() == 0.3
&& argument[0].getUnit() == UnitGroup.UNITS_LENGTH.getDefaultUnit()
&& argument[1].getUnit() == UnitGroup.UNITS_LENGTH.getDefaultUnit();
}
}), eq(dref), eq(null), eq(1.98E200));
}
@Test
@ -192,16 +198,8 @@ public class TestRocketOptimizationFunction extends BaseTestCase {
final double ddist = Double.NaN;
final Value dref = new Value(0.33, Unit.NOUNIT);
// @formatter:off
context.checking(new Expectations() {
{
oneOf(modifier1).modify(simulation, p1);
oneOf(modifier2).modify(simulation, p2);
oneOf(domain).getDistanceToDomain(simulation);
will(returnValue(new Pair<Double, Value>(ddist, dref)));
}
});
// @formatter:on
// Stubbing to return a specific value
when(domain.getDistanceToDomain(simulation)).thenReturn(new Pair<>(ddist, dref));
RocketOptimizationFunction function = new RocketOptimizationFunction(simulation,
parameter, goal, domain, modifier1, modifier2) {
@ -213,6 +211,11 @@ public class TestRocketOptimizationFunction extends BaseTestCase {
double value = function.evaluate(new Point(p1, p2));
assertEquals(Double.MAX_VALUE, value, 0);
// Verify the interactions
verify(modifier1).modify(simulation, p1);
verify(modifier2).modify(simulation, p2);
verify(domain).getDistanceToDomain(simulation);
}
@Test

View File

@ -1,7 +1,7 @@
package info.openrocket.core.optimization.rocketoptimization.modifiers;
import static info.openrocket.core.util.MathUtil.EPSILON;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.document.Simulation;
import info.openrocket.core.optimization.general.OptimizationException;
import info.openrocket.core.rocketcomponent.Rocket;
@ -11,7 +11,7 @@ import info.openrocket.core.util.BaseTestCase;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestGenericModifier extends BaseTestCase {

View File

@ -2,7 +2,7 @@ package info.openrocket.core.plugin;
import info.openrocket.core.ServicesForTesting;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;

View File

@ -1,7 +1,7 @@
package info.openrocket.core.plugin;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.List;

View File

@ -1,6 +1,6 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.BodyTube;
@ -9,7 +9,7 @@ import info.openrocket.core.rocketcomponent.ExternalComponent.Finish;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to BodyTube RocketComponents through

View File

@ -1,10 +1,10 @@
package info.openrocket.core.preset;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of BODY_TUBE type ComponentPresets based on

View File

@ -1,13 +1,13 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.Bulkhead;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to Bulkhead RocketComponents through

View File

@ -1,10 +1,10 @@
package info.openrocket.core.preset;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of BULK_HEAD type ComponentPresets based on

View File

@ -1,13 +1,13 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.CenteringRing;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to CenteringRing RocketComponents

View File

@ -1,10 +1,10 @@
package info.openrocket.core.preset;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of CENTERING_RING type ComponentPresets based on

View File

@ -1,13 +1,13 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.EngineBlock;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to EngineBlock RocketComponents through

View File

@ -1,10 +1,10 @@
package info.openrocket.core.preset;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of ENGINE_BLOCK type ComponentPresets based on

View File

@ -1,6 +1,6 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.ExternalComponent.Finish;
@ -9,7 +9,7 @@ import info.openrocket.core.rocketcomponent.LaunchLug;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to LaunchLug RocketComponents through

View File

@ -1,10 +1,10 @@
package info.openrocket.core.preset;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of LAUNCH_LUG type ComponentPresets based on

View File

@ -1,6 +1,6 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.ExternalComponent.Finish;
@ -10,7 +10,7 @@ import info.openrocket.core.rocketcomponent.Transition;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to NoseCone RocketComponents through

View File

@ -1,12 +1,12 @@
package info.openrocket.core.preset;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.Transition;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of NOSE_CONE type ComponentPresets based on

View File

@ -2,7 +2,7 @@ package info.openrocket.core.preset;
import info.openrocket.core.motor.Manufacturer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of PARACHUTE type ComponentPresets based on

View File

@ -1,13 +1,13 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.Parachute;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to Parachute RocketComponents through

View File

@ -1,6 +1,6 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
public abstract class PresetAssertHelper {

View File

@ -1,13 +1,13 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.Streamer;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to Streamer RocketComponents through

View File

@ -2,7 +2,7 @@ package info.openrocket.core.preset;
import info.openrocket.core.motor.Manufacturer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of STREAMER type ComponentPresets based on TypedPropertyMap

View File

@ -1,6 +1,6 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.ExternalComponent.Finish;
@ -9,7 +9,7 @@ import info.openrocket.core.rocketcomponent.Transition;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to Transition RocketComponents through

View File

@ -1,12 +1,12 @@
package info.openrocket.core.preset;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.Transition;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of TRANSITION type ComponentPresets based on

View File

@ -1,13 +1,13 @@
package info.openrocket.core.preset;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import info.openrocket.core.rocketcomponent.TubeCoupler;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test application of ComponentPresets to TubeCoupler RocketComponents through

View File

@ -1,10 +1,10 @@
package info.openrocket.core.preset;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.motor.Manufacturer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test construction of TUBE_COUPLER type ComponentPresets based on

View File

@ -5,7 +5,7 @@ import info.openrocket.core.preset.ComponentPreset;
import info.openrocket.core.preset.ComponentPresetFactory;
import info.openrocket.core.preset.TypedPropertyMap;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import javax.imageio.ImageIO;
import javax.xml.bind.JAXBContext;

View File

@ -2,7 +2,7 @@ package info.openrocket.core.preset.xml;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* OpenRocketComponentSaver Tester.

View File

@ -2,10 +2,10 @@ package info.openrocket.core.rocketcomponent;
import info.openrocket.core.util.BaseTestCase;
import info.openrocket.core.util.TestRockets;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AxialStageTest extends BaseTestCase {
/**

View File

@ -3,13 +3,11 @@ package info.openrocket.core.rocketcomponent;
import info.openrocket.core.util.BoundingBox;
import info.openrocket.core.util.MathUtil;
import info.openrocket.core.util.TestRockets;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.util.BaseTestCase;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BoundingBoxTest extends BaseTestCase {
final double EPSILON = MathUtil.EPSILON;

View File

@ -1,10 +1,10 @@
package info.openrocket.core.rocketcomponent;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.util.TestRockets;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.rocketcomponent.position.*;
import info.openrocket.core.util.Coordinate;

View File

@ -1,14 +1,13 @@
package info.openrocket.core.rocketcomponent;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Field;
import java.util.ArrayList;
@ -16,7 +15,7 @@ import java.util.List;
import java.util.Map;
import info.openrocket.core.util.BoundingBox;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.util.Coordinate;
import info.openrocket.core.util.MathUtil;
@ -48,20 +47,18 @@ public class FlightConfigurationTest extends BaseTestCase {
config.setAllStages();
// preconditions
assertThat("active stage count doesn't match", config.getActiveStageCount(), equalTo(2));
assertEquals(config.getActiveStageCount(), 2, "active stage count doesn't match");
final double expectedLength = 0.335;
final double calculatedLength = config.getLengthAerodynamic();
assertEquals("source config length doesn't match: ", expectedLength, calculatedLength, EPSILON);
assertEquals(expectedLength, calculatedLength, EPSILON, "source config length doesn't match: ");
double expectedReferenceLength = 0.024;
assertEquals("source config reference length doesn't match: ", expectedReferenceLength,
config.getReferenceLength(), EPSILON);
assertEquals(expectedReferenceLength, config.getReferenceLength(), EPSILON, "source config reference length doesn't match: ");
double expectedReferenceArea = Math.pow(expectedReferenceLength / 2, 2) * Math.PI;
double actualReferenceArea = config.getReferenceArea();
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea,
EPSILON);
assertEquals(expectedReferenceArea, actualReferenceArea, EPSILON, "source config reference area doesn't match: ");
}
@Test
@ -73,19 +70,17 @@ public class FlightConfigurationTest extends BaseTestCase {
config1.setAllStages();
int expectedStageCount = 2;
int actualStageCount = config1.getActiveStageCount();
assertThat("active stage count doesn't match", actualStageCount, equalTo(expectedStageCount));
assertEquals(actualStageCount, expectedStageCount, "active stage count doesn't match");
int expectedMotorCount = 2;
int actualMotorCount = config1.getActiveMotors().size();
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
assertEquals(actualMotorCount, expectedMotorCount, "active motor count doesn't match");
double expectedLength = 0.335;
assertEquals("source config length doesn't match: ", expectedLength, config1.getLengthAerodynamic(), EPSILON);
assertEquals(expectedLength, config1.getLengthAerodynamic(), EPSILON, "source config length doesn't match: ");
double expectedReferenceLength = 0.024;
assertEquals("source config reference length doesn't match: ", expectedReferenceLength,
config1.getReferenceLength(), EPSILON);
assertEquals(expectedReferenceLength, config1.getReferenceLength(), EPSILON, "source config reference length doesn't match: ");
double expectedReferenceArea = Math.pow(expectedReferenceLength / 2, 2) * Math.PI;
double actualReferenceArea = config1.getReferenceArea();
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea,
EPSILON);
assertEquals(expectedReferenceArea, actualReferenceArea, EPSILON, "source config reference area doesn't match: ");
// vvvv test target vvvv
FlightConfiguration config2 = config1.clone();
@ -94,15 +89,13 @@ public class FlightConfigurationTest extends BaseTestCase {
// postconditions
expectedStageCount = 2;
actualStageCount = config2.getActiveStageCount();
assertThat("active stage count doesn't match", actualStageCount, equalTo(expectedStageCount));
assertEquals(actualStageCount, expectedStageCount, "active stage count doesn't match");
expectedMotorCount = 2;
actualMotorCount = config2.getActiveMotors().size();
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
assertEquals("source config length doesn't match: ", expectedLength, config2.getLengthAerodynamic(), EPSILON);
assertEquals("source config reference length doesn't match: ", expectedReferenceLength,
config2.getReferenceLength(), EPSILON);
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, config2.getReferenceArea(),
EPSILON);
assertEquals(actualMotorCount, expectedMotorCount, "active motor count doesn't match");
assertEquals(expectedLength, config2.getLengthAerodynamic(), EPSILON, "source config length doesn't match: ");
assertEquals(expectedReferenceLength, config2.getReferenceLength(), EPSILON, "source config reference length doesn't match: ");
assertEquals(expectedReferenceArea, config2.getReferenceArea(), EPSILON, "source config reference area doesn't match: ");
}
@ -130,18 +123,18 @@ public class FlightConfigurationTest extends BaseTestCase {
// postcondition: config #1
expectedStageCount = 0;
actualStageCount = config1.getActiveStageCount();
assertThat("active stage count doesn't match", actualStageCount, equalTo(expectedStageCount));
assertEquals(actualStageCount, expectedStageCount, "active stage count doesn't match");
expectedMotorCount = 0;
actualMotorCount = config1.getActiveMotors().size();
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
assertEquals(actualMotorCount, expectedMotorCount, "active motor count doesn't match");
// postcondition: config #2
expectedStageCount = 2;
actualStageCount = config2.getActiveStageCount();
assertThat("active stage count doesn't match", actualStageCount, equalTo(expectedStageCount));
assertEquals(actualStageCount, expectedStageCount, "active stage count doesn't match");
expectedMotorCount = 2;
actualMotorCount = config2.getActiveMotors().size();
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
assertEquals(actualMotorCount, expectedMotorCount, "active motor count doesn't match");
}
/**
@ -159,11 +152,11 @@ public class FlightConfigurationTest extends BaseTestCase {
// test that getStageCount() returns correct value
int expectedStageCount = 1;
int stageCount = config.getStageCount();
assertTrue("stage count doesn't match", stageCount == expectedStageCount);
assertTrue(stageCount == expectedStageCount, "stage count doesn't match");
expectedStageCount = 1;
stageCount = config.getActiveStageCount();
assertThat("active stage count doesn't match", stageCount, equalTo(expectedStageCount));
assertEquals(stageCount, expectedStageCount, "active stage count doesn't match");
// test explicitly setting all stages up to first stage active
config.setOnlyStage(0);
@ -182,10 +175,8 @@ public class FlightConfigurationTest extends BaseTestCase {
// don't change the configuration:
FlightConfiguration defaultConfig = r1.getSelectedConfiguration();
assertThat("Empty configuration has motors! it should be empty!",
r1.getEmptyConfiguration().getActiveMotors().size(), equalTo(0));
assertThat("Default configuration is not the empty configuration. It should be!",
defaultConfig.getActiveMotors().size(), equalTo(0));
assertEquals(r1.getEmptyConfiguration().getActiveMotors().size(), 0, "Empty configuration has motors! it should be empty!");
assertEquals(defaultConfig.getActiveMotors().size(), 0, "Default configuration is not the empty configuration. It should be!");
}
@Test
@ -197,15 +188,13 @@ public class FlightConfigurationTest extends BaseTestCase {
// test that all configurations correctly loaded:
int expectedConfigCount = 5;
int actualConfigCount = rkt.getConfigurationCount();
assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount,
equalTo(expectedConfigCount));
assertEquals(actualConfigCount, expectedConfigCount, "number of loaded configuration counts doesn't actually match.");
// create with
rkt.createFlightConfiguration(null);
expectedConfigCount = 6;
actualConfigCount = rkt.getConfigurationCount();
assertThat("createFlightConfiguration with null: doesn't actually work.", actualConfigCount,
equalTo(expectedConfigCount));
assertEquals(actualConfigCount, expectedConfigCount, "createFlightConfiguration with null: doesn't actually work.");
}
@Test
@ -217,7 +206,7 @@ public class FlightConfigurationTest extends BaseTestCase {
int expectedMotorCount = 5;
int actualMotorCount = smmt.getMotorConfigurationSet().size();
assertThat("number of motor configurations doesn't match.", actualMotorCount, equalTo(expectedMotorCount));
assertEquals(actualMotorCount, expectedMotorCount, "number of motor configurations doesn't match.");
}
@ -228,12 +217,10 @@ public class FlightConfigurationTest extends BaseTestCase {
// test that all configurations correctly loaded:
int expectedConfigCount = 5;
int actualConfigCount = rkt.getConfigurationCount();
assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount,
equalTo(expectedConfigCount));
assertEquals(actualConfigCount, expectedConfigCount, "number of loaded configuration counts doesn't actually match.");
actualConfigCount = rkt.getIds().size();
assertThat("number of configuration array ids doesn't actually match.",
actualConfigCount, equalTo(expectedConfigCount));
assertEquals(actualConfigCount, expectedConfigCount, "number of configuration array ids doesn't actually match.");
// upon success, these silently complete.
// upon failure, they'll throw exceptions:
@ -241,19 +228,20 @@ public class FlightConfigurationTest extends BaseTestCase {
rkt.getFlightConfigurationByIndex(5, true);
}
@Test(expected = java.lang.IndexOutOfBoundsException.class)
@Test
public void testGetFlightConfigurationOutOfBounds() {
Rocket rkt = TestRockets.makeEstesAlphaIII();
// test that all configurations correctly loaded:
int expectedConfigCount = 5;
int actualConfigCount = rkt.getConfigurationCount();
assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount,
equalTo(expectedConfigCount));
assertEquals(actualConfigCount, expectedConfigCount, "number of loaded configuration counts doesn't actually match.");
// this SHOULD throw an exception --
// it's out of bounds on, and no configuration exists at index 5.
assertThrows(IndexOutOfBoundsException.class, () -> {
rkt.getFlightConfigurationByIndex(5);
});
}
/**
@ -271,73 +259,73 @@ public class FlightConfigurationTest extends BaseTestCase {
expectedStageCount = 2;
stageCount = config.getStageCount();
assertThat("stage count doesn't match", stageCount, equalTo(expectedStageCount));
assertEquals(stageCount, expectedStageCount, "stage count doesn't match");
config.clearAllStages();
assertThat(" clear all stages: check #0: ", config.isStageActive(0), equalTo(false));
assertThat(" clear all stages: check #1: ", config.isStageActive(1), equalTo(false));
assertFalse(config.isStageActive(0), " clear all stages: check #0: ");
assertFalse(config.isStageActive(1), " clear all stages: check #1: ");
// test explicitly setting only first stage active
config.setOnlyStage(0);
expectedStageCount = 1;
stageCount = config.getActiveStageCount();
assertThat("active stage count doesn't match", stageCount, equalTo(expectedStageCount));
assertEquals(stageCount, expectedStageCount, "active stage count doesn't match");
assertThat(" setting single stage active: ", config.isStageActive(0), equalTo(true));
assertTrue(config.isStageActive(0), " setting single stage active: ");
// test explicitly setting all stages up to second stage active
config.setOnlyStage(1);
assertThat("Setting single stage active: ", config.isStageActive(0), equalTo(false));
assertThat("Setting single stage active: ", config.isStageActive(1), equalTo(true));
assertFalse(config.isStageActive(0), "Setting single stage active: ");
assertTrue(config.isStageActive(1), "Setting single stage active: ");
config.clearStage(0);
assertThat(" deactivate stage #0: ", config.isStageActive(0), equalTo(false));
assertThat(" active stage #1: ", config.isStageActive(1), equalTo(true));
assertFalse(config.isStageActive(0), " deactivate stage #0: ");
assertTrue(config.isStageActive(1), " active stage #1: ");
// test explicitly setting all two stages active
config.setAllStages();
assertThat(" activate all stages: check stage #0: ", config.isStageActive(0), equalTo(true));
assertThat(" activate all stages: check stage #1: ", config.isStageActive(1), equalTo(true));
assertTrue(config.isStageActive(0), " activate all stages: check stage #0: ");
assertTrue(config.isStageActive(1), " activate all stages: check stage #1: ");
// test toggling single stage
config.setAllStages();
config.toggleStage(0);
assertThat(" toggle stage #0: ", config.isStageActive(0), equalTo(false));
assertFalse(config.isStageActive(0), " toggle stage #0: ");
config.toggleStage(0);
assertThat(" toggle stage #0: ", config.isStageActive(0), equalTo(true));
assertTrue(config.isStageActive(0), " toggle stage #0: ");
config.toggleStage(0);
assertThat(" toggle stage #0: ", config.isStageActive(0), equalTo(false));
assertFalse(config.isStageActive(0), " toggle stage #0: ");
AxialStage sustainer = rkt.getTopmostStage(config);
AxialStage booster = rkt.getBottomCoreStage(config);
assertThat(" sustainer stage is stage #1: ", sustainer.getStageNumber(), equalTo(1));
assertThat(" booster stage is stage #1: ", booster.getStageNumber(), equalTo(1));
assertEquals(sustainer.getStageNumber(), 1, " sustainer stage is stage #1: ");
assertEquals(booster.getStageNumber(), 1, " booster stage is stage #1: ");
config.setAllStages();
config._setStageActive(1, false);
sustainer = rkt.getTopmostStage(config);
booster = rkt.getBottomCoreStage(config);
assertThat(" sustainer stage is stage #1: ", sustainer.getStageNumber(), equalTo(0));
assertThat(" booster stage is stage #1: ", booster.getStageNumber(), equalTo(0));
assertEquals(sustainer.getStageNumber(), 0, " sustainer stage is stage #1: ");
assertEquals(booster.getStageNumber(), 0, " booster stage is stage #1: ");
config.setAllStages();
sustainer = rkt.getTopmostStage(config);
booster = rkt.getBottomCoreStage(config);
assertThat(" sustainer stage is stage #0: ", sustainer.getStageNumber(), equalTo(0));
assertThat(" booster stage is stage #1: ", booster.getStageNumber(), equalTo(1));
assertEquals(sustainer.getStageNumber(), 0, " sustainer stage is stage #0: ");
assertEquals(booster.getStageNumber(), 1, " booster stage is stage #1: ");
config.clearAllStages();
config.activateStagesThrough(sustainer);
assertThat(" sustainer stage is active: ", config.isStageActive(sustainer.getStageNumber()), equalTo(true));
assertThat(" booster stage is inactive: ", config.isStageActive(booster.getStageNumber()), equalTo(false));
assertTrue(config.isStageActive(sustainer.getStageNumber()), " sustainer stage is active: ");
assertFalse(config.isStageActive(booster.getStageNumber()), " booster stage is inactive: ");
config.clearAllStages();
config.activateStagesThrough(booster);
assertThat(" sustainer stage is active: ", config.isStageActive(sustainer.getStageNumber()), equalTo(true));
assertThat(" booster stage is active: ", config.isStageActive(booster.getStageNumber()), equalTo(true));
assertTrue(config.isStageActive(sustainer.getStageNumber()), " sustainer stage is active: ");
assertTrue(config.isStageActive(booster.getStageNumber()), " booster stage is active: ");
}
@ -354,22 +342,22 @@ public class FlightConfigurationTest extends BaseTestCase {
config.clearAllStages();
int expectedMotorCount = 0;
int actualMotorCount = config.getActiveMotors().size();
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
assertEquals(actualMotorCount, expectedMotorCount, "active motor count doesn't match");
config.setOnlyStage(0);
expectedMotorCount = 1;
actualMotorCount = config.getActiveMotors().size();
assertThat("active motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
assertEquals(actualMotorCount, expectedMotorCount, "active motor count doesn't match: ");
config.setOnlyStage(1);
expectedMotorCount = 1;
actualMotorCount = config.getActiveMotors().size();
assertThat("active motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
assertEquals(actualMotorCount, expectedMotorCount, "active motor count doesn't match: ");
config.setAllStages();
expectedMotorCount = 2;
actualMotorCount = config.getActiveMotors().size();
assertThat("active motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
assertEquals(actualMotorCount, expectedMotorCount, "active motor count doesn't match: ");
}
@Test
@ -389,9 +377,9 @@ public class FlightConfigurationTest extends BaseTestCase {
{ // Core Stage
final List<InstanceContext> coreStageContextList = instances.getInstanceContexts(coreStage);
final InstanceContext coreStageContext = coreStageContextList.get(0);
assertThat((Class<AxialStage>) coreStageContext.component.getClass(), equalTo(AxialStage.class));
assertThat(coreStageContext.component.getID(), equalTo(rocket.getChild(1).getID()));
assertThat(coreStageContext.component.getInstanceCount(), equalTo(1));
assertEquals(coreStageContext.component.getClass(), AxialStage.class);
assertEquals(coreStageContext.component.getID(), rocket.getChild(1).getID());
assertEquals(coreStageContext.component.getInstanceCount(), 1);
final Coordinate coreLocation = coreStageContext.getLocation();
assertEquals(coreLocation.x, 0.564, EPSILON);
@ -406,9 +394,9 @@ public class FlightConfigurationTest extends BaseTestCase {
final ParallelStage boosterStage = (ParallelStage) coreStage.getChild(0).getChild(0);
final List<InstanceContext> boosterStageContextList = instances.getInstanceContexts(boosterStage);
final InstanceContext boosterStage0Context = boosterStageContextList.get(0);
assertThat((Class<ParallelStage>) boosterStage0Context.component.getClass(), equalTo(ParallelStage.class));
assertThat(boosterStage0Context.component.getID(), equalTo(boosterStage.getID()));
assertThat(boosterStage0Context.instanceNumber, equalTo(0));
assertEquals(boosterStage0Context.component.getClass(), ParallelStage.class);
assertEquals(boosterStage0Context.component.getID(), boosterStage.getID());
assertEquals(boosterStage0Context.instanceNumber, 0);
{
final Coordinate loc = boosterStage0Context.getLocation();
assertEquals(loc.x, 0.484, EPSILON);
@ -417,9 +405,9 @@ public class FlightConfigurationTest extends BaseTestCase {
}
final InstanceContext boosterStage1Context = boosterStageContextList.get(1);
assertThat((Class<ParallelStage>) boosterStage1Context.component.getClass(), equalTo(ParallelStage.class));
assertThat(boosterStage1Context.component.getID(), equalTo(boosterStage.getID()));
assertThat(boosterStage1Context.instanceNumber, equalTo(1));
assertEquals(boosterStage1Context.component.getClass(), ParallelStage.class);
assertEquals(boosterStage1Context.component.getID(), boosterStage.getID());
assertEquals(boosterStage1Context.instanceNumber, 1);
{
final Coordinate loc = boosterStage1Context.getLocation();
assertEquals(loc.x, 0.484, EPSILON);
@ -435,9 +423,9 @@ public class FlightConfigurationTest extends BaseTestCase {
final InstanceContext boosterBodyContext = boosterBodyContextList.get(1);
// this is the instance number per-parent
assertThat(boosterBodyContext.instanceNumber, equalTo(0));
assertEquals(boosterBodyContext.instanceNumber, 0);
assertThat((Class<BodyTube>) boosterBodyContext.component.getClass(), equalTo(BodyTube.class));
assertEquals(boosterBodyContext.component.getClass(), BodyTube.class);
final Coordinate bodyTubeLocation = boosterBodyContext.getLocation();
assertEquals(bodyTubeLocation.x, 0.564, EPSILON);
@ -450,32 +438,32 @@ public class FlightConfigurationTest extends BaseTestCase {
assertEquals(8, mmtContextList.size());
final InstanceContext motorTubeContext0 = mmtContextList.get(4);
assertThat((Class<InnerTube>) motorTubeContext0.component.getClass(), equalTo(InnerTube.class));
assertThat(motorTubeContext0.instanceNumber, equalTo(0));
assertEquals(motorTubeContext0.component.getClass(), InnerTube.class);
assertEquals(motorTubeContext0.instanceNumber, 0);
final Coordinate motorTube0Location = motorTubeContext0.getLocation();
assertEquals(motorTube0Location.x, 1.214, EPSILON);
assertEquals(motorTube0Location.y, -0.062, EPSILON);
assertEquals(motorTube0Location.z, -0.015, EPSILON);
final InstanceContext motorTubeContext1 = mmtContextList.get(5);
assertThat((Class<InnerTube>) motorTubeContext1.component.getClass(), equalTo(InnerTube.class));
assertThat(motorTubeContext1.instanceNumber, equalTo(1));
assertEquals(motorTubeContext1.component.getClass(), InnerTube.class);
assertEquals(motorTubeContext1.instanceNumber, 1);
final Coordinate motorTube1Location = motorTubeContext1.getLocation();
assertEquals(motorTube1Location.x, 1.214, EPSILON);
assertEquals(motorTube1Location.y, -0.092, EPSILON);
assertEquals(motorTube1Location.z, -0.015, EPSILON);
final InstanceContext motorTubeContext2 = mmtContextList.get(6);
assertThat((Class<InnerTube>) motorTubeContext2.component.getClass(), equalTo(InnerTube.class));
assertThat(motorTubeContext2.instanceNumber, equalTo(2));
assertEquals(motorTubeContext2.component.getClass(), InnerTube.class);
assertEquals(motorTubeContext2.instanceNumber, 2);
final Coordinate motorTube2Location = motorTubeContext2.getLocation();
assertEquals(motorTube2Location.x, 1.214, EPSILON);
assertEquals(motorTube2Location.y, -0.092, EPSILON);
assertEquals(motorTube2Location.z, 0.015, EPSILON);
final InstanceContext motorTubeContext3 = mmtContextList.get(7);
assertThat((Class<InnerTube>) motorTubeContext3.component.getClass(), equalTo(InnerTube.class));
assertThat(motorTubeContext3.instanceNumber, equalTo(3));
assertEquals(motorTubeContext3.component.getClass(), InnerTube.class);
assertEquals(motorTubeContext3.instanceNumber, 3);
final Coordinate motorTube3Location = motorTubeContext3.getLocation();
assertEquals(motorTube3Location.x, 1.214, EPSILON);
assertEquals(motorTube3Location.y, -0.062, EPSILON);
@ -488,27 +476,24 @@ public class FlightConfigurationTest extends BaseTestCase {
assertEquals(6, finContextList.size());
final InstanceContext boosterFinContext0 = finContextList.get(3);
assertThat((Class<TrapezoidFinSet>) boosterFinContext0.component.getClass(),
equalTo(TrapezoidFinSet.class));
assertThat(boosterFinContext0.instanceNumber, equalTo(0));
assertEquals(boosterFinContext0.component.getClass(), TrapezoidFinSet.class);
assertEquals(boosterFinContext0.instanceNumber, 0);
final Coordinate boosterFin0Location = boosterFinContext0.getLocation();
assertEquals(1.044, boosterFin0Location.x, EPSILON);
assertEquals(-0.1155, boosterFin0Location.y, EPSILON);
assertEquals(0.0, boosterFin0Location.z, EPSILON);
final InstanceContext boosterFinContext1 = finContextList.get(4);
assertThat((Class<TrapezoidFinSet>) boosterFinContext1.component.getClass(),
equalTo(TrapezoidFinSet.class));
assertThat(boosterFinContext1.instanceNumber, equalTo(1));
assertEquals(boosterFinContext1.component.getClass(), TrapezoidFinSet.class);
assertEquals(boosterFinContext1.instanceNumber, 1);
final Coordinate boosterFin1Location = boosterFinContext1.getLocation();
assertEquals(1.044, boosterFin1Location.x, EPSILON);
assertEquals(-0.05775, boosterFin1Location.y, EPSILON);
assertEquals(-0.033341978, boosterFin1Location.z, EPSILON);
final InstanceContext boosterFinContext2 = finContextList.get(5);
assertThat((Class<TrapezoidFinSet>) boosterFinContext2.component.getClass(),
equalTo(TrapezoidFinSet.class));
assertThat(boosterFinContext2.instanceNumber, equalTo(2));
assertEquals(boosterFinContext2.component.getClass(), TrapezoidFinSet.class);
assertEquals(boosterFinContext2.instanceNumber, 2);
final Coordinate boosterFin2Location = boosterFinContext2.getLocation();
assertEquals(1.044, boosterFin2Location.x, EPSILON);
assertEquals(-0.05775, boosterFin2Location.y, EPSILON);
@ -531,32 +516,32 @@ public class FlightConfigurationTest extends BaseTestCase {
ArrayList<RocketComponent> components = selected.getCoreComponents();
// ^^^^ Test Target ^^^^
assertThat(components.size(), equalTo(10));
assertEquals(components.size(), 10);
final AxialStage payloadStage = (AxialStage) components.get(0);
assertThat(payloadStage.getName(), equalTo("Payload Fairing Stage"));
assertEquals(payloadStage.getName(), "Payload Fairing Stage");
final AxialStage coreStage = (AxialStage) components.get(1);
assertThat(coreStage.getName(), equalTo("Core Stage"));
assertEquals(coreStage.getName(), "Core Stage");
assertThat(components.get(2), instanceOf(NoseCone.class));
assertInstanceOf(NoseCone.class, components.get(2));
assertThat(components.get(3), instanceOf(BodyTube.class));
assertThat(components.get(3).getName(), equalTo("PL Fairing Body"));
assertInstanceOf(BodyTube.class, components.get(3));
assertEquals(components.get(3).getName(), "PL Fairing Body");
assertThat(components.get(4), instanceOf(Transition.class));
assertInstanceOf(Transition.class, components.get(4));
assertThat(components.get(5), instanceOf(BodyTube.class));
assertThat(components.get(5).getName(), equalTo("Upper Stage Body"));
assertInstanceOf(BodyTube.class, components.get(5));
assertEquals(components.get(5).getName(), "Upper Stage Body");
assertThat(components.get(6), instanceOf(BodyTube.class));
assertThat(components.get(6).getName(), equalTo("Interstage"));
assertInstanceOf(BodyTube.class, components.get(6));
assertEquals(components.get(6).getName(), "Interstage");
assertThat(components.get(7), instanceOf(BodyTube.class));
assertThat(components.get(7).getName(), equalTo("Core Stage Body"));
assertInstanceOf(BodyTube.class, components.get(7));
assertEquals(components.get(7).getName(), "Core Stage Body");
assertThat(components.get(8), instanceOf(Parachute.class));
assertThat(components.get(9), instanceOf(ShockCord.class));
assertInstanceOf(Parachute.class, components.get(8));
assertInstanceOf(ShockCord.class, components.get(9));
}
@Test
@ -571,7 +556,7 @@ public class FlightConfigurationTest extends BaseTestCase {
ArrayList<RocketComponent> components = selected.getCoreComponents();
// ^^^^ Test Target ^^^^
assertThat(components.size(), equalTo(0));
assertEquals(components.size(), 0);
// =================================
selected.clearAllStages();
@ -581,13 +566,13 @@ public class FlightConfigurationTest extends BaseTestCase {
components = selected.getCoreComponents();
// ^^^^ Test Target ^^^^
assertThat(components.size(), equalTo(2));
assertEquals(components.size(), 2);
final AxialStage coreStage = (AxialStage) components.get(0);
assertThat(coreStage.getName(), equalTo("Core Stage"));
assertEquals(coreStage.getName(), "Core Stage");
assertThat(components.get(1), instanceOf(BodyTube.class));
assertThat(components.get(1).getName(), equalTo("Core Stage Body"));
assertInstanceOf(BodyTube.class, components.get(1));
assertEquals(components.get(1).getName(), "Core Stage Body");
}

View File

@ -1,17 +1,15 @@
package info.openrocket.core.rocketcomponent;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.awt.geom.Point2D;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.aerodynamics.AerodynamicForces;
import info.openrocket.core.aerodynamics.FlightConditions;
@ -1290,8 +1288,8 @@ public class FreeformFinSetTest extends BaseTestCase {
// this *already* has detected the intersection, and aborted...
Coordinate p1 = fins.getFinPoints()[1];
// ... which makes a rather hard-to-test functionality...
assertThat("Fin Set failed to detect an intersection! ", p1.x, not(equalTo(initPoints[1].x)));
assertThat("Fin Set failed to detect an intersection! ", p1.y, not(equalTo(initPoints[1].y)));
assertNotEquals("Fin Set failed to detect an intersection! ", p1.x, initPoints[1].x);
assertNotEquals("Fin Set failed to detect an intersection! ", p1.y, initPoints[1].y);
}
@Test

View File

@ -1,8 +1,8 @@
package info.openrocket.core.rocketcomponent;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.util.Coordinate;
import info.openrocket.core.util.MathUtil;

View File

@ -2,7 +2,7 @@ package info.openrocket.core.rocketcomponent;
import info.openrocket.core.util.BaseTestCase;
import info.openrocket.core.util.MathUtil;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.Assert;
public class MassObjectTest extends BaseTestCase {

View File

@ -3,13 +3,13 @@ package info.openrocket.core.rocketcomponent;
import info.openrocket.core.document.OpenRocketDocumentFactory;
import info.openrocket.core.util.BaseTestCase;
import info.openrocket.core.util.MathUtil;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class NoseConeTest extends BaseTestCase {
private final double EPSILON = MathUtil.EPSILON * 1000;

View File

@ -7,15 +7,15 @@ import info.openrocket.core.logging.WarningSet;
import info.openrocket.core.util.BaseTestCase;
import info.openrocket.core.util.MathUtil;
import info.openrocket.core.util.TestRockets;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class OverrideTest extends BaseTestCase {

View File

@ -1,12 +1,12 @@
package info.openrocket.core.rocketcomponent;
//import junit.framework.TestCase;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import junit.framework.Assert;
import info.openrocket.core.rocketcomponent.position.*;
import info.openrocket.core.util.Coordinate;
import info.openrocket.core.util.TestRockets;
@ -77,32 +77,28 @@ public class ParallelStageTest extends BaseTestCase {
AxialStage payloadStage = (AxialStage) rocket.getChild(0);
RocketComponent payloadNose = payloadStage.getChild(0);
RocketComponent payloadBody = payloadStage.getChild(1);
assertThat(" createTestRocket failed: is payload stage an ancestor of the payload stage? ",
payloadStage.isAncestor(payloadStage), equalTo(false));
assertThat(" createTestRocket failed: is payload stage an ancestor of the payload nose? ",
payloadStage.isAncestor(payloadNose), equalTo(true));
assertThat(" createTestRocket failed: is the rocket an ancestor of the sustainer Nose? ",
rocket.isAncestor(payloadNose), equalTo(true));
assertThat(" createTestRocket failed: is payload Body an ancestor of the payload Nose? ",
payloadBody.isAncestor(payloadNose), equalTo(false));
assertFalse(" createTestRocket failed: is payload stage an ancestor of the payload stage? ", payloadStage.isAncestor(payloadStage));
assertTrue(" createTestRocket failed: is payload stage an ancestor of the payload nose? ", payloadStage.isAncestor(payloadNose));
assertTrue(" createTestRocket failed: is the rocket an ancestor of the sustainer Nose? ", rocket.isAncestor(payloadNose));
assertFalse(" createTestRocket failed: is payload Body an ancestor of the payload Nose? ", payloadBody.isAncestor(payloadNose));
int relToExpected = -1;
int relToStage = payloadStage.getRelativeToStage();
assertThat(" createTestRocket failed: sustainer relative position: ", relToStage, equalTo(relToExpected));
assertEquals(" createTestRocket failed: sustainer relative position: ", relToStage, relToExpected);
double expectedPayloadLength = 0.564;
Assert.assertEquals(payloadStage.getLength(), expectedPayloadLength, EPSILON);
assertEquals(payloadStage.getLength(), expectedPayloadLength, EPSILON);
double expectedPayloadStageX = 0;
Assert.assertEquals(payloadStage.getPosition().x, expectedPayloadStageX, EPSILON);
Assert.assertEquals(payloadStage.getComponentLocations()[0].x, expectedPayloadStageX, EPSILON);
assertEquals(payloadStage.getPosition().x, expectedPayloadStageX, EPSILON);
assertEquals(payloadStage.getComponentLocations()[0].x, expectedPayloadStageX, EPSILON);
Assert.assertEquals(0, payloadNose.getPosition().x, EPSILON);
Assert.assertEquals(0, payloadNose.getComponentLocations()[0].x, EPSILON);
assertEquals(0, payloadNose.getPosition().x, EPSILON);
assertEquals(0, payloadNose.getComponentLocations()[0].x, EPSILON);
double expectedPayloadBodyX = payloadNose.getLength();
Assert.assertEquals(payloadBody.getPosition().x, expectedPayloadBodyX, EPSILON);
Assert.assertEquals(payloadBody.getComponentLocations()[0].x, expectedPayloadBodyX, EPSILON);
assertEquals(payloadBody.getPosition().x, expectedPayloadBodyX, EPSILON);
assertEquals(payloadBody.getComponentLocations()[0].x, expectedPayloadBodyX, EPSILON);
}
// WARNING: this test will not pass unless 'testAddTopStage' is passing as well
@ -117,25 +113,25 @@ public class ParallelStageTest extends BaseTestCase {
AxialStage payloadStage = (AxialStage) rocket.getChild(0);
final double expectedPayloadLength = 0.564;
final double payloadLength = payloadStage.getLength();
Assert.assertEquals(payloadLength, expectedPayloadLength, EPSILON);
assertEquals(payloadLength, expectedPayloadLength, EPSILON);
// Core Stage
AxialStage coreStage = (AxialStage) rocket.getChild(1);
double expectedCoreLength = 0.8;
assertThat(" createTestRocket failed: @ Core size: ", coreStage.getLength(), equalTo(expectedCoreLength));
assertEquals(" createTestRocket failed: @ Core size: ", coreStage.getLength(), expectedCoreLength);
int relToExpected = 0;
int relToStage = coreStage.getRelativeToStage();
assertThat(" createTestRocket failed! @ core relative position: ", relToStage, equalTo(relToExpected));
assertEquals(" createTestRocket failed! @ core relative position: ", relToStage, relToExpected);
final double expectedCoreStageX = payloadLength;
Assert.assertEquals(expectedCoreStageX, 0.564, EPSILON);
Assert.assertEquals(coreStage.getPosition().x, expectedCoreStageX, EPSILON);
Assert.assertEquals(coreStage.getComponentLocations()[0].x, expectedCoreStageX, EPSILON);
assertEquals(expectedCoreStageX, 0.564, EPSILON);
assertEquals(coreStage.getPosition().x, expectedCoreStageX, EPSILON);
assertEquals(coreStage.getComponentLocations()[0].x, expectedCoreStageX, EPSILON);
RocketComponent coreBody = coreStage.getChild(0);
Assert.assertEquals(coreBody.getPosition().x, 0.0, EPSILON);
Assert.assertEquals(coreBody.getComponentLocations()[0].x, expectedCoreStageX, EPSILON);
assertEquals(coreBody.getPosition().x, 0.0, EPSILON);
assertEquals(coreBody.getComponentLocations()[0].x, expectedCoreStageX, EPSILON);
}
@ -148,13 +144,13 @@ public class ParallelStageTest extends BaseTestCase {
AxialStage booster = (AxialStage) coreStage.getChild(0).getChild(0);
AxialStage sustainerPrev = sustainer.getUpperStage();
assertThat("sustainer parent is not found correctly: ", sustainerPrev, equalTo(null));
assertNull("sustainer parent is not found correctly: ", sustainerPrev);
AxialStage corePrev = coreStage.getUpperStage();
assertThat("core parent is not found correctly: ", corePrev, equalTo(sustainer));
assertEquals("core parent is not found correctly: ", corePrev, sustainer);
AxialStage boosterPrev = booster.getUpperStage();
assertThat("booster parent is not found correctly: ", boosterPrev, equalTo(coreStage));
assertEquals("booster parent is not found correctly: ", boosterPrev, coreStage);
}
@Test
@ -168,10 +164,9 @@ public class ParallelStageTest extends BaseTestCase {
// without making the rocket 'external' and the Stage should be restricted to
// AFTER positioning.
sustainer.setAxialMethod(AxialMethod.ABSOLUTE);
assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.isAfter(),
equalTo(true));
assertThat("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.getAxialMethod(),
equalTo(AxialMethod.AFTER));
assertTrue("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.isAfter());
assertEquals("Setting a centerline stage to anything other than AFTER is ignored.", sustainer.getAxialMethod(),
AxialMethod.AFTER);
// vv function under test
sustainer.setAxialOffset(targetPosition.x);
@ -179,13 +174,13 @@ public class ParallelStageTest extends BaseTestCase {
String rocketTree = rocket.toDebugTree();
Coordinate resultantRelativePosition = sustainer.getPosition();
assertThat(" 'setAxialPosition(double)' failed:\n" + rocketTree + " Relative position: ",
resultantRelativePosition.x, equalTo(expectedPosition.x));
assertEquals(" 'setAxialPosition(double)' failed:\n" + rocketTree + " Relative position: ",
resultantRelativePosition.x, expectedPosition.x, EPSILON);
// for all stages, the absolute position should equal the relative, because the
// direct parent is the rocket component (i.e. the Rocket)
Coordinate resultantAbsolutePosition = sustainer.getComponentLocations()[0];
assertThat(" 'setAxialPosition(double)' failed:\n" + rocketTree + " Absolute position: ",
resultantAbsolutePosition.x, equalTo(expectedPosition.x));
assertEquals(" 'setAxialPosition(double)' failed:\n" + rocketTree + " Absolute position: ",
resultantAbsolutePosition.x, expectedPosition.x, EPSILON);
}
@ -200,7 +195,7 @@ public class ParallelStageTest extends BaseTestCase {
parallelBoosterSet.setRadiusOffset(2.0);
// ^^ function under test
assertThat(" 'setInstancecount(int)' failed: ", 2, equalTo(parallelBoosterSet.getInstanceCount()));
assertEquals(" 'setInstancecount(int)' failed: ", 2, parallelBoosterSet.getInstanceCount());
assertFalse(RadiusMethod.FREE.clampToZero());
assertEquals(" error while setting radius method: ", RadiusMethod.FREE, parallelBoosterSet.getRadiusMethod());
@ -226,7 +221,7 @@ public class ParallelStageTest extends BaseTestCase {
parallelBoosterStage.setRadiusOffset(4.0);
// ^^^^ function under test
assertThat(" 'setInstancecount(int)' failed: ", 2, equalTo(parallelBoosterStage.getInstanceCount()));
assertEquals(" 'setInstancecount(int)' failed: ", 2, parallelBoosterStage.getInstanceCount());
assertTrue(RadiusMethod.SURFACE.clampToZero());
assertEquals(" error while setting radius method: ", RadiusMethod.SURFACE,
@ -379,8 +374,7 @@ public class ParallelStageTest extends BaseTestCase {
int expectedRelativeIndex = -1;
int resultantRelativeIndex = payloadStage.getRelativeToStage();
assertThat(" 'setRelativeToStage(int)' failed. Relative stage index:", expectedRelativeIndex,
equalTo(resultantRelativeIndex));
assertEquals(" 'setRelativeToStage(int)' failed. Relative stage index:", expectedRelativeIndex, resultantRelativeIndex);
// vv function under test
// a centerline stage is not freely movable
@ -415,23 +409,23 @@ public class ParallelStageTest extends BaseTestCase {
double expectedRelativeX = 0.2;
double expectedAbsoluteX = 0.764;
Coordinate resultantRelativePosition = boosterStage.getPosition();
assertThat(" 'setAxialPosition(double)' failed: \n" + treeDump + " Relative position: ",
resultantRelativePosition.x, equalTo(expectedRelativeX));
assertEquals(" 'setAxialPosition(double)' failed: \n" + treeDump + " Relative position: ",
resultantRelativePosition.x, expectedRelativeX, EPSILON);
// for all stages, the absolute position should equal the relative, because the
// direct parent is the rocket component (i.e. the Rocket)
Coordinate resultantAbsolutePosition = boosterStage.getComponentLocations()[0];
assertThat(" 'setAxialPosition(double)' failed: \n" + treeDump + " Absolute position: ",
resultantAbsolutePosition.x, equalTo(expectedAbsoluteX));
assertEquals(" 'setAxialPosition(double)' failed: \n" + treeDump + " Absolute position: ",
resultantAbsolutePosition.x, expectedAbsoluteX, EPSILON);
double resultantAxialOffset = boosterStage.getAxialOffset();
assertThat(" 'getAxialPosition()' failed: \n" + treeDump + " Axial Offset: ", resultantAxialOffset,
equalTo(targetOffset));
assertEquals(" 'getAxialPosition()' failed: \n" + treeDump + " Axial Offset: ", resultantAxialOffset,
targetOffset, EPSILON);
double resultantPositionValue = boosterStage.getAxialOffset();
assertThat(" 'setPositionValue()' failed: \n" + treeDump + " Position Value: ", resultantPositionValue,
equalTo(targetOffset));
assertEquals(" 'setPositionValue()' failed: \n" + treeDump + " Position Value: ", resultantPositionValue,
targetOffset, EPSILON);
}
@Test
@ -446,11 +440,11 @@ public class ParallelStageTest extends BaseTestCase {
boosterStage.setAxialOffset(AxialMethod.MIDDLE, targetOffset);
// ^^ function under test
Assert.assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
Assert.assertEquals(0.16, boosterStage.getPosition().x, EPSILON);
assertEquals(0.16, boosterStage.getPosition().x, EPSILON);
Assert.assertEquals(0.724, boosterStage.getComponentLocations()[0].x, EPSILON);
assertEquals(0.724, boosterStage.getComponentLocations()[0].x, EPSILON);
}
@Test
@ -464,11 +458,11 @@ public class ParallelStageTest extends BaseTestCase {
boosterStage.setAxialOffset(AxialMethod.BOTTOM, targetOffset);
// ^^ function under test
Assert.assertEquals(0.120, boosterStage.getPosition().x, EPSILON);
assertEquals(0.120, boosterStage.getPosition().x, EPSILON);
Assert.assertEquals(0.684, boosterStage.getComponentLocations()[0].x, EPSILON);
assertEquals(0.684, boosterStage.getComponentLocations()[0].x, EPSILON);
Assert.assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
}
@Test
@ -483,18 +477,18 @@ public class ParallelStageTest extends BaseTestCase {
boosterStage.setAxialOffset(AxialMethod.TOP, targetOffset);
// ^^ function under test
Assert.assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
Assert.assertEquals(targetOffset, boosterStage.getPosition().x, EPSILON);
assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
assertEquals(targetOffset, boosterStage.getPosition().x, EPSILON);
final double expectedRelativePositionX = 0.2;
final double resultantRelativePosition = boosterStage.getPosition().x;
Assert.assertEquals(expectedRelativePositionX, resultantRelativePosition, EPSILON);
assertEquals(expectedRelativePositionX, resultantRelativePosition, EPSILON);
// vv function under test
final double actualAbsoluteX = boosterStage.getAxialOffset(AxialMethod.ABSOLUTE);
// ^^ function under test
Assert.assertEquals(0.764, actualAbsoluteX, EPSILON);
assertEquals(0.764, actualAbsoluteX, EPSILON);
}
@Test
@ -509,14 +503,14 @@ public class ParallelStageTest extends BaseTestCase {
boosterStage.setAxialOffset(AxialMethod.TOP, targetOffset);
// ^^ function under test
Assert.assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
Assert.assertEquals(0.2, boosterStage.getPosition().x, EPSILON);
assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
assertEquals(0.2, boosterStage.getPosition().x, EPSILON);
// vv function under test
double actualPositionXAfter = boosterStage.getAxialOffset(AxialMethod.AFTER);
// ^^ function under test
Assert.assertEquals(-0.6, actualPositionXAfter, EPSILON);
assertEquals(-0.6, actualPositionXAfter, EPSILON);
}
@Test
@ -531,14 +525,14 @@ public class ParallelStageTest extends BaseTestCase {
boosterStage.setAxialOffset(AxialMethod.TOP, targetOffset);
// ^^ function under test
Assert.assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
Assert.assertEquals(0.2, boosterStage.getPosition().x, EPSILON);
assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
assertEquals(0.2, boosterStage.getPosition().x, EPSILON);
// vv function under test
final double actualAxialPosition = boosterStage.getAxialOffset(AxialMethod.MIDDLE);
// ^^ function under test
Assert.assertEquals(0.24, actualAxialPosition, EPSILON);
assertEquals(0.24, actualAxialPosition, EPSILON);
}
@Test
@ -553,14 +547,14 @@ public class ParallelStageTest extends BaseTestCase {
boosterStage.setAxialOffset(AxialMethod.TOP, targetOffset);
// ^^ function under test
Assert.assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
Assert.assertEquals(0.2, boosterStage.getPosition().x, EPSILON);
assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
assertEquals(0.2, boosterStage.getPosition().x, EPSILON);
// vv function under test
double actualAxialBottomOffset = boosterStage.getAxialOffset(AxialMethod.BOTTOM);
// ^^ function under test
Assert.assertEquals(0.28, actualAxialBottomOffset, EPSILON);
assertEquals(0.28, actualAxialBottomOffset, EPSILON);
}
@Test
@ -574,14 +568,14 @@ public class ParallelStageTest extends BaseTestCase {
boosterStage.setAxialOffset(AxialMethod.BOTTOM, targetOffset);
// ^^ function under test
Assert.assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
Assert.assertEquals(0.120, boosterStage.getPosition().x, EPSILON);
assertEquals(targetOffset, boosterStage.getAxialOffset(), EPSILON);
assertEquals(0.120, boosterStage.getPosition().x, EPSILON);
// vv function under test
double actualAxialTopOffset = boosterStage.getAxialOffset(AxialMethod.TOP);
// ^^ function under test
Assert.assertEquals(0.12, actualAxialTopOffset, EPSILON);
assertEquals(0.12, actualAxialTopOffset, EPSILON);
}
@Test

View File

@ -1,19 +1,12 @@
package info.openrocket.core.rocketcomponent;
//import static org.hamcrest.CoreMatchers.equalTo;
//import static org.junit.Assert.assertEquals;
//import static org.junit.Assert.assertThat;
//import static org.junit.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.util.ArrayList;
import info.openrocket.core.util.BaseTestCase;
@ -74,11 +67,11 @@ public class ParameterSetTest extends BaseTestCase {
@Test
public void testEmptySet() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
TestParameter dtp = new TestParameter();
testSet.setDefault(dtp);
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertThat("set stores default value correctly: ", testSet.getDefault(), equalTo(dtp));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
assertEquals("set stores default value correctly: ", testSet.getDefault(), dtp);
}
@Test
@ -86,50 +79,50 @@ public class ParameterSetTest extends BaseTestCase {
FlightConfigurationId fcid2 = new FlightConfigurationId();
// i.e. requesting the value for a non-existent config id should return the
// default
assertThat("set stores id-value pair correctly : ", testSet.get(fcid2), equalTo(testSet.getDefault()));
assertThat("set contains wrong number of overrides: ", testSet.size(), equalTo(0));
assertEquals("set stores id-value pair correctly : ", testSet.get(fcid2), testSet.getDefault());
assertEquals("set contains wrong number of overrides: ", testSet.size(), 0);
FlightConfigurationId fcid_def = FlightConfigurationId.DEFAULT_VALUE_FCID;
assertThat("retrieving the via the special default key should produce the default value: ",
testSet.get(fcid_def), equalTo(testSet.getDefault()));
assertThat("set should still contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("retrieving the via the special default key should produce the default value: ",
testSet.get(fcid_def), testSet.getDefault());
assertEquals("set should still contain zero overrides: ", testSet.size(), 1);
}
@Test
public void testSetGetSecond() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
// fcid <=> tp2 should be stored....
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo(tp2));
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(1));
assertEquals("set stores default value correctly: ", testSet.get(fcid2), tp2);
assertEquals("set should contain zero overrides: ", testSet.size(), 1);
}
@Test(expected = IndexOutOfBoundsException.class)
public void testGetByNegativeIndex() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
// assertThat
// assertEquals
testSet.get(-1);
}
@Test(expected = IndexOutOfBoundsException.class)
public void testGetByTooHighIndex() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
assertThat("set should contain one override: ", testSet.size(), equalTo(1));
assertEquals("set should contain one override: ", testSet.size(), 1);
// assertThat
// assertEquals
testSet.get(1); // this should be off-by-one (too high)
}
@Test
public void testGetIdsLength() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
@ -139,17 +132,17 @@ public class ParameterSetTest extends BaseTestCase {
FlightConfigurationId fcid3 = new FlightConfigurationId();
testSet.set(fcid3, tp3);
assertThat("set should contain two overrides: ", testSet.size(), equalTo(2));
assertEquals("set should contain two overrides: ", testSet.size(), 2);
// testSet.getSortedConfigurationIDs()
// >> this function should ONLY return ids for the overrides
assertThat("getIds() broken!\n" + testSet.toDebug(), testSet.getIds().size(), equalTo(testSet.size()));
assertThat("getIds() broken!\n" + testSet.toDebug(), testSet.getIds().size(), equalTo(testSet.getIds().size()));
assertEquals("getIds() broken!\n" + testSet.toDebug(), testSet.getIds().size(), testSet.size());
assertEquals("getIds() broken!\n" + testSet.toDebug(), testSet.getIds().size(), testSet.getIds().size());
}
@Test
public void testGetByIndex() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
TestParameter tp1 = new TestParameter();
FlightConfigurationId fcid1 = new FlightConfigurationId();
@ -167,7 +160,7 @@ public class ParameterSetTest extends BaseTestCase {
FlightConfigurationId fcid4 = new FlightConfigurationId();
testSet.set(fcid4, tp4);
assertThat("set should contain two overrides: ", testSet.size(), equalTo(4));
assertEquals("set should contain two overrides: ", testSet.size(), 4);
ArrayList<FlightConfigurationId> refList = new ArrayList<FlightConfigurationId>();
refList.add(fcid1);
@ -175,70 +168,66 @@ public class ParameterSetTest extends BaseTestCase {
refList.add(fcid3);
refList.add(fcid4);
// assertThat
assertThat("retrieve-by-index broken!\n" + testSet.toDebug(), testSet.get(0),
equalTo(testSet.get(refList.get(0))));
assertThat("retrieve-by-index broken!\n" + testSet.toDebug(), testSet.get(1),
equalTo(testSet.get(refList.get(1))));
assertThat("retrieve-by-index broken!\n" + testSet.toDebug(), testSet.get(2),
equalTo(testSet.get(refList.get(2))));
assertThat("retrieve-by-index broken!\n" + testSet.toDebug(), testSet.get(3),
equalTo(testSet.get(refList.get(3))));
// assertEquals
assertEquals("retrieve-by-index broken!\n" + testSet.toDebug(), testSet.get(0), testSet.get(refList.get(0)));
assertEquals("retrieve-by-index broken!\n" + testSet.toDebug(), testSet.get(1), testSet.get(refList.get(1)));
assertEquals("retrieve-by-index broken!\n" + testSet.toDebug(), testSet.get(2), testSet.get(refList.get(2)));
assertEquals("retrieve-by-index broken!\n" + testSet.toDebug(), testSet.get(3), testSet.get(refList.get(3)));
}
@Test
public void testRemoveSecond() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
// fcid <=> tp2 should be stored....
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo(tp2));
assertThat("set should contain one override: ", testSet.size(), equalTo(1));
assertEquals("set stores default value correctly: ", testSet.get(fcid2), tp2);
assertEquals("set should contain one override: ", testSet.size(), 1);
testSet.set(fcid2, null);
// fcid <=> tp2 should be stored....
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo(testSet.getDefault()));
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("set stores default value correctly: ", testSet.get(fcid2), testSet.getDefault());
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
}
@Test
public void testGetByValue() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertThat("retrieving the default value should produce the special default key: ",
testSet.getId(testSet.getDefault()), equalTo(FlightConfigurationId.DEFAULT_VALUE_FCID));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
assertEquals("retrieving the default value should produce the special default key: ",
testSet.getId(testSet.getDefault()), FlightConfigurationId.DEFAULT_VALUE_FCID);
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
// fcid <=> tp2 should be stored....
assertThat("set should contain one override: ", testSet.size(), equalTo(1));
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo(tp2));
assertEquals("set should contain one override: ", testSet.size(), 1);
assertEquals("set stores default value correctly: ", testSet.get(fcid2), tp2);
// now retrieve that same parameter by value
FlightConfigurationId fcid3 = testSet.getId(tp2);
assertThat("set should contain one override: ", testSet.size(), equalTo(1));
assertThat("set stores default value correctly: ", fcid2, equalTo(fcid3));
assertThat("set stores default value correctly: ", testSet.get(fcid3), equalTo(tp2));
assertEquals("set should contain one override: ", testSet.size(), 1);
assertEquals("set stores default value correctly: ", fcid2, fcid3);
assertEquals("set stores default value correctly: ", testSet.get(fcid3), tp2);
}
@Test
public void testCloneSecond() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(0));
assertEquals("set should contain zero overrides: ", testSet.size(), 0);
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
// fcid <=> tp2 should be stored....
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(1));
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo(tp2));
assertEquals("set should contain zero overrides: ", testSet.size(), 1);
assertEquals("set stores default value correctly: ", testSet.get(fcid2), tp2);
FlightConfigurationId fcid3 = new FlightConfigurationId();
testSet.copyFlightConfiguration(fcid2, fcid3);
// fcid <=> tp2 should be stored....
assertThat("set should contain zero overrides: ", testSet.size(), equalTo(2));
assertThat("set stores default value correctly: ", testSet.get(fcid3), not(testSet.getDefault()));
assertEquals("set should contain zero overrides: ", testSet.size(), 2);
assertNotEquals("set stores default value correctly: ", testSet.get(fcid3), testSet.getDefault());
}
/**

View File

@ -2,10 +2,10 @@ package info.openrocket.core.rocketcomponent;
import info.openrocket.core.util.Coordinate;
import info.openrocket.core.util.MathUtil;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.util.BaseTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class RailButtonTest extends BaseTestCase {
protected final double EPSILON = MathUtil.EPSILON;

View File

@ -1,14 +1,10 @@
package info.openrocket.core.rocketcomponent;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.closeTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import info.openrocket.core.util.ArrayList;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.rocketcomponent.position.AxialMethod;
import info.openrocket.core.rocketcomponent.position.AngleMethod;
@ -75,39 +71,39 @@ public class RocketTest extends BaseTestCase {
NoseCone nose = (NoseCone) stage.getChild(0);
expLoc = new Coordinate(0, 0, 0);
actLoc = nose.getComponentLocations()[0];
assertThat(nose.getName() + " not positioned correctly: ", actLoc, equalTo(expLoc));
assertEquals(nose.getName() + " not positioned correctly: ", actLoc, expLoc);
BodyTube body = (BodyTube) stage.getChild(1);
expLoc = new Coordinate(0.07, 0, 0);
actLoc = body.getComponentLocations()[0];
assertThat(body.getName() + " not positioned correctly: ", actLoc, equalTo(expLoc));
assertEquals(body.getName() + " not positioned correctly: ", actLoc, expLoc);
{
FinSet fins = (FinSet) body.getChild(0);
Coordinate[] actLocs = fins.getComponentLocations();
assertThat(fins.getName() + " have incorrect count: ", fins.getInstanceCount(), equalTo(3));
assertEquals(fins.getName() + " have incorrect count: ", fins.getInstanceCount(), 3);
{ // fin #1
expLoc = new Coordinate(0.22, 0.012, 0);
assertThat(fins.getName() + " not positioned correctly: ", actLocs[0], equalTo(expLoc));
assertEquals(fins.getName() + " not positioned correctly: ", actLocs[0], expLoc);
}
LaunchLug lugs = (LaunchLug) body.getChild(1);
expLoc = new Coordinate(0.181, -0.015, 0);
assertThat(lugs.getName() + " have incorrect count: ", lugs.getInstanceCount(), equalTo(1));
assertEquals(lugs.getName() + " have incorrect count: ", lugs.getInstanceCount(), 1);
actLocs = lugs.getComponentLocations();
{ // singular instance:
assertThat(lugs.getName() + " not positioned correctly: ", actLocs[0], equalTo(expLoc));
assertEquals(lugs.getName() + " not positioned correctly: ", actLocs[0], expLoc);
}
InnerTube mmt = (InnerTube) body.getChild(2);
expLoc = new Coordinate(0.203, 0, 0);
actLoc = mmt.getComponentLocations()[0];
assertThat(mmt.getName() + " not positioned correctly: ", actLoc, equalTo(expLoc));
assertEquals(mmt.getName() + " not positioned correctly: ", actLoc, expLoc);
{
EngineBlock block = (EngineBlock) mmt.getChild(0);
expLoc = new Coordinate(0.203, 0, 0);
actLoc = block.getComponentLocations()[0];
assertThat(block.getName() + " not positioned correctly: ", actLoc, equalTo(expLoc));
assertEquals(block.getName() + " not positioned correctly: ", actLoc, expLoc);
}
}
@ -115,10 +111,10 @@ public class RocketTest extends BaseTestCase {
Parachute chute = (Parachute) body.getChild(3);
expLoc = new Coordinate(0.098, 0, 0);
actLoc = chute.getComponentLocations()[0];
assertThat(chute.getName() + " not positioned correctly: ", actLoc, equalTo(expLoc));
assertEquals(chute.getName() + " not positioned correctly: ", actLoc, expLoc);
CenteringRing ring = (CenteringRing) body.getChild(4);
assertThat(ring.getName() + " not instanced correctly: ", ring.getInstanceCount(), equalTo(2));
assertEquals(ring.getName() + " not instanced correctly: ", ring.getInstanceCount(), 2);
// singleton instances follow different code paths
ring.setInstanceCount(1);
expLoc = new Coordinate(0.21, 0, 0);
@ -126,20 +122,20 @@ public class RocketTest extends BaseTestCase {
assertEquals(" position x fail: ", expLoc.x, actLoc.x, EPSILON);
assertEquals(" position y fail: ", expLoc.y, actLoc.y, EPSILON);
assertEquals(" position z fail: ", expLoc.z, actLoc.z, EPSILON);
assertThat(ring.getName() + " not positioned correctly: ", actLoc, equalTo(expLoc));
assertEquals(ring.getName() + " not positioned correctly: ", actLoc, expLoc);
ring.setInstanceCount(2);
Coordinate[] actLocs = ring.getComponentLocations();
{ // first instance
expLoc = new Coordinate(0.21, 0, 0);
actLoc = actLocs[0];
assertThat(ring.getName() + " not positioned correctly: ", actLoc, equalTo(expLoc));
assertEquals(ring.getName() + " not positioned correctly: ", actLoc, expLoc);
}
{ // second instance
assertThat(ring.getName() + " not instanced correctly: ", ring.getInstanceCount(), equalTo(2));
assertEquals(ring.getName() + " not instanced correctly: ", ring.getInstanceCount(), 1);
expLoc = new Coordinate(0.245, 0, 0);
actLoc = actLocs[1];
assertThat(ring.getName() + " not positioned correctly: ", actLoc, equalTo(expLoc));
assertEquals(ring.getName() + " not positioned correctly: ", actLoc, expLoc);
}
}
@ -184,7 +180,7 @@ public class RocketTest extends BaseTestCase {
{ // fin #1
final Coordinate expLoc = new Coordinate(0.22, 0.012, 0);
final Coordinate[] actLocs = fins.getComponentLocations();
assertThat(fins.getName() + " not positioned correctly: ", actLocs[0], equalTo(expLoc));
assertEquals(fins.getName() + " not positioned correctly: ", actLocs[0], expLoc);
}
}
@ -226,7 +222,7 @@ public class RocketTest extends BaseTestCase {
{
BodyTube bodyPrior = (BodyTube) rocket.getChild(0).getChild(1);
Coordinate locPrior = bodyPrior.getComponentLocations()[0];
assertThat(locPrior.x, equalTo(0.07));
assertEquals(locPrior.x, 0.07, EPSILON);
}
// remove the nose cone, causing the bodytube to reposition:
@ -235,7 +231,7 @@ public class RocketTest extends BaseTestCase {
{
BodyTube tubePost = (BodyTube) rocket.getChild(0).getChild(0);
Coordinate locPost = tubePost.getComponentLocations()[0];
assertThat(locPost.x, equalTo(0.0));
assertEquals(locPost.x, 0.0, EPSILON);
}
}
@ -329,26 +325,26 @@ public class RocketTest extends BaseTestCase {
BodyTube body = (BodyTube) boosterStage.getChild(0);
Coordinate[] bodyLocs = body.getComponentLocations();
expLoc = new Coordinate(0.27, 0, 0);
assertThat(body.getName() + " not positioned correctly: ", bodyLocs[0], equalTo(expLoc));
assertEquals(body.getName() + " not positioned correctly: ", bodyLocs[0], 1);
{
TubeCoupler coupler = (TubeCoupler) body.getChild(0);
actLocs = coupler.getComponentLocations();
expLoc = new Coordinate(0.255, 0, 0);
assertThat(coupler.getName() + " not positioned correctly: ", actLocs[0], equalTo(expLoc));
assertEquals(coupler.getName() + " not positioned correctly: ", actLocs[0], expLoc);
FinSet fins = (FinSet) body.getChild(1);
actLocs = fins.getComponentLocations();
assertThat(fins.getName() + " have incorrect count: ", fins.getInstanceCount(), equalTo(3));
assertEquals(fins.getName() + " have incorrect count: ", fins.getInstanceCount(), 3);
{ // fin #1
expLoc = new Coordinate(0.28, 0.012, 0);
assertThat(fins.getName() + " not positioned correctly: ", actLocs[0], equalTo(expLoc));
assertEquals(fins.getName() + " not positioned correctly: ", actLocs[0], expLoc);
}
InnerTube mmt = (InnerTube) body.getChild(2);
actLoc = mmt.getComponentLocations()[0];
expLoc = new Coordinate(0.285, 0, 0);
assertThat(mmt.getName() + " not positioned correctly: ", actLoc, equalTo(expLoc));
assertEquals(mmt.getName() + " not positioned correctly: ", actLoc, expLoc);
}
}

View File

@ -1,14 +1,14 @@
package info.openrocket.core.rocketcomponent;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import info.openrocket.core.rocketcomponent.position.AxialMethod;
import info.openrocket.core.rocketcomponent.position.RadiusMethod;
import info.openrocket.core.util.BaseTestCase;
import info.openrocket.core.util.TestRockets;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class SymmetricComponentTest extends BaseTestCase {

View File

@ -1,13 +1,13 @@
package info.openrocket.core.rocketcomponent;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import info.openrocket.core.material.Material;
import info.openrocket.core.util.Coordinate;
import info.openrocket.core.util.BaseTestCase;
import info.openrocket.core.util.MathUtil;
import static info.openrocket.core.util.MathUtil.pow2;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class SymmetricComponentVolumeTest extends BaseTestCase {
final double EPSILON = MathUtil.EPSILON * 1000;

View File

@ -1,10 +1,8 @@
package info.openrocket.core.rocketcomponent;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.util.MathUtil;
import info.openrocket.core.util.TestRockets;
@ -19,7 +17,7 @@ public class TransitionTest extends BaseTestCase {
assertEquals("nose cone length is wrong ", 0.06, nose.getLength(), EPSILON);
assertEquals("nose cone fore radius is wrong ", 0.00, nose.getForeRadius(), EPSILON);
assertEquals("nose cone aft radius is wrong ", 0.01, nose.getAftRadius(), EPSILON);
assertThat("nose cone shape type is wrong ", Transition.Shape.CONICAL, equalTo(nose.getShapeType()));
assertEquals("nose cone shape type is wrong ", Transition.Shape.CONICAL, nose.getShapeType());
assertEquals("nose cone shape parameter is wrong ", 0.0, nose.getShapeParameter(), EPSILON);
assertEquals("bad shape - conical forward ", 0.0, nose.getRadius(0.00), EPSILON);
@ -41,7 +39,7 @@ public class TransitionTest extends BaseTestCase {
assertEquals("nose cone length is wrong ", 5.0, nose.getLength(), EPSILON);
assertEquals("nose cone fore radius is wrong ", 0.5, nose.getForeRadius(), EPSILON);
assertEquals("nose cone aft radius is wrong ", 1.0, nose.getAftRadius(), EPSILON);
assertThat("nose cone shape type is wrong ", Transition.Shape.CONICAL, equalTo(nose.getShapeType()));
assertEquals("nose cone shape type is wrong ", Transition.Shape.CONICAL, nose.getShapeType());
assertEquals("nose cone shape parameter is wrong ", 0.0, nose.getShapeParameter(), EPSILON);
assertEquals("bad shape - conical forward transition", 0.5, nose.getRadius(0.0), EPSILON);
@ -64,7 +62,7 @@ public class TransitionTest extends BaseTestCase {
assertEquals("nose cone length is wrong ", 5.0, tail.getLength(), EPSILON);
assertEquals("nose cone fore radius is wrong ", 1.0, tail.getForeRadius(), EPSILON);
assertEquals("nose cone aft radius is wrong ", 0.5, tail.getAftRadius(), EPSILON);
assertThat("nose cone shape type is wrong ", Transition.Shape.CONICAL, equalTo(tail.getShapeType()));
assertEquals("nose cone shape type is wrong ", Transition.Shape.CONICAL, tail.getShapeType());
assertEquals("nose cone shape parameter is wrong ", 0.0, tail.getShapeParameter(), EPSILON);
assertEquals("bad shape - conical forward transition", 1.0, tail.getRadius(0.0), EPSILON);
@ -86,7 +84,7 @@ public class TransitionTest extends BaseTestCase {
assertEquals("nose cone length is wrong ", 8.0, nose.getLength(), EPSILON);
assertEquals("nose cone fore radius is wrong ", 0.0, nose.getForeRadius(), EPSILON);
assertEquals("nose cone aft radius is wrong ", 1.0, nose.getAftRadius(), EPSILON);
assertThat("nose cone shape type is wrong ", Transition.Shape.OGIVE, equalTo(nose.getShapeType()));
assertEquals("nose cone shape type is wrong ", Transition.Shape.OGIVE, nose.getShapeType());
assertEquals("nose cone shape parameter is wrong ", 1.0, nose.getShapeParameter(), EPSILON);
assertEquals("bad shape - conical forward transition", 0.0, nose.getRadius(0.0), EPSILON);
@ -111,7 +109,7 @@ public class TransitionTest extends BaseTestCase {
assertEquals("nose cone length is wrong ", 6.0, transition.getLength(), EPSILON);
assertEquals("nose cone fore radius is wrong ", 0.44135, transition.getForeRadius(), EPSILON);
assertEquals("nose cone aft radius is wrong ", 1.0, transition.getAftRadius(), EPSILON);
assertThat("nose cone shape type is wrong ", Transition.Shape.OGIVE, equalTo(transition.getShapeType()));
assertEquals("nose cone shape type is wrong ", Transition.Shape.OGIVE, transition.getShapeType());
assertEquals("nose cone shape parameter is wrong ", 1.0, transition.getShapeParameter(), EPSILON);
assertEquals("bad shape - conical forward transition", 0.44135250736, transition.getRadius(0.0), EPSILON);
@ -134,7 +132,7 @@ public class TransitionTest extends BaseTestCase {
assertEquals("nose cone length is wrong ", 6.0, transition.getLength(), EPSILON);
assertEquals("nose cone fore radius is wrong ", 1.0, transition.getForeRadius(), EPSILON);
assertEquals("nose cone aft radius is wrong ", 0.44135, transition.getAftRadius(), EPSILON);
assertThat("nose cone shape type is wrong ", Transition.Shape.OGIVE, equalTo(transition.getShapeType()));
assertEquals("nose cone shape type is wrong ", Transition.Shape.OGIVE, transition.getShapeType());
assertEquals("nose cone shape parameter is wrong ", 1.0, transition.getShapeParameter(), EPSILON);
assertEquals("bad shape - conical forward transition", 1.0, transition.getRadius(0.0), EPSILON);
@ -154,7 +152,7 @@ public class TransitionTest extends BaseTestCase {
assertEquals("Alpha3 nose cone length is wrong ", 0.07, nose.getLength(), EPSILON);
assertEquals("Alpha3 nose cone fore radius is wrong ", 0.00, nose.getForeRadius(), EPSILON);
assertEquals("Alpha3 nose cone aft radius is wrong ", 0.012, nose.getAftRadius(), EPSILON);
assertThat("Alpha3 nose cone shape type is wrong ", Transition.Shape.OGIVE, equalTo(nose.getShapeType()));
assertEquals("Alpha3 nose cone shape type is wrong ", Transition.Shape.OGIVE, nose.getShapeType());
assertEquals("Alpha3 nose cone shape parameter is wrong ", 1.0, nose.getShapeParameter(), EPSILON);
assertEquals("Alpha3 nose cone aft shoulder length is wrong ", 0.02, nose.getAftShoulderLength(), EPSILON);

View File

@ -1,8 +1,8 @@
package info.openrocket.core.rocketcomponent;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.material.Material;
import info.openrocket.core.rocketcomponent.position.*;

View File

@ -9,7 +9,7 @@ import info.openrocket.core.simulation.exception.SimulationException;
import info.openrocket.core.util.BaseTestCase;
import info.openrocket.core.util.TestRockets;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Test class that tests the effect on the simulation results of

View File

@ -12,13 +12,13 @@ import info.openrocket.core.rocketcomponent.RocketComponent;
import info.openrocket.core.simulation.exception.SimulationException;
import info.openrocket.core.util.BaseTestCase;
import info.openrocket.core.util.TestRockets;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;;
/**
* Tests to verify that simulations contain all the expected flight events.

View File

@ -15,17 +15,17 @@ import info.openrocket.core.startup.Application;
import info.openrocket.core.startup.MockPreferences;
import info.openrocket.core.startup.Preferences;
import info.openrocket.core.util.MathUtil;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class SimulationConditionsTest {
private final static double EPSILON = MathUtil.EPSILON;
@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
Module applicationModule = new PreferencesModule();
Module debugTranslator = new AbstractModule() {

View File

@ -1,10 +1,10 @@
package info.openrocket.core.simulation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.logging.WarningSet;

View File

@ -4,7 +4,7 @@ import info.openrocket.core.document.OpenRocketDocument;
import info.openrocket.core.document.OpenRocketDocumentFactory;
import info.openrocket.core.util.BaseTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestExpressions extends BaseTestCase {

View File

@ -1,12 +1,12 @@
package info.openrocket.core.simulation.extension.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import info.openrocket.core.startup.MockPreferences;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class TestScriptingUtil {

View File

@ -1,10 +1,10 @@
package info.openrocket.core.thrustcurve;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.InputStream;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.openrocket.core.util.BaseTestCase;

Some files were not shown because too many files have changed in this diff Show More