Ignore:
Timestamp:
2016-03-28T14:23:40+02:00 (8 years ago)
Author:
Don-vip
Message:

see #12652 - rework bug report classes to improve unit tests coverage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportSender.java

    r10055 r10067  
    4949
    5050    private final String statusText;
     51    private String errorMessage;
    5152
    5253    /**
     
    5455     * @param statusText The status text to send.
    5556     */
    56     public BugReportSender(String statusText) {
     57    protected BugReportSender(String statusText) {
    5758        super("Bug report sender");
    5859        this.statusText = statusText;
     
    101102                DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    102103                Document document = builder.parse(in);
    103                 return retriveDebugToken(document);
     104                return retrieveDebugToken(document);
    104105            }
    105106        } catch (IOException | SAXException | ParserConfigurationException | XPathExpressionException t) {
     
    108109    }
    109110
    110     private String getJOSMTicketURL() {
     111    private static String getJOSMTicketURL() {
    111112        return Main.getJOSMWebsite() + "/josmticket";
    112113    }
    113114
    114     private String retriveDebugToken(Document document) throws XPathExpressionException, BugReportSenderException {
     115    private static String retrieveDebugToken(Document document) throws XPathExpressionException, BugReportSenderException {
    115116        XPathFactory factory = XPathFactory.newInstance();
    116117        XPath xpath = factory.newXPath();
     
    134135
    135136    private void failed(String string) {
     137        errorMessage = string;
    136138        SwingUtilities.invokeLater(new Runnable() {
    137139            @Override
    138140            public void run() {
    139                 JPanel errorPanel = new JPanel();
    140                 errorPanel.setLayout(new GridBagLayout());
     141                JPanel errorPanel = new JPanel(new GridBagLayout());
    141142                errorPanel.add(new JMultilineLabel(
    142143                        tr("Opening the bug report failed. Please report manually using this website:")),
     
    149150            }
    150151        });
     152    }
     153
     154    /**
     155     * Returns the error message that could have occured during bug sending.
     156     * @return the error message, or {@code null} if successful
     157     */
     158    public final String getErrorMessage() {
     159        return errorMessage;
    151160    }
    152161
     
    164173     * Opens the bug report window on the JOSM server.
    165174     * @param statusText The status text to send along to the server.
     175     * @return bug report sender started thread
    166176     */
    167     public static void reportBug(String statusText) {
    168         new BugReportSender(statusText).start();
     177    public static BugReportSender reportBug(String statusText) {
     178        BugReportSender sender = new BugReportSender(statusText);
     179        sender.start();
     180        return sender;
    169181    }
    170182}
Note: See TracChangeset for help on using the changeset viewer.