Skip to content

Commit

Permalink
DEVEXP-728: Provide 'create()' Group helper function wihtout any para…
Browse files Browse the repository at this point in the history
…meter
  • Loading branch information
JPPortier committed Feb 3, 2025
1 parent 30fd3f0 commit cbcd871
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,34 @@ void get() throws ApiException {
TestHelpers.recursiveEquals(response, groupDto);
}

@Test
void createDefault() throws ApiException {

HttpRequest httpRequest =
new HttpRequest(
"/xms/v1/" + URLPathUtils.encodePathSegment(SERVICE_PLAN_ID) + "/groups",
HttpMethod.POST,
Collections.emptyList(),
// SMS is expecting an empty body but do not accept a NULL one
"{}",
Collections.emptyMap(),
Collections.singletonList(HttpContentType.APPLICATION_JSON),
Collections.singletonList(HttpContentType.APPLICATION_JSON),
Collections.singletonList(SMS_AUTH_NAMES));
HttpResponse httpResponse =
new HttpResponse(200, null, Collections.emptyMap(), jsonGroupDto.getBytes());

when(httpClient.invokeAPI(
eq(serverConfiguration),
eq(authManagers),
argThat(new HttpRequestMatcher(httpRequest))))
.thenReturn(httpResponse);

Group response = service.create();

TestHelpers.recursiveEquals(response, groupDto);
}

@Test
void create() throws ApiException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,12 @@ public interface GroupsService {
* @throws ApiException if fails to make API call
*/
Group update(String groupId, GroupUpdateRequest groupUpdateRequest) throws ApiException;

/**
* Create an unnamed and empty group
*
* @return See {@link #create(GroupRequest)}
* @since 1.5
*/
Group create() throws ApiException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,8 @@ private HttpRequest updateRequestBuilder(String groupId, GroupUpdateRequest grou
localVarContentTypes,
localVarAuthNames);
}

public Group create() throws ApiException {
return this.create(GroupRequest.builder().build());
}
}

0 comments on commit cbcd871

Please sign in to comment.