Skip to content

Commit

Permalink
Update tests to use JUnit 5
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <tsmock@meta.com>
  • Loading branch information
tsmock committed Nov 6, 2023
1 parent 90cd1c5 commit 6025be3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 49 deletions.
18 changes: 8 additions & 10 deletions test/unit/io/parser/BIMtoOSMParserTest.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
// License: AGPL. For details, see LICENSE file.
package io.parser;

import org.openstreetmap.josm.plugins.indoorhelper.io.parser.BIMtoOSMParser;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.openstreetmap.josm.TestUtils;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openstreetmap.josm.TestUtils;
import org.openstreetmap.josm.plugins.indoorhelper.io.parser.BIMtoOSMParser;

/**
* Unit tests of {@link BIMtoOSMParser} class.
*/
@Ignore("Causes unexpected error in Jenkins build")
@Disabled("Causes unexpected error in Jenkins build\n")
public class BIMtoOSMParserTest {
class BIMtoOSMParserTest {

/**
* Setup test.
*/
// @Rule
// public JOSMTestRules test = new JOSMTestRules().preferences();
// JOSMTestRules test = new JOSMTestRules().preferences();

String pluginDir = System.getProperty("user.dir");
String resourcePathDir = TestUtils.getTestDataRoot();
Expand All @@ -30,7 +28,7 @@ public class BIMtoOSMParserTest {
* Test case for {@link BIMtoOSMParser#parse} method.
*/
@Test
public void testParse() {
void testParse() {
// IFC2X3
assertParseTrue("test1_IFC2X3_TC1.ifc");
assertParseTrue("test2_IFC2X3_TC1.ifc");
Expand Down
36 changes: 18 additions & 18 deletions test/unit/io/parser/data/math/Matrix3DTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

//import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;
import org.openstreetmap.josm.plugins.indoorhelper.io.parser.math.Matrix3D;
import org.openstreetmap.josm.plugins.indoorhelper.io.parser.math.Vector3D;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Unit tests of {@link Matrix3D} class.
*/
public class Matrix3DTest {
class Matrix3DTest {
/**
* Setup test
*/
Expand All @@ -35,7 +35,7 @@ public class Matrix3DTest {
Vector3D matrix1TransformedPoint1 = new Vector3D(86.0, 105.8, 125.123);

@Test
public void testTransform() {
void testTransform() {
Vector3D v = new Vector3D(vector1);
matrix1.transform(v);
assertEquals(v.getX(), matrix1TransformedPoint1.getX(), 0.005);
Expand All @@ -44,7 +44,7 @@ public void testTransform() {
}

@Test
public void testMultiply() {
void testMultiply() {
Matrix3D m = new Matrix3D(matrix1);
m.multiply(10.0);
assertEquals(m.getM00(), matrix1.getM00() * 10.0, 0.005);
Expand Down Expand Up @@ -75,25 +75,25 @@ public void testMultiply() {
}

@Test
public void testInvert() {
void testInvert() {
Matrix3D m = new Matrix3D(matrix3);
m.invert();

assertEquals(m.getM00(), -(1.0 / 3.0), 0.005);
assertEquals(m.getM01(), 0.0, 0.005);
assertEquals(m.getM02(), (2.0 / 3.0), 0.005);
assertEquals(-(1.0 / 3.0), m.getM00(), 0.005);
assertEquals(0.0, m.getM01(), 0.005);
assertEquals((2.0 / 3.0), m.getM02(), 0.005);

assertEquals(m.getM10(), (2.0 / 3.0), 0.005);
assertEquals(m.getM11(), 0.0, 0.005);
assertEquals(m.getM12(), -(1.0 / 3.0), 0.005);
assertEquals((2.0 / 3.0), m.getM10(), 0.005);
assertEquals(0.0, m.getM11(), 0.005);
assertEquals(-(1.0 / 3.0), m.getM12(), 0.005);

assertEquals(m.getM20(), -2.0, 0.005);
assertEquals(m.getM21(), 1.0, 0.005);
assertEquals(m.getM22(), 0.0, 0.005);
assertEquals(-2.0, m.getM20(), 0.005);
assertEquals(1.0, m.getM21(), 0.005);
assertEquals(0.0, m.getM22(), 0.005);
}

@Test
public void testDet() {
assertEquals(matrix3.det(), 3.0);
void testDet() {
assertEquals(3.0, matrix3.det());
}
}
21 changes: 11 additions & 10 deletions test/unit/io/parser/optimizer/OutputOptimizerTest.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package io.parser.optimizer;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.openstreetmap.josm.plugins.indoorhelper.io.optimizer.OutputOptimizer;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.osm.Node;
import org.openstreetmap.josm.plugins.indoorhelper.io.optimizer.OutputOptimizer;
import org.openstreetmap.josm.testutils.DatasetFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Disabled("Causes java.lang.SecurityException: class \"org.openstreetmap.josm.tools.MemoryManagerTest\"'s " +
"signer information does not match signer information of other classes in the same package\n")
public class OutputOptimizerTest {
class OutputOptimizerTest {

/**
* Setup test.
*/
// @Rule
// public JOSMTestRules test = new JOSMTestRules().preferences();
// JOSMTestRules test = new JOSMTestRules().preferences();
@SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")

public ArrayList<LatLon> testNodes1 = new ArrayList<LatLon>() {
ArrayList<LatLon> testNodes1 = new ArrayList<LatLon>() {
{
add(new LatLon(50.81400880917, 12.9240191164));
add(new LatLon(50.81410474868, 12.92479892858));
Expand All @@ -44,7 +45,7 @@ public class OutputOptimizerTest {
* Test case for {@link OutputOptimizer#optimize} method.
*/
@Test
public void testOptimize() {
void testOptimize() {
// ArrayList<Node> nodes = llsToNodes(testNodes1);
// ArrayList<Way> ways = new ArrayList<>();
// Pair<ArrayList<Node>, ArrayList<Way>> testData = new Pair<>(nodes, ways);
Expand Down
10 changes: 5 additions & 5 deletions test/unit/model/LevelRangeVerifierTest.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// License: AGPL. For details, see LICENSE file.
package model;

import org.openstreetmap.josm.plugins.indoorhelper.model.LevelRangeVerifier;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;
import org.openstreetmap.josm.plugins.indoorhelper.model.LevelRangeVerifier;

/**
* Unit tests of {@link LevelRangeVerifier} class.
*/
public class LevelRangeVerifierTest {
class LevelRangeVerifierTest {

/**
* Test case for {@link LevelRangeVerifier#isPartOfWorkingLevel(String, int)} method.
*/
@Test
public void testIsPartOfWorkingLevel() {
void testIsPartOfWorkingLevel() {
assertTrue(LevelRangeVerifier.isPartOfWorkingLevel("-3--1", -3));
assertTrue(LevelRangeVerifier.isPartOfWorkingLevel("-3--1", -2));
assertTrue(LevelRangeVerifier.isPartOfWorkingLevel("-3--1", -1));
Expand Down
12 changes: 6 additions & 6 deletions test/unit/model/PresetCounterTest.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// License: AGPL. For details, see LICENSE file.
package model;

import org.openstreetmap.josm.plugins.indoorhelper.model.PresetCounter;
import org.openstreetmap.josm.plugins.indoorhelper.model.TagCatalog.IndoorObject;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;
import org.openstreetmap.josm.plugins.indoorhelper.model.PresetCounter;
import org.openstreetmap.josm.plugins.indoorhelper.model.TagCatalog.IndoorObject;

/**
* Unit tests of {@link PresetCounter} class.
*/
public class PresetCounterTest {
class PresetCounterTest {

/**
* Test case for testing the ranking functionality.
*/
@Test
public void testRanking() {
void testRanking() {
// input preparation
PresetCounter counter = new PresetCounter();

Expand Down

0 comments on commit 6025be3

Please sign in to comment.