Skip to content

Commit

Permalink
test: RestRequest Test
Browse files Browse the repository at this point in the history
  • Loading branch information
brenoepics committed Feb 8, 2024
1 parent 3a0ae11 commit a5f0a60
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ public void includeAuthorizationHeader(boolean includeAuthorizationHeader) {
this.includeAuthorizationHeader = includeAuthorizationHeader;
}

/**
* Returns if an authorization header should be included in this request.
*
* @return Whether the authorization header should be included or not.
*/
public boolean isIncludeAuthorizationHeader() {
return includeAuthorizationHeader;
}

/**
* Executes the request. This will automatically retry if we hit a ratelimit.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,42 @@ void shouldSetBody() {
Assertions.assertTrue(restRequest.getBody().isPresent());
Assertions.assertEquals("bodyContent", restRequest.getBody().get());
}

@Test
@DisplayName("Should include authorization header correctly")
void shouldIncludeAuthorizationHeader() {
restRequest.includeAuthorizationHeader(true);
Assertions.assertTrue(restRequest.isIncludeAuthorizationHeader());
}

@Test
@DisplayName("Should handle empty query parameters correctly")
void shouldHandleEmptyQueryParameters() {
restRequest.getQueryParameters().clear();
Assertions.assertTrue(restRequest.getQueryParameters().isEmpty());
}

@Test
@DisplayName("Should handle multiple query parameters correctly")
void shouldHandleMultipleQueryParameters() {
restRequest.addQueryParameter("param1", "value1");
restRequest.addQueryParameter("param2", "value2");
Assertions.assertTrue(restRequest.getQueryParameters().containsKey("param1"));
Assertions.assertTrue(restRequest.getQueryParameters().containsKey("param2"));
}

@Test
@DisplayName("Should handle empty headers correctly")
void shouldHandleEmptyHeaders() {
restRequest.getHeaders().clear();
Assertions.assertTrue(restRequest.getHeaders().isEmpty());
}

@Test
@DisplayName("Should handle multiple headers correctly")
void shouldHandleMultipleHeaders() {
restRequest.addHeader("header1", "value1");
restRequest.addHeader("header2", "value2");
Assertions.assertEquals(2, restRequest.getHeaders().size());
}
}

0 comments on commit a5f0a60

Please sign in to comment.