Skip to content

Ref/model#2

Open
atakanargn wants to merge 13 commits into
mainfrom
ref/model
Open

Ref/model#2
atakanargn wants to merge 13 commits into
mainfrom
ref/model

Conversation

@atakanargn
Copy link
Copy Markdown
Contributor

order and subsciption dto parity fix and tests updated

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (OrderRequestOrderCreateRequest) 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.

Comment thread pom.xml
Comment on lines +90 to +97
<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>
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +89 to +105
@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());
}
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +328 to 335
public OrderRequestBuilder orderCards(List<OrderCard> orderCards) {
this.orderCards = new ArrayList<>(orderCards);
return this;
}

public OrderRequestBuilder addOrderCard(OrderCard orderCard) {
this.orderCards.add(orderCard);
return this;
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines 40 to 45
@JsonProperty("title")
private String title;

@JsonProperty("user")
private SubscriptionUser user;

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread src/test/java/com/tapsilat/CheckType.java Outdated
Comment on lines +40 to +51
@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);
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread src/main/java/com/tapsilat/validation/OrderRequestValidator.java Outdated
Comment on lines 78 to 93
/**
* 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;
}
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@salihdev0 salihdev0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but copilot reviews are important

@TarikSogukpinar
Copy link
Copy Markdown

lgtm but one inconsistency buyer is optional in Swagger but still required by SDK validation.

@hmert
Copy link
Copy Markdown
Member

hmert commented Apr 21, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown

Copilot AI commented Apr 21, 2026

lgtm but one inconsistency buyer is optional in Swagger but still required by SDK validation.

Updated in 77a9bdc: buyer is now optional in SDK order validation to align with Swagger, and tests were adjusted accordingly.

@copilot apply changes based on the comments in this thread

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.

Copilot AI requested a review from hmert April 21, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants