44import static org .mockito .Mockito .mock ;
55import static org .mockito .Mockito .when ;
66
7+ import com .sap .cloud .sdk .cloudplatform .connectivity .Destination ;
78import org .apache .http .HttpResponse ;
89import org .apache .http .HttpVersion ;
10+ import org .apache .http .client .HttpClient ;
911import org .apache .http .entity .ContentType ;
1012import org .apache .http .entity .StringEntity ;
1113import org .apache .http .message .BasicHttpResponse ;
1214import org .junit .jupiter .api .Test ;
1315
16+ import com .sap .cloud .sdk .cloudplatform .connectivity .DefaultHttpDestination ;
17+ import com .sap .cloud .sdk .cloudplatform .connectivity .HttpClientAccessor ;
1418import com .sap .cloud .sdk .datamodel .odata .client .ODataProtocol ;
1519
1620class ODataNextLinkTest
@@ -24,6 +28,22 @@ class ODataNextLinkTest
2428 }
2529 """ ;
2630
31+ @ Test
32+ void testRemoveDuplicateQueryArguments ()
33+ {
34+ final ODataRequestGeneric request =
35+ new ODataRequestRead ("/v1/foo/bar/" , "endpoint" , "blub=42" , ODataProtocol .V2 );
36+ final Destination dest =
37+ DefaultHttpDestination .builder ("http://blub/?high=five" ).property ("URL.queries.foo" , "bar" ).build ();
38+ final HttpClient client = HttpClientAccessor .getHttpClient (dest );
39+
40+ final HttpResponse httpResponse = new BasicHttpResponse (HttpVersion .HTTP_1_1 , 200 , "Ok" );
41+ httpResponse .setEntity (new StringEntity (PAYLOAD_NEXT_LINK , ContentType .APPLICATION_JSON ));
42+ final ODataRequestResultGeneric result = new ODataRequestResultGeneric (request , httpResponse , client );
43+
44+ assertThat (result .getNextLink ()).contains ("/v1/foo/bar/endpoint?$skiptoken=s3cReT-t0k3n" );
45+ }
46+
2747 @ Test
2848 void testNotParsedNextLinkV4 ()
2949 {
0 commit comments