Ignore:
Timestamp:
2016-10-15T00:17:47+02:00 (8 years ago)
Author:
simon04
Message:

fix #13799 - Use builder pattern for TestError

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TurnrestrictionTest.java

    r9244 r11129  
    55
    66import java.util.ArrayList;
    7 import java.util.Arrays;
    8 import java.util.Collections;
    97import java.util.List;
    108
     
    9997                    break;
    10098                default:
    101                     errors.add(new TestError(this, Severity.WARNING, tr("Unknown role"), UNKNOWN_ROLE,
    102                             l, Collections.singletonList(m)));
     99                    errors.add(TestError.builder(this, Severity.WARNING, UNKNOWN_ROLE)
     100                            .message(tr("Unknown role"))
     101                            .primitives(l)
     102                            .highlight(m.getMember())
     103                            .build());
    103104                }
    104105            } else if (m.isNode()) {
     
    115116                    }
    116117                } else {
    117                     errors.add(new TestError(this, Severity.WARNING, tr("Unknown role"), UNKNOWN_ROLE,
    118                             l, Collections.singletonList(m)));
     118                    errors.add(TestError.builder(this, Severity.WARNING, UNKNOWN_ROLE)
     119                            .message(tr("Unknown role"))
     120                            .primitives(l)
     121                            .highlight(m.getMember())
     122                            .build());
    119123                }
    120124            } else {
    121                 errors.add(new TestError(this, Severity.WARNING, tr("Unknown member type"), UNKNOWN_TYPE,
    122                         l, Collections.singletonList(m)));
     125                errors.add(TestError.builder(this, Severity.WARNING, UNKNOWN_TYPE)
     126                        .message(tr("Unknown member type"))
     127                        .primitives(l)
     128                        .highlight(m.getMember())
     129                        .build());
    123130            }
    124131        }
    125132        if (morefrom) {
    126             errors.add(new TestError(this, Severity.ERROR, tr("More than one \"from\" way found"), MORE_FROM, r));
     133            errors.add(TestError.builder(this, Severity.ERROR, MORE_FROM)
     134                    .message(tr("More than one \"from\" way found"))
     135                    .primitives(r)
     136                    .build());
    127137        }
    128138        if (moreto) {
    129             errors.add(new TestError(this, Severity.ERROR, tr("More than one \"to\" way found"), MORE_TO, r));
     139            errors.add(TestError.builder(this, Severity.ERROR, MORE_TO)
     140                    .message(tr("More than one \"to\" way found"))
     141                    .primitives(r)
     142                    .build());
    130143        }
    131144        if (morevia) {
    132             errors.add(new TestError(this, Severity.ERROR, tr("More than one \"via\" node found"), MORE_VIA, r));
     145            errors.add(TestError.builder(this, Severity.ERROR, MORE_VIA)
     146                    .message(tr("More than one \"via\" node found"))
     147                    .primitives(r)
     148                    .build());
    133149        }
    134150        if (mixvia) {
    135             errors.add(new TestError(this, Severity.ERROR, tr("Cannot mix node and way for role \"via\""), MIX_VIA, r));
     151            errors.add(TestError.builder(this, Severity.ERROR, MIX_VIA)
     152                    .message(tr("Cannot mix node and way for role \"via\""))
     153                    .primitives(r)
     154                    .build());
    136155        }
    137156
    138157        if (fromWay == null) {
    139             errors.add(new TestError(this, Severity.ERROR, tr("No \"from\" way found"), NO_FROM, r));
     158            errors.add(TestError.builder(this, Severity.ERROR, NO_FROM)
     159                    .message(tr("No \"from\" way found"))
     160                    .primitives(r)
     161                    .build());
    140162            return;
    141163        }
    142164        if (toWay == null) {
    143             errors.add(new TestError(this, Severity.ERROR, tr("No \"to\" way found"), NO_TO, r));
     165            errors.add(TestError.builder(this, Severity.ERROR, NO_TO)
     166                    .message(tr("No \"to\" way found"))
     167                    .primitives(r)
     168                    .build());
    144169            return;
    145170        }
    146171        if (fromWay.equals(toWay)) {
    147             errors.add(new TestError(this, r.hasTag("restriction", "no_u_turn") ? Severity.OTHER : Severity.WARNING,
    148                     tr("\"from\" way equals \"to\" way"), FROM_EQUALS_TO, r));
     172            Severity severity = r.hasTag("restriction", "no_u_turn") ? Severity.OTHER : Severity.WARNING;
     173            errors.add(TestError.builder(this, severity, FROM_EQUALS_TO)
     174                    .message(tr("\"from\" way equals \"to\" way"))
     175                    .primitives(r)
     176                    .build());
    149177        }
    150178        if (via.isEmpty()) {
    151             errors.add(new TestError(this, Severity.ERROR, tr("No \"via\" node or way found"), NO_VIA, r));
     179            errors.add(TestError.builder(this, Severity.ERROR, NO_VIA)
     180                    .message(tr("No \"via\" node or way found"))
     181                    .primitives(r)
     182                    .build());
    152183            return;
    153184        }
     
    160191                    tr("The \"from\" way does not start or end at a \"via\" node."), FROM_VIA_NODE);
    161192            if (toWay.isOneway() != 0 && viaNode.equals(toWay.lastNode(true))) {
    162                 errors.add(new TestError(this, Severity.WARNING, tr("Superfluous turnrestriction as \"to\" way is oneway"), SUPERFLUOUS, r));
     193                errors.add(TestError.builder(this, Severity.WARNING, SUPERFLUOUS)
     194                        .message(tr("Superfluous turnrestriction as \"to\" way is oneway"))
     195                        .primitives(r)
     196                        .build());
    163197                return;
    164198            }
     
    178212            }
    179213            if (toWay.isOneway() != 0 && ((Way) via.get(via.size() - 1)).isFirstLastNode(toWay.lastNode(true))) {
    180                 errors.add(new TestError(this, Severity.WARNING, tr("Superfluous turnrestriction as \"to\" way is oneway"), SUPERFLUOUS, r));
     214                errors.add(TestError.builder(this, Severity.WARNING, SUPERFLUOUS)
     215                        .message(tr("Superfluous turnrestriction as \"to\" way is oneway"))
     216                        .primitives(r)
     217                        .build());
    181218                return;
    182219            }
     
    206243        }
    207244        if (!c) {
    208             errors.add(new TestError(this, Severity.ERROR, msg, code, Arrays.asList(previous, current)));
     245            errors.add(TestError.builder(this, Severity.ERROR, code)
     246                    .message(msg)
     247                    .primitives(previous, current)
     248                    .build());
    209249        }
    210250    }
Note: See TracChangeset for help on using the changeset viewer.