Skip to content

Commit

Permalink
refactor (SMS/Batches): Rename 'Batch' class with 'BatchResponse'
Browse files Browse the repository at this point in the history
  • Loading branch information
JPPortier committed Dec 17, 2024
1 parent b7b1d79 commit 79fa747
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.request.SendDeliveryFeedbackRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBatchRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.response.Batch;
import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse;

public interface BatchesService {

Batch send(BatchRequest batch) throws ApiException;
BatchResponse send(BatchRequest batch) throws ApiException;

ListBatchesResponse list(ListBatchesRequest parameters) throws ApiException;

DryRunResponse dryRun(boolean perRecipient, int numberOfRecipient, BatchRequest batch);

Batch get(String batchId) throws ApiException;
BatchResponse get(String batchId) throws ApiException;

Batch replace(String batchId, BatchRequest batch) throws ApiException;
BatchResponse replace(String batchId, BatchRequest batch) throws ApiException;

Batch cancel(String batchId) throws ApiException;
BatchResponse cancel(String batchId) throws ApiException;

void sendDeliveryFeedback(String batchId, SendDeliveryFeedbackRequest recipients)
throws ApiException;

Batch update(String batchId, UpdateBatchRequest request) throws ApiException;
BatchResponse update(String batchId, UpdateBatchRequest request) throws ApiException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.request.SendDeliveryFeedbackRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBatchRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.response.Batch;
import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.internal.ApiBatchList;
Expand All @@ -36,7 +36,7 @@ protected BatchesApi getApi() {
return this.api;
}

public Batch send(BatchRequest batch) throws ApiException {
public BatchResponse send(BatchRequest batch) throws ApiException {
return getApi().send(batch);
}

Expand Down Expand Up @@ -66,15 +66,15 @@ public DryRunResponse dryRun(boolean perRecipient, int numberOfRecipient, BatchR
return getApi().dryRun(perRecipient, numberOfRecipient, batch);
}

public Batch get(String batchId) throws ApiException {
public BatchResponse get(String batchId) throws ApiException {
return getApi().get(batchId);
}

public Batch replace(String batchId, BatchRequest batch) throws ApiException {
public BatchResponse replace(String batchId, BatchRequest batch) throws ApiException {
return getApi().replace(batchId, batch);
}

public Batch cancel(String batchId) throws ApiException {
public BatchResponse cancel(String batchId) throws ApiException {
return getApi().cancel(batchId);
}

Expand All @@ -83,7 +83,7 @@ public void sendDeliveryFeedback(String batchId, SendDeliveryFeedbackRequest req
getApi().sendDeliveryFeedback(batchId, request);
}

public Batch update(String batchId, UpdateBatchRequest request) throws ApiException {
public BatchResponse update(String batchId, UpdateBatchRequest request) throws ApiException {
return getApi().update(batchId, request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
import com.sinch.sdk.domains.sms.models.v1.batches.response.internal.BatchResponseInternalImpl;

@JsonDeserialize(using = BatchResponseInternalImpl.Deserializer.class)
public interface Batch {}
public interface BatchResponse {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import java.util.Collection;
import java.util.NoSuchElementException;

public class ListBatchesResponse extends ListResponse<Batch> {
public class ListBatchesResponse extends ListResponse<BatchResponse> {

private final Page<ListBatchesRequest, Batch, Integer> page;
private final Page<ListBatchesRequest, BatchResponse, Integer> page;
private final BatchesService service;
private ListBatchesResponse nextPage;

public ListBatchesResponse(
BatchesService service, Page<ListBatchesRequest, Batch, Integer> page) {
BatchesService service, Page<ListBatchesRequest, BatchResponse, Integer> page) {
this.service = service;
this.page = page;
}
Expand All @@ -40,7 +40,7 @@ public ListBatchesResponse nextPage() {
return response;
}

public Collection<Batch> getContent() {
public Collection<BatchResponse> getContent() {
return page.getEntities();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ public class BatchesServiceTest extends BaseTest {
.setUdh(udh)
.build();

@GivenJsonResource("/domains/sms/v1/batches/response/BatchBinaryDto.json")
@GivenJsonResource("/domains/sms/v1/batches/response/BinaryResponseDto.json")
public SendSMS201ResponseDto binaryResponseDto;

@GivenJsonResource("/domains/sms/v1/batches/response/BatchMediaDto.json")
@GivenJsonResource("/domains/sms/v1/batches/response/MediaResponseDto.json")
SendSMS201ResponseDto mediaResponseDto;

@GivenJsonResource("/domains/sms/v1/batches/response/BatchTextDto.json")
@GivenJsonResource("/domains/sms/v1/batches/response/TextResponseDto.json")
SendSMS201ResponseDto textResponseDto;

@GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
@TestWithResources
class BatchDtoConverterTest extends BaseTest {

@GivenJsonResource("/domains/sms/v1/batches/response/BatchBinaryDto.json")
@GivenJsonResource("/domains/sms/v1/batches/response/BinaryResponseDto.json")
public SendSMS201ResponseDto binaryResponseDto;

@GivenJsonResource("/domains/sms/v1/batches/response/BatchTextDto.json")
@GivenJsonResource("/domains/sms/v1/batches/response/TextResponseDto.json")
public SendSMS201ResponseDto textResponseDto;

@GivenJsonResource("/domains/sms/v1/batches/response/BatchMediaDto.json")
@GivenJsonResource("/domains/sms/v1/batches/response/MediaResponseDto.json")
public SendSMS201ResponseDto mediaResponseDto;

@GivenJsonResource("/domains/sms/v1/BinaryRequestDto.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBinaryRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateMediaRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateTextRequest;
import com.sinch.sdk.domains.sms.models.v1.batches.response.Batch;
import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchBinary;
import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchMedia;
import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchText;
import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.BinaryResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.MediaResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.TextResponse;
import com.sinch.sdk.domains.sms.models.v1.batches.response.internal.ApiBatchList;
import com.sinch.sdk.models.SmsContext;
import java.time.Instant;
Expand Down Expand Up @@ -70,8 +70,8 @@ public class BatchesServiceTest extends BaseTest {
static final int fromNpi = 18;
static final String udh = "foo udh";
static final String body = "Hi ${name} ({an identifier}) ! How are you?";
public static final BatchBinary batchBinary =
BatchBinary.builder()
public static final BinaryResponse batchBinary =
BinaryResponse.builder()
.setId(id)
.setTo(to)
.setFrom(from)
Expand Down Expand Up @@ -109,8 +109,8 @@ public class BatchesServiceTest extends BaseTest {
new AbstractMap.SimpleEntry<>("an identifier", anIdentifierParameters))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

public static final BatchMedia batchMedia =
BatchMedia.builder()
public static final MediaResponse batchMedia =
MediaResponse.builder()
.setId(id)
.setTo(to)
.setFrom(from)
Expand All @@ -133,8 +133,8 @@ public class BatchesServiceTest extends BaseTest {
.setStrictValidation(true)
.setParameters(parameters)
.build();
public static final BatchText batchText =
BatchText.builder()
public static final TextResponse batchText =
TextResponse.builder()
.setId(id)
.setTo(to)
.setFrom(from)
Expand Down Expand Up @@ -248,14 +248,14 @@ public class BatchesServiceTest extends BaseTest {
.setUdh(udh)
.build();

@GivenJsonResource("/domains/sms/v1/batches/response/BatchBinaryDto.json")
public Batch binaryResponseDto;
@GivenJsonResource("/domains/sms/v1/batches/response/BinaryResponseDto.json")
public BatchResponse binaryResponseDto;

@GivenJsonResource("/domains/sms/v1/batches/response/BatchMediaDto.json")
Batch mediaResponseDto;
@GivenJsonResource("/domains/sms/v1/batches/response/MediaResponseDto.json")
BatchResponse mediaResponseDto;

@GivenJsonResource("/domains/sms/v1/batches/response/BatchTextDto.json")
Batch textResponseDto;
@GivenJsonResource("/domains/sms/v1/batches/response/TextResponseDto.json")
BatchResponse textResponseDto;

@GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json")
DryRunResponse dryRunResponseDto;
Expand Down Expand Up @@ -289,7 +289,7 @@ void getBinary() throws ApiException {

when(api.get(eq("foo binary batch id"))).thenReturn(binaryResponseDto);

Batch response = service.get("foo binary batch id");
BatchResponse response = service.get("foo binary batch id");

TestHelpers.recursiveEquals(response, batchBinary);
}
Expand All @@ -299,7 +299,7 @@ void getMedia() throws ApiException {

when(api.get(eq("foo media batch id"))).thenReturn(mediaResponseDto);

Batch response = service.get("foo media batch id");
BatchResponse response = service.get("foo media batch id");

TestHelpers.recursiveEquals(response, batchMedia);
}
Expand All @@ -309,7 +309,7 @@ void getText() throws ApiException {

when(api.get(eq("foo text batch id"))).thenReturn(textResponseDto);

Batch response = service.get("foo text batch id");
BatchResponse response = service.get("foo text batch id");

TestHelpers.recursiveEquals(response, batchText);
}
Expand All @@ -319,7 +319,7 @@ void sendBinary() throws ApiException {

when(api.send(sendSmsBatchBinaryRequest)).thenReturn(binaryResponseDto);

Batch response = service.send(sendSmsBatchBinaryRequest);
BatchResponse response = service.send(sendSmsBatchBinaryRequest);

TestHelpers.recursiveEquals(response, batchBinary);
}
Expand All @@ -329,7 +329,7 @@ void sendMedia() throws ApiException {

when(api.send(sendSmsBatchMediaRequest)).thenReturn(mediaResponseDto);

Batch response = service.send(sendSmsBatchMediaRequest);
BatchResponse response = service.send(sendSmsBatchMediaRequest);

TestHelpers.recursiveEquals(response, batchMedia);
}
Expand All @@ -339,7 +339,7 @@ void sendText() throws ApiException {

when(api.send(sendSmsBatchTextRequest)).thenReturn(textResponseDto);

Batch response = service.send(sendSmsBatchTextRequest);
BatchResponse response = service.send(sendSmsBatchTextRequest);

TestHelpers.recursiveEquals(response, batchText);
}
Expand All @@ -365,12 +365,12 @@ void list() throws ApiException {
.thenReturn(listBatchesResponseDtoPage2);
ListBatchesResponse response = service.list(null);

Iterator<Batch> iterator = response.iterator();
Batch batch = iterator.next();
Iterator<BatchResponse> iterator = response.iterator();
BatchResponse batch = iterator.next();
Assertions.assertThat(iterator.hasNext()).isEqualTo(true);
TestHelpers.recursiveEquals(
batch,
BatchBinary.builder()
BinaryResponse.builder()
.setId("01HEAWCHESCXG8SDG5R10VF8E1")
.setTo(Collections.singletonList("339876543213"))
.setFrom("33123456789")
Expand All @@ -388,7 +388,7 @@ void list() throws ApiException {
Assertions.assertThat(iterator.hasNext()).isEqualTo(true);
TestHelpers.recursiveEquals(
batch,
BatchText.builder()
TextResponse.builder()
.setId("01HEAC0AG69SVYYQ675VPYT28Q")
.setTo(Collections.singletonList("3300000000"))
.setCanceled(false)
Expand All @@ -405,7 +405,7 @@ void list() throws ApiException {
Assertions.assertThat(iterator.hasNext()).isEqualTo(false);
TestHelpers.recursiveEquals(
batch,
BatchMedia.builder()
MediaResponse.builder()
.setId("01HEABZ9S80D4ENE3X6CPMATZR")
.setTo(Collections.singletonList("331111111"))
.setCanceled(false)
Expand All @@ -424,7 +424,7 @@ void updateText() throws ApiException {
when(api.update(eq("foo text batch id"), eq(updateSmsBatchTextRequest)))
.thenReturn(textResponseDto);

Batch response = service.update("foo text batch id", updateSmsBatchTextRequest);
BatchResponse response = service.update("foo text batch id", updateSmsBatchTextRequest);

TestHelpers.recursiveEquals(response, batchText);
}
Expand All @@ -435,7 +435,7 @@ void updateMedia() throws ApiException {
when(api.update(eq("foo text batch id"), eq(updateSmsBatchMediaRequest)))
.thenReturn(mediaResponseDto);

Batch response = service.update("foo text batch id", updateSmsBatchMediaRequest);
BatchResponse response = service.update("foo text batch id", updateSmsBatchMediaRequest);

TestHelpers.recursiveEquals(response, batchMedia);
}
Expand All @@ -446,7 +446,7 @@ void updateBinary() throws ApiException {
when(api.update(eq("foo text batch id"), eq(updateSmsBatchBinaryRequest)))
.thenReturn(binaryResponseDto);

Batch response = service.update("foo text batch id", updateSmsBatchBinaryRequest);
BatchResponse response = service.update("foo text batch id", updateSmsBatchBinaryRequest);

TestHelpers.recursiveEquals(response, batchBinary);
}
Expand All @@ -457,7 +457,7 @@ void replaceBinary() throws ApiException {
when(api.replace(eq("foo text batch id"), eq(sendSmsBatchBinaryRequest)))
.thenReturn(binaryResponseDto);

Batch response = service.replace("foo text batch id", sendSmsBatchBinaryRequest);
BatchResponse response = service.replace("foo text batch id", sendSmsBatchBinaryRequest);

TestHelpers.recursiveEquals(response, batchBinary);
}
Expand All @@ -468,7 +468,7 @@ void replaceMedia() throws ApiException {
when(api.replace(eq("foo text batch id"), eq(sendSmsBatchMediaRequest)))
.thenReturn(mediaResponseDto);

Batch response = service.replace("foo text batch id", sendSmsBatchMediaRequest);
BatchResponse response = service.replace("foo text batch id", sendSmsBatchMediaRequest);

TestHelpers.recursiveEquals(response, batchMedia);
}
Expand All @@ -479,7 +479,7 @@ void replaceText() throws ApiException {
when(api.replace(eq("foo text batch id"), eq(sendSmsBatchTextRequest)))
.thenReturn(textResponseDto);

Batch response = service.replace("foo text batch id", sendSmsBatchTextRequest);
BatchResponse response = service.replace("foo text batch id", sendSmsBatchTextRequest);

TestHelpers.recursiveEquals(response, batchText);
}
Expand All @@ -489,7 +489,7 @@ void cancelBatch() throws ApiException {

when(api.cancel(eq("foo text batch id"))).thenReturn(textResponseDto);

Batch response = service.cancel("foo text batch id");
BatchResponse response = service.cancel("foo text batch id");

TestHelpers.recursiveEquals(response, batchText);
}
Expand Down
Loading

0 comments on commit 79fa747

Please sign in to comment.