Ignore:
Timestamp:
2023-03-13T21:59:27+01:00 (13 months ago)
Author:
taylor.smock
Message:

See #16567: Convert all assertion calls to JUnit 5 (patch by gaben, modified)

The modifications are as follows:

  • Merge DomainValidatorTest.testIDN and DomainValidatorTest.testIDNJava6OrLater
  • Update some tests to use @ParameterizedTest (DomainValidatorTest)
  • Replace various exception blocks with assertThrows. These typically looked like
        try {
            // Something that should throw an exception here
            fail("An exception should have been thrown");
        } catch (Exception e) {
            // Verify the exception matches expectations here
        }
    
  • Replace assertTrue(val instanceof Clazz) with assertInstanceOf
  • Replace JUnit 4 @Suite with JUnit 5 @Suite

Both the original patch and the modified patch fix various lint issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/corrector/ReverseWayTagCorrectorTest.java

    r17289 r18690  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.actions.corrector;
     3
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    37
    48import java.util.Collections;
     
    711import java.util.stream.Stream;
    812
    9 import org.junit.Assert;
    1013import org.junit.jupiter.api.Test;
    1114import org.junit.jupiter.api.extension.RegisterExtension;
     
    105108
    106109    private void assertSwitch(Tag oldTag, Tag newTag) {
    107         Assert.assertEquals(newTag, ReverseWayTagCorrector.TagSwitcher.apply(oldTag));
     110        assertEquals(newTag, ReverseWayTagCorrector.TagSwitcher.apply(oldTag));
    108111    }
    109112
     
    128131    void testSwitchingWayNodes() {
    129132        final Map<OsmPrimitive, List<TagCorrection>> tagCorrections = getTagCorrectionsForWay("direction=forward");
    130         Assert.assertEquals(1, tagCorrections.size());
    131         Assert.assertEquals(Collections.singletonList(new TagCorrection("direction", "forward", "direction", "backward")),
     133        assertEquals(1, tagCorrections.size());
     134        assertEquals(Collections.singletonList(new TagCorrection("direction", "forward", "direction", "backward")),
    132135                tagCorrections.values().iterator().next());
    133136    }
     
    138141    @Test
    139142    void testNotSwitchingWayNodes() {
    140         Assert.assertEquals(0, getTagCorrectionsForWay("direction=SSW").size());
    141         Assert.assertEquals(0, getTagCorrectionsForWay("direction=145").size());
     143        assertEquals(0, getTagCorrectionsForWay("direction=SSW").size());
     144        assertEquals(0, getTagCorrectionsForWay("direction=145").size());
    142145    }
    143146
     
    148151    void testIsReversible() {
    149152        Way w0 = buildWayWithMiddleNode("highway=stop");
    150         Assert.assertTrue(ReverseWayTagCorrector.isReversible(w0));
     153        assertTrue(ReverseWayTagCorrector.isReversible(w0));
    151154        Way w1 = buildWayWithMiddleNode("direction=forward");
    152         Assert.assertFalse(ReverseWayTagCorrector.isReversible(w1));
    153         Assert.assertEquals(3, w1.getNodesCount());
     155        assertFalse(ReverseWayTagCorrector.isReversible(w1));
     156        assertEquals(3, w1.getNodesCount());
    154157        w1.getNodes().forEach(n -> n.setKeys(null));
    155         Assert.assertTrue(ReverseWayTagCorrector.isReversible(w1));
     158        assertTrue(ReverseWayTagCorrector.isReversible(w1));
    156159        w1.put("oneway", "yes");
    157         Assert.assertFalse(ReverseWayTagCorrector.isReversible(w1));
     160        assertFalse(ReverseWayTagCorrector.isReversible(w1));
    158161    }
    159162
Note: See TracChangeset for help on using the changeset viewer.