Skip to content

Commit 22683b1

Browse files
committed
Add test
1 parent c7a6aa5 commit 22683b1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

datamodel/odata-client/src/test/java/com/sap/cloud/sdk/datamodel/odata/client/request/ODataNextLinkTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
import static org.mockito.Mockito.mock;
55
import static org.mockito.Mockito.when;
66

7+
import com.sap.cloud.sdk.cloudplatform.connectivity.Destination;
78
import org.apache.http.HttpResponse;
89
import org.apache.http.HttpVersion;
10+
import org.apache.http.client.HttpClient;
911
import org.apache.http.entity.ContentType;
1012
import org.apache.http.entity.StringEntity;
1113
import org.apache.http.message.BasicHttpResponse;
1214
import org.junit.jupiter.api.Test;
1315

16+
import com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpDestination;
17+
import com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientAccessor;
1418
import com.sap.cloud.sdk.datamodel.odata.client.ODataProtocol;
1519

1620
class 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

Comments
 (0)