Ignore:
Timestamp:
2024-06-05T19:04:29+02:00 (8 months ago)
Author:
taylor.smock
Message:

Fix more plugin tests

For reverter, the test needed to be updated for newer WireMock versions.
For graphview, the assert in production code was removed and replaced with
requireNonNull for the parameters that are actually used.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/test/unit/reverter/ChangesetReverterTest.java

    r36235 r36272  
    5555
    5656import com.github.tomakehurst.wiremock.client.WireMock;
    57 import com.github.tomakehurst.wiremock.common.FileSource;
    58 import com.github.tomakehurst.wiremock.extension.Parameters;
    59 import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
     57import com.github.tomakehurst.wiremock.extension.ResponseTransformerV2;
    6058import com.github.tomakehurst.wiremock.http.QueryParameter;
    61 import com.github.tomakehurst.wiremock.http.Request;
    6259import com.github.tomakehurst.wiremock.http.Response;
    6360import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
    6461import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
     62import com.github.tomakehurst.wiremock.stubbing.ServeEvent;
    6563import jakarta.json.Json;
    6664import jakarta.json.JsonArray;
     
    8987     */
    9088    @Test
    91     void testTicket22520(WireMockRuntimeInfo wireMockRuntimeInfo) throws ExecutionException, InterruptedException {
     89    void testTicket22520() throws ExecutionException, InterruptedException {
     90        final WireMockRuntimeInfo wireMockRuntimeInfo = wireMockExtension.getRuntimeInfo();
    9291        wireMockRuntimeInfo.getWireMock().loadMappingsFrom(TestUtils.getRegressionDataDir(22520));
    9392        MultiplePrimitiveTransformer.register(wireMockRuntimeInfo.getWireMock(), 22520);
     
    112111     */
    113112    @Test
    114     void testTicket23582(WireMockRuntimeInfo wireMockRuntimeInfo) {
     113    void testTicket23582() {
     114        final WireMockRuntimeInfo wireMockRuntimeInfo = wireMockExtension.getRuntimeInfo();
    115115        wireMockRuntimeInfo.getWireMock().loadMappingsFrom(TestUtils.getRegressionDataDir(23582));
    116116        MultiplePrimitiveTransformer.register(wireMockRuntimeInfo.getWireMock(), 23582);
     
    126126
    127127    @Test
    128     void testTicket23584(WireMockRuntimeInfo wireMockRuntimeInfo) {
     128    void testTicket23584() {
     129        final WireMockRuntimeInfo wireMockRuntimeInfo = wireMockExtension.getRuntimeInfo();
    129130        new JOptionPaneSimpleMocker(Collections.singletonMap("Conflicts detected", JOptionPane.OK_OPTION));
    130131        wireMockRuntimeInfo.getWireMock().loadMappingsFrom(TestUtils.getRegressionDataDir(23584));
     
    148149     * the same data as {@link MultiplePrimitiveTransformer}.
    149150     */
    150     private static class PrimitiveTransformer extends ResponseTransformer {
     151    private static class PrimitiveTransformer implements ResponseTransformerV2 {
    151152        /**
    152153         * Register the URLs for this transformer
     
    174175
    175176        @Override
    176         public Response transform(Request request, Response response, FileSource files, Parameters parameters) {
    177             final int ticket = parameters.getInt("ticket");
    178             final String[] parts = request.getUrl().substring(1).split("/", -1);
     177        public Response transform(Response response, ServeEvent serveEvent) {
     178            final int ticket = serveEvent.getTransformerParameters().getInt("ticket");
     179            final String[] parts = serveEvent.getRequest().getUrl().substring(1).split("/", -1);
    179180            final int version = Integer.parseInt(parts[3]);
    180181            final long id = Long.parseLong(parts[2]);
     
    204205     * This is needed since we don't always do the requests in the same order.
    205206     */
    206     private static class MultiplePrimitiveTransformer extends ResponseTransformer {
     207    private static class MultiplePrimitiveTransformer implements ResponseTransformerV2 {
    207208
    208209        /**
     
    226227
    227228        @Override
    228         public Response transform(Request request, Response response, FileSource files, Parameters parameters) {
    229             final int ticket = parameters.getInt("ticket");
    230             final QueryParameter wayParam = request.queryParameter("ways");
    231             final QueryParameter nodeParam = request.queryParameter("nodes");
    232             final QueryParameter relParam = request.queryParameter("relations");
     229        public Response transform(Response response, ServeEvent serveEvent) {
     230            final int ticket = serveEvent.getTransformerParameters().getInt("ticket");
     231            final QueryParameter wayParam = serveEvent.getRequest().queryParameter("ways");
     232            final QueryParameter nodeParam = serveEvent.getRequest().queryParameter("nodes");
     233            final QueryParameter relParam = serveEvent.getRequest().queryParameter("relations");
    233234            if (wayParam.isPresent()) {
    234235                return Response.Builder.like(response).but().body(getReturnXml(ticket, OsmPrimitiveType.WAY, wayParam)).build();
Note: See TracChangeset for help on using the changeset viewer.