Ref/model#2
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Java SDK models/services to better match (“parity”) the Order/Subscription API payloads and expands test coverage around DTO serialization and service calls.
Changes:
- Rename/align order request types (
OrderRequest→OrderCreateRequest) and update validator/service/builder usage accordingly. - Adjust subscription and organization DTOs/service methods for updated request/response shapes.
- Add extensive unit tests plus a manual Apache HttpClient test double to avoid Mockito instrumentation issues.
Reviewed changes
Copilot reviewed 41 out of 42 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/org/apache/hc/client5/http/impl/classic/CloseableHttpResponseAdapter.java | Test-only adapter to access package-private CloseableHttpResponse.adapt. |
| src/test/java/com/tapsilat/unit/validation/ValidatorTest.java | Adds tests for GSM cleaning, installment validation, and validator behavior. |
| src/test/java/com/tapsilat/unit/utils/MockHttpClient.java | Manual CloseableHttpClient stub capturing requests and returning stub responses. |
| src/test/java/com/tapsilat/unit/service/SubscriptionServiceTest.java | Adds service tests for subscription create/get/list/cancel/redirect. |
| src/test/java/com/tapsilat/unit/service/OrganizationServiceTest.java | Adds service tests for organization endpoints. |
| src/test/java/com/tapsilat/unit/service/OrderServiceTest.java | Adds broad service tests for order endpoints. |
| src/test/java/com/tapsilat/unit/model/SubscriptionModelTest.java | Adds JSON serialization tests for subscription DTOs. |
| src/test/java/com/tapsilat/unit/model/OrganizationModelTest.java | Adds JSON serialization tests for organization DTOs. |
| src/test/java/com/tapsilat/unit/model/OrderModelTest.java | Adds JSON serialization tests for order DTOs. |
| src/test/java/com/tapsilat/unit/model/OrderDTOSerializationTest.java | Adds comprehensive DTO serialization/deserialization coverage for orders. |
| src/test/java/com/tapsilat/unit/model/CommonModelTest.java | Fixes package and updates Buyer construction usage. |
| src/test/java/com/tapsilat/unit/TapsilatClientTest.java | Updates tests to use OrderCreateRequest / GSM setter changes. |
| src/test/java/com/tapsilat/integration/TapsilatClientLiveExample.java | Updates example package and order request type usage. |
| src/test/java/com/tapsilat/integration/TapsilatClientExample.java | Updates example package and order request type usage. |
| src/test/java/com/tapsilat/integration/TapsilatClientComprehensiveExample.java | Updates example package and aligns fields (e.g., paymentMethods). |
| src/test/java/com/tapsilat/integration/IntegrationTest.java | Adds real API integration tests guarded by env/.env token. |
| src/test/java/com/tapsilat/IntegrationTest.java | Removes old integration test. |
| src/test/java/com/tapsilat/EnumTest.java | Removes old enum test. |
| src/test/java/com/tapsilat/CheckType.java | Adds a local debugging helper for HttpClient type inspection. |
| src/main/java/com/tapsilat/validation/OrderRequestValidator.java | Updates validator to accept OrderCreateRequest, revises GSM cleaning + installment validation. |
| src/main/java/com/tapsilat/service/SubscriptionService.java | Changes list to return a raw map payload. |
| src/main/java/com/tapsilat/service/OrganizationService.java | Updates request types for create/verify operations. |
| src/main/java/com/tapsilat/service/OrderService.java | Updates create to accept OrderCreateRequest. |
| src/main/java/com/tapsilat/model/subscription/SubscriptionPriceOption.java | Removes SubscriptionPriceOption model. |
| src/main/java/com/tapsilat/model/subscription/SubscriptionCreateRequest.java | Removes price_option from create request. |
| src/main/java/com/tapsilat/model/organization/SetLimitUserRequest.java | Changes payload from limit to limit_id. |
| src/main/java/com/tapsilat/model/organization/OrgUserVerifyRequest.java | Adds new verify request model (user_id based). |
| src/main/java/com/tapsilat/model/organization/OrgUserVerifyReq.java | Removes old verify request model. |
| src/main/java/com/tapsilat/model/organization/OrgUserMobileVerifyRequest.java | Adds new mobile-verify request model (user_id based). |
| src/main/java/com/tapsilat/model/organization/OrgUserMobileVerifyReq.java | Removes old mobile-verify request model. |
| src/main/java/com/tapsilat/model/organization/OrgCreateUserRequest.java | Renames request type and aligns class name with file name. |
| src/main/java/com/tapsilat/model/organization/GetVposRequest.java | Switches from currency to currency_id. |
| src/main/java/com/tapsilat/model/order/OrderCreateRequest.java | Renames and aligns fields (e.g., order_cards as list) and removes description/callbackUrl. |
| src/main/java/com/tapsilat/model/common/ShippingAddress.java | Adds tracking/shipping fields and includes them in equals/hashCode. |
| src/main/java/com/tapsilat/model/common/OrderPFSubMerchant.java | Adds national_id and switch_id. |
| src/main/java/com/tapsilat/model/common/Buyer.java | Removes phone field and updates constructors/equals/hashCode accordingly. |
| src/main/java/com/tapsilat/model/common/BillingAddress.java | Adds multiple billing fields and includes them in equals/hashCode. |
| src/main/java/com/tapsilat/model/common/BasketItem.java | Adds mcc and expands equality/hash/printing and accessors. |
| src/main/java/com/tapsilat/builder/OrderRequestBuilder.java | Updates builder to build OrderCreateRequest and align buyer/order_cards handling. |
| src/main/java/com/tapsilat/TapsilatClient.java | Updates backward-compatible createOrder to accept OrderCreateRequest. |
| pom.xml | Updates Mockito deps and adds surefire JVM args. |
| .gitignore | Adds ignores for a Maven directory and src/main/docker. |
Comments suppressed due to low confidence (1)
src/main/java/com/tapsilat/model/order/OrderCreateRequest.java:18
- The class-level Javadoc still lists description/callbackUrl as optional fields, but those properties have been removed from OrderCreateRequest. Please update the documentation so it matches the actual serialized fields.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <configuration> | ||
| <argLine> | ||
| -XX:+EnableDynamicAgentLoading | ||
| --add-opens java.base/java.lang=ALL-UNNAMED | ||
| --add-opens java.base/java.util=ALL-UNNAMED | ||
| --add-opens java.base/java.io=ALL-UNNAMED | ||
| --add-opens java.base/java.net=ALL-UNNAMED | ||
| </argLine> |
There was a problem hiding this comment.
The surefire is set directly, which will override any future tool/plugin that relies on ${argLine} (e.g., JaCoCo). Prefer prefixing with ${argLine} so additional JVM args can compose cleanly.
| @Test | ||
| public void testScenario1_BasicOrder() throws Exception { | ||
| if (token == null) { | ||
| skipTest("testScenario1_BasicOrder"); | ||
| return; | ||
| } | ||
|
|
||
| OrderCreateRequest order = new OrderCreateRequest(); | ||
| order.setAmount(BigDecimal.valueOf(100.00)); | ||
| order.setCurrency("TRY"); | ||
| order.setLocale("tr"); | ||
| order.setBuyer(new Buyer("John", "Doe", "test@example.com")); | ||
|
|
||
| OrderResponse response = client.orders().create(order); | ||
| assertNotNull(response); | ||
| assertNotNull(response.getReferenceId()); | ||
| } |
There was a problem hiding this comment.
These tests execute real API calls when TAPSILAT_API_KEY is present, and they live under src/test/java so they will run in the default unit-test phase. Consider marking the class/methods as @tag("integration") and excluding that tag from the default surefire run (or using @Disabled / a Maven profile) to avoid accidental live calls in CI/dev environments.
| public OrderRequestBuilder orderCards(List<OrderCard> orderCards) { | ||
| this.orderCards = new ArrayList<>(orderCards); | ||
| return this; | ||
| } | ||
|
|
||
| public OrderRequestBuilder addOrderCard(OrderCard orderCard) { | ||
| this.orderCards.add(orderCard); | ||
| return this; |
There was a problem hiding this comment.
orderCards(List) copies the input with new ArrayList<>(orderCards) without a null check, which will throw NPE if a caller passes null (unlike other builder setters that accept null in some cases). Consider treating null as an empty list, or document/enforce non-null explicitly (e.g., Objects.requireNonNull).
| @JsonProperty("title") | ||
| private String title; | ||
|
|
||
| @JsonProperty("user") | ||
| private SubscriptionUser user; | ||
|
|
There was a problem hiding this comment.
Removing the price_option field from SubscriptionCreateRequest is a breaking change for SDK consumers. If the API no longer supports it that’s fine, but consider keeping the field (and SubscriptionPriceOption type) deprecated for at least one release cycle, or providing a clear migration path in code/docs.
| @SuppressWarnings("unchecked") | ||
| public Map<String, Object> list(Integer page, Integer perPage) throws TapsilatException { | ||
| try { | ||
| Map<String, String> params = new HashMap<>(); | ||
| if (page != null) | ||
| params.put("page", String.valueOf(page)); | ||
| if (perPage != null) | ||
| params.put("per_page", String.valueOf(perPage)); | ||
|
|
||
| SubscriptionListItem[] items = executeRequest( | ||
| return executeRequest( | ||
| buildRequest("GET", TapsilatConstants.ENDPOINT_SUBSCRIPTION_LIST, null, params), | ||
| SubscriptionListItem[].class); | ||
| return items != null ? java.util.Arrays.asList(items) : java.util.Collections.emptyList(); | ||
| Map.class); |
There was a problem hiding this comment.
Changing list(...) from returning List to returning a raw Map is a breaking public API change (and loses type safety). If the endpoint response shape has changed, consider adding a new method (e.g., listRaw / listResponse) while keeping the typed list method for backwards compatibility, or introduce a typed response DTO that matches the API payload.
| /** | ||
| * Constructor with all fields. | ||
| * | ||
| * @param name Buyer's first name (required) | ||
| * @param surname Buyer's last name (required) | ||
| * @param email Buyer's email address (required) | ||
| * @param phone Buyer's phone number (optional) | ||
| * @param identityNumber Buyer's identity number (optional) | ||
| * @throws NullPointerException if any required parameter is null | ||
| */ | ||
| public Buyer(String name, String surname, String email, String phone, String identityNumber) { | ||
| public Buyer(String name, String surname, String email, String identityNumber) { | ||
| this.name = Objects.requireNonNull(name, "Buyer name cannot be null"); | ||
| this.surname = Objects.requireNonNull(surname, "Buyer surname cannot be null"); | ||
| this.email = Objects.requireNonNull(email, "Buyer email cannot be null"); | ||
| this.phone = phone; | ||
| this.identityNumber = identityNumber; | ||
| } |
There was a problem hiding this comment.
The constructor Javadoc still documents a "phone" parameter, but the constructor signature no longer takes it. Please update the Javadoc (and the "Constructor with all fields" wording) to reflect the new parameters and how callers should set gsmNumber if needed.
salihdev0
left a comment
There was a problem hiding this comment.
lgtm but copilot reviews are important
|
lgtm but one inconsistency buyer is optional in Swagger but still required by SDK validation. |
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/tapsilat/tapsilat-java/sessions/932150a5-cc9c-4614-a7b2-875f81ee5054 Co-authored-by: hmert <182906+hmert@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tapsilat/tapsilat-java/sessions/932150a5-cc9c-4614-a7b2-875f81ee5054 Co-authored-by: hmert <182906+hmert@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tapsilat/tapsilat-java/sessions/932150a5-cc9c-4614-a7b2-875f81ee5054 Co-authored-by: hmert <182906+hmert@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tapsilat/tapsilat-java/sessions/932150a5-cc9c-4614-a7b2-875f81ee5054 Co-authored-by: hmert <182906+hmert@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tapsilat/tapsilat-java/sessions/932150a5-cc9c-4614-a7b2-875f81ee5054 Co-authored-by: hmert <182906+hmert@users.noreply.github.com>
Updated in 77a9bdc: buyer is now optional in SDK order validation to align with Swagger, and tests were adjusted accordingly.
Applied the review-thread fixes in 77a9bdc (with follow-up refinement in 3a7c1e6), including integration test tagging/exclusion, null-safe builder handling, subscription API compatibility updates, GSM normalization update, buyer-validation alignment, Javadoc cleanup, and test cleanup. |
order and subsciption dto parity fix and tests updated