Changeset 16682 in josm for trunk


Ignore:
Timestamp:
2020-06-19T20:36:27+02:00 (4 years ago)
Author:
simon04
Message:

see #19407 - Add SequenceCommandTest.testCreateReportedException

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/command/SequenceCommandTest.java

    r16574 r16682  
    1010import static org.junit.Assert.assertTrue;
    1111import static org.junit.Assert.fail;
    12 
     12import static org.junit.jupiter.api.Assertions.assertThrows;
     13
     14import java.io.PrintWriter;
     15import java.io.StringWriter;
    1316import java.util.ArrayList;
    1417import java.util.Arrays;
     
    2730import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2831import org.openstreetmap.josm.testutils.JOSMTestRules;
     32import org.openstreetmap.josm.tools.bugreport.ReportedException;
    2933
    3034import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    313317        assertEquals(new SequenceCommand("foo", command1, command2), SequenceCommand.wrapIfNeeded("foo", command1, command2));
    314318    }
     319
     320    /**
     321     * Test SequenceCommand#createReportedException
     322     */
     323    @Test
     324    public void testCreateReportedException() {
     325        DataSet ds = new DataSet();
     326        Command c1 = new TestCommand(ds, Collections.emptyList()) {
     327            @Override
     328            public boolean executeCommand() {
     329                fail("foo");
     330                return false;
     331            }
     332
     333            @Override
     334            public String getDescriptionText() {
     335                return "foo command";
     336            }
     337        };
     338        SequenceCommand command = new SequenceCommand("test", c1);
     339        ReportedException reportedException = assertThrows(ReportedException.class, command::executeCommand);
     340        StringWriter stringWriter = new StringWriter();
     341        reportedException.printReportDataTo(new PrintWriter(stringWriter));
     342        assertEquals("=== REPORTED CRASH DATA ===\n" +
     343                "sequence_information:\n" +
     344                " - sequence_name: Sequence: test\n" +
     345                " - sequence_command: foo command\n" +
     346                " - sequence_index: 0\n" +
     347                " - sequence_commands: [null]\n" +
     348                " - sequence_commands_descriptions: [foo command]\n" +
     349                "\n", stringWriter.toString());
     350    }
    315351}
Note: See TracChangeset for help on using the changeset viewer.