From 45aec08a581e2de7e663857df9772195ba21c7bc Mon Sep 17 00:00:00 2001 From: "maksim.safronov" Date: Fri, 4 Apr 2025 12:15:22 +0400 Subject: [PATCH 1/4] v3 version of api changed to v1 for vuega compatibility --- src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt index 88b361c6a..bdf4f76c4 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt @@ -423,8 +423,8 @@ class ApiClientHelper private constructor( } private fun buildBaseEndpointPath(credentials: ApiCredentials) = when (credentials) { - is ApiStoreCredentials -> "/api/v3/${credentials.storeId}" - is ApiAppCredentials -> "/api/v3" + is ApiStoreCredentials -> "/api/v1/${credentials.storeId}" + is ApiAppCredentials -> "/api/v1" } } From 8f7448f131fcd31aca44730731020e5ce6ab8fd4 Mon Sep 17 00:00:00 2001 From: "maksim.safronov" Date: Fri, 4 Apr 2025 12:43:19 +0400 Subject: [PATCH 2/4] v3 version of api changed to v1 for vuega compatibility - removed tests. Do not merge this commits --- .../apiclient/v3/BatchSupportUnitTest.kt | 36 - .../v3/DTOsEmptinessCheckerUnitTest.kt | 457 ----- .../ecwid/apiclient/v3/DtoContractUnitTest.kt | 629 ------- .../ecwid/apiclient/v3/EncodeUtilsUnitTest.kt | 42 - .../v3/FetchedUpdatedDTOsCheckerUnitTest.kt | 379 ---- .../ecwid/apiclient/v3/MaskUtilsUnitTest.kt | 49 - .../apiclient/v3/entity/BaseEntityTest.kt | 254 --- .../ecwid/apiclient/v3/entity/BatchApiTest.kt | 115 -- .../ecwid/apiclient/v3/entity/BrandsTest.kt | 96 - .../ecwid/apiclient/v3/entity/CartsTest.kt | 719 ------- .../apiclient/v3/entity/CategoriesTest.kt | 726 ------- .../ecwid/apiclient/v3/entity/CouponsTest.kt | 320 ---- .../apiclient/v3/entity/CustomerGroupsTest.kt | 129 -- .../apiclient/v3/entity/CustomersTest.kt | 478 ----- .../apiclient/v3/entity/ExtRequestTest.kt | 65 - .../ecwid/apiclient/v3/entity/OrdersTest.kt | 481 ----- .../apiclient/v3/entity/ProductTypesTest.kt | 193 -- .../ecwid/apiclient/v3/entity/ProductsTest.kt | 1668 ----------------- .../apiclient/v3/entity/ResponseFieldsTest.kt | 59 - .../ecwid/apiclient/v3/entity/StorageTest.kt | 93 - .../apiclient/v3/entity/StoreProfileTest.kt | 322 ---- .../apiclient/v3/entity/VariationsTest.kt | 360 ---- .../gson/GsonTransformerTest.kt | 275 --- .../ResponseFieldsBuilderUnitTest.kt | 165 -- .../ResponseFieldsDslUnitTest.kt | 32 - .../ResponseFieldsProviderKtUnitTest.kt | 125 -- .../responsefields/ResponseFieldsUnitTest.kt | 183 -- .../v3/rule/NonDuplicablePropertyRules.kt | 37 - .../v3/rule/NonUpdatablePropertyRules.kt | 347 ---- .../apiclient/v3/rule/NonnullPropertyRules.kt | 69 - .../v3/rule/NullablePropertyRules.kt | 222 --- .../BrandsSearchRequestRules.kt | 13 - .../CalculateOrderDetailsResultRules.kt | 189 -- .../CartsSearchRequestRules.kt | 17 - .../CategoriesByPathRequestRules.kt | 9 - .../CategoriesSearchRequestRules.kt | 17 - .../CategoryDetailsRequestRules.kt | 12 - .../CouponSearchRequestRules.kt | 15 - .../CustomAppRequestRules.kt | 195 -- .../CustomersIdsRequestRules.kt | 20 - .../CustomersMassUpdateRequestRules.kt | 30 - .../CustomersSearchRequestRules.kt | 34 - .../DeletedCustomersSearchRequestRules.kt | 10 - .../DeletedOrdersSearchRequestRules.kt | 10 - .../DeletedProductsSearchRequestRules.kt | 10 - .../FetchedBrandRules.kt | 10 - .../nullablepropertyrules/FetchedCartRules.kt | 182 -- .../FetchedCategoryRules.kt | 34 - .../FetchedCouponRules.kt | 23 - .../FetchedCustomerRules.kt | 68 - .../FetchedCustomersConfigRules.kt | 16 - .../FetchedExtrafieldConfigRules.kt | 40 - .../FetchedOrderRules.kt | 330 ---- .../FetchedOrderStatusSettingsRules.kt | 12 - .../FetchedProductReviewRules.kt | 29 - .../FetchedProductRules.kt | 172 -- .../FetchedProductTypeRules.kt | 14 - ...chedShippingoptionNullablePropertyRules.kt | 86 - .../FetchedSlugInfoRules.kt | 25 - .../FetchedStoreProfileRules.kt | 335 ---- .../FetchedSubscriptionRules.kt | 116 -- .../FetchedVariationRules.kt | 79 - .../GetProductFiltersRequestRules.kt | 25 - .../OrderForCalculateRules.kt | 148 -- .../OrdersSearchRequestRules.kt | 31 - .../ProductDetailsRequestRules.kt | 12 - .../ProductReviewMassUpdateRequestRules.kt | 21 - .../ProductReviewSearchRequestRules.kt | 19 - .../ProductsSearchRequestRules.kt | 40 - .../SlugInfoRequestRules.kt | 9 - .../SubscriptionsSearchRequestRules.kt | 28 - .../v3/util/DTORandomDataProviderStrategy.kt | 94 - .../apiclient/v3/util/DTOsEmptinessChecker.kt | 189 -- .../v3/util/FetchedUpdatedDTOsChecker.kt | 304 --- .../com/ecwid/apiclient/v3/util/OrderUtils.kt | 345 ---- .../apiclient/v3/util/PropertiesLoadError.kt | 3 - .../apiclient/v3/util/PropertiesLoader.kt | 88 - .../ecwid/apiclient/v3/util/RandomUtils.kt | 90 - .../ecwid/apiclient/v3/util/TestProperties.kt | 8 - 79 files changed, 12731 deletions(-) delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/BatchSupportUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/DTOsEmptinessCheckerUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/EncodeUtilsUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/FetchedUpdatedDTOsCheckerUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/MaskUtilsUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/BaseEntityTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/BatchApiTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/BrandsTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/CouponsTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/CustomerGroupsTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/CustomersTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/ExtRequestTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/OrdersTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductTypesTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/ResponseFieldsTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/StorageTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/StoreProfileTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/entity/VariationsTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/GsonTransformerTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsBuilderUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsDslUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsProviderKtUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsUnitTest.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/NonDuplicablePropertyRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/NonnullPropertyRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/BrandsSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CartsSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoriesByPathRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoriesSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoryDetailsRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CouponSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomAppRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersIdsRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersMassUpdateRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedCustomersSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedOrdersSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedProductsSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedBrandRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCartRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCategoryRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCouponRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomerRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomersConfigRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedExtrafieldConfigRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderStatusSettingsRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductReviewRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductTypeRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedShippingoptionNullablePropertyRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedSlugInfoRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedStoreProfileRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedSubscriptionRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedVariationRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/GetProductFiltersRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrderForCalculateRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrdersSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductDetailsRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewMassUpdateRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductsSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/SlugInfoRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/SubscriptionsSearchRequestRules.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/util/DTORandomDataProviderStrategy.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/util/DTOsEmptinessChecker.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/util/FetchedUpdatedDTOsChecker.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/util/PropertiesLoadError.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/util/PropertiesLoader.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/util/RandomUtils.kt delete mode 100644 src/test/kotlin/com/ecwid/apiclient/v3/util/TestProperties.kt diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/BatchSupportUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/BatchSupportUnitTest.kt deleted file mode 100644 index 5fad103f6..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/BatchSupportUnitTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.ecwid.apiclient.v3 - -import com.ecwid.apiclient.v3.util.buildQueryString -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.Arguments -import org.junit.jupiter.params.provider.Arguments.arguments -import org.junit.jupiter.params.provider.MethodSource -import java.util.stream.Stream - -class BatchSupportUnitTest { - - @ParameterizedTest - @MethodSource("expectedQueryToParamsMapProvider") - fun queryBuilderTest(expectedQuery: String, params: Map) { - Assertions.assertEquals(expectedQuery, buildQueryString(params)) - } - - companion object { - - @Suppress("unused") - @JvmStatic - fun expectedQueryToParamsMapProvider(): Stream { - return Stream.of( - arguments("", mapOf()), - arguments("?test=test", mapOf("test" to "test")), - arguments("?test=t%C3%A8st", mapOf("test" to "tèst")), - arguments("?test_1=1&test_2=t%C3%A9st", mapOf("test_1" to "1", "test_2" to "tést")), - arguments( - "?baseUrl=https%3A%2F%2Fexample.com%3Ftest%3Dexample&test_2=t%C3%A9st", - mapOf("baseUrl" to "https://example.com?test=example", "test_2" to "tést") - ) - ) - } - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/DTOsEmptinessCheckerUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/DTOsEmptinessCheckerUnitTest.kt deleted file mode 100644 index 581ebf1f1..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/DTOsEmptinessCheckerUnitTest.kt +++ /dev/null @@ -1,457 +0,0 @@ -package com.ecwid.apiclient.v3 - -import com.ecwid.apiclient.v3.util.FieldEmptinessProblem -import com.ecwid.apiclient.v3.util.FieldEmptinessProblemKind -import com.ecwid.apiclient.v3.util.checkDTOFieldsEmptiness -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test -import java.util.* - -class DTOsEmptinessCheckerUnitTest { - - @Test - fun `test DTOs check for emptiness and default fields value works well`() { - data class BooleanDTO( - val booleanField1: Boolean, - val booleanField2: Boolean, - val booleanField3: Boolean?, - val booleanField4: Boolean?, - val booleanField5: Boolean?, - val booleanField6: Boolean? - ) - - data class ByteDTO( - val byteField1: Byte, - val byteField2: Byte, - val byteField3: Byte?, - val byteField4: Byte?, - val byteField5: Byte?, - val byteField6: Byte? - ) - - data class ShortDTO( - val shortField1: Short, - val shortField2: Short, - val shortField3: Short?, - val shortField4: Short?, - val shortField5: Short?, - val shortField6: Short? - ) - - data class IntDTO( - val intField1: Int, - val intField2: Int, - val intField3: Int?, - val intField4: Int?, - val intField5: Int?, - val intField6: Int? - ) - - data class LongDTO( - val longField1: Long, - val longField2: Long, - val longField3: Long?, - val longField4: Long?, - val longField5: Long?, - val longField6: Long? - ) - - data class FloatDTO( - val floatField1: Float, - val floatField2: Float, - val floatField3: Float?, - val floatField4: Float?, - val floatField5: Float?, - val floatField6: Float? - ) - - data class DoubleDTO( - val doubleField1: Double, - val doubleField2: Double, - val doubleField3: Double?, - val doubleField4: Double?, - val doubleField5: Double?, - val doubleField6: Double? - ) - - data class StringDTO( - val stringField1: String?, - val stringField2: String, - val stringField3: String - ) - - data class DateDTO( - val dateField1: Date?, - val dateField2: Date?, - val dateField3: Date - ) - - data class EnumDTO( - val enumField1: EnumClass?, - val enumField2: EnumClass - ) - - data class ListDTO( - val listField1: List?, - val listField2: List, - val listField3: List, - val listField4: List - ) - - data class MapDTO( - val mapField1: Map?, - val mapField2: Map, - val mapField3: Map, - val mapField4: Map, - val mapField5: Map - ) - - data class NullDTO( - val intField: Int - ) - - data class TestDTO( - val booleanDTO: BooleanDTO, - val byteDTO: ByteDTO, - val shortDTO: ShortDTO, - val intDTO: IntDTO, - val longDTO: LongDTO, - val floatDTO: FloatDTO, - val doubleDTO: DoubleDTO, - val stringDTO: StringDTO, - val dateDTO: DateDTO, - val enumDTO: EnumDTO, - val listDTO: ListDTO, - val mapDTO: MapDTO, - - val primitiveField: Int?, - val nullDTOField: NullDTO? - ) - - val dto = TestDTO( - booleanDTO = BooleanDTO( - booleanField1 = false, - booleanField2 = false, - booleanField3 = null, - booleanField4 = null, - booleanField5 = true, - booleanField6 = true - ), - byteDTO = ByteDTO( - byteField1 = 0, - byteField2 = 0, - byteField3 = null, - byteField4 = null, - byteField5 = 1, - byteField6 = 1 - ), - shortDTO = ShortDTO( - shortField1 = 0, - shortField2 = 0, - shortField3 = null, - shortField4 = null, - shortField5 = 1, - shortField6 = 1 - ), - intDTO = IntDTO( - intField1 = 0, - intField2 = 0, - intField3 = null, - intField4 = null, - intField5 = 1, - intField6 = 1 - ), - longDTO = LongDTO( - longField1 = 0L, - longField2 = 0L, - longField3 = null, - longField4 = null, - longField5 = 1L, - longField6 = 1L - ), - floatDTO = FloatDTO( - floatField1 = 0.0f, - floatField2 = 0.0f, - floatField3 = null, - floatField4 = null, - floatField5 = 1.0f, - floatField6 = 1.0f - ), - doubleDTO = DoubleDTO( - doubleField1 = 0.0, - doubleField2 = 0.0, - doubleField3 = null, - doubleField4 = null, - doubleField5 = 1.0, - doubleField6 = 1.0 - ), - stringDTO = StringDTO( - stringField1 = null, - stringField2 = "", - stringField3 = "stringField3" - ), - dateDTO = DateDTO( - dateField1 = null, - dateField2 = Date(0), - dateField3 = Date() - ), - enumDTO = EnumDTO( - enumField1 = null, - enumField2 = EnumClass.VALUE1 - ), - listDTO = ListDTO( - listField1 = null, - listField2 = listOf(), - listField3 = listOf(0), - listField4 = listOf(1) - ), - mapDTO = MapDTO( - mapField1 = null, - mapField2 = mapOf(), - mapField3 = mapOf(0 to 1), - mapField4 = mapOf(1 to 0), - mapField5 = mapOf(1 to 1) - ), - primitiveField = null, - nullDTOField = null - ) - - val expectedProblems = setOf( - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = BooleanDTO::class.java, - fieldName = "booleanField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = BooleanDTO::class.java, - fieldName = "booleanField2" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = BooleanDTO::class.java, - fieldName = "booleanField3" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = BooleanDTO::class.java, - fieldName = "booleanField4" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = ByteDTO::class.java, - fieldName = "byteField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = ByteDTO::class.java, - fieldName = "byteField2" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = ByteDTO::class.java, - fieldName = "byteField3" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = ByteDTO::class.java, - fieldName = "byteField4" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = ShortDTO::class.java, - fieldName = "shortField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = ShortDTO::class.java, - fieldName = "shortField2" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = ShortDTO::class.java, - fieldName = "shortField3" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = ShortDTO::class.java, - fieldName = "shortField4" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = IntDTO::class.java, - fieldName = "intField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = IntDTO::class.java, - fieldName = "intField2" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = IntDTO::class.java, - fieldName = "intField3" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = IntDTO::class.java, - fieldName = "intField4" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = LongDTO::class.java, - fieldName = "longField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = LongDTO::class.java, - fieldName = "longField2" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = LongDTO::class.java, - fieldName = "longField3" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = LongDTO::class.java, - fieldName = "longField4" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = FloatDTO::class.java, - fieldName = "floatField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = FloatDTO::class.java, - fieldName = "floatField2" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = FloatDTO::class.java, - fieldName = "floatField3" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = FloatDTO::class.java, - fieldName = "floatField4" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = DoubleDTO::class.java, - fieldName = "doubleField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = DoubleDTO::class.java, - fieldName = "doubleField2" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = DoubleDTO::class.java, - fieldName = "doubleField3" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = DoubleDTO::class.java, - fieldName = "doubleField4" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = StringDTO::class.java, - fieldName = "stringField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = StringDTO::class.java, - fieldName = "stringField2" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = DateDTO::class.java, - fieldName = "dateField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = DateDTO::class.java, - fieldName = "dateField2" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = EnumDTO::class.java, - fieldName = "enumField1" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = ListDTO::class.java, - fieldName = "listField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.EMPTY_LIST, - fieldClass = ListDTO::class.java, - fieldName = "listField2" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = ListDTO::class.java, - fieldName = "listField3 (list value)" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = MapDTO::class.java, - fieldName = "mapField1" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.EMPTY_MAP, - fieldClass = MapDTO::class.java, - fieldName = "mapField2" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = MapDTO::class.java, - fieldName = "mapField3 (map key)" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = MapDTO::class.java, - fieldName = "mapField4 (map value)" - ), - - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = TestDTO::class.java, - fieldName = "primitiveField" - ), - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = TestDTO::class.java, - fieldName = "nullDTOField" - ) - ) - - val problems = checkDTOFieldsEmptiness( - values = listOf(dto), - ignoredFields = listOf() - ) - Assertions.assertEquals(expectedProblems, problems) - } -} - -@Suppress("unused") -private enum class EnumClass { - VALUE1, - VALUE2 -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt deleted file mode 100644 index c5c7b28af..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/DtoContractUnitTest.kt +++ /dev/null @@ -1,629 +0,0 @@ -package com.ecwid.apiclient.v3 - -import com.ecwid.apiclient.v3.dto.ApiRequest -import com.ecwid.apiclient.v3.dto.common.ApiFetchedDTO -import com.ecwid.apiclient.v3.dto.common.ApiRequestDTO -import com.ecwid.apiclient.v3.dto.common.ApiResultDTO -import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO -import com.ecwid.apiclient.v3.jsontransformer.JsonTransformer -import com.ecwid.apiclient.v3.rule.* -import com.ecwid.apiclient.v3.rule.NonnullPropertyRule.AllowNonnull -import com.ecwid.apiclient.v3.rule.NonnullPropertyRule.IgnoreNonnull -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable -import com.ecwid.apiclient.v3.util.* -import org.junit.jupiter.api.Assertions.* -import org.junit.jupiter.api.MethodOrderer.OrderAnnotation -import org.junit.jupiter.api.Order -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.TestMethodOrder -import org.reflections.Reflections -import org.reflections.scanners.Scanners -import org.reflections.scanners.Scanners.SubTypes -import org.reflections.util.ConfigurationBuilder -import org.reflections.util.FilterBuilder -import uk.co.jemos.podam.api.PodamFactoryImpl -import java.io.File -import java.io.InputStream -import java.lang.reflect.* -import kotlin.reflect.* -import kotlin.reflect.full.declaredMemberProperties -import kotlin.reflect.full.primaryConstructor -import kotlin.reflect.jvm.internal.impl.load.kotlin.header.KotlinClassHeader -import kotlin.reflect.jvm.javaField -import kotlin.reflect.jvm.javaGetter - -@TestMethodOrder(OrderAnnotation::class) -class DtoContractUnitTest { - - private val convertersReflections = lazy { - Reflections( - ConfigurationBuilder() - .forPackage("com.ecwid.apiclient.v3.converter") - .filterInputsBy( - FilterBuilder() - .includePattern("com\\.ecwid\\.apiclient\\.v3\\.converter\\..*") - ) - .setScanners(Scanners.MethodsReturn) - ) - } - - private val apiRequestClassesReflections = lazy { - Reflections( - ConfigurationBuilder() - .forPackage(ApiRequest::class.java.packageName) - .filterInputsBy( - FilterBuilder() - .includePattern(ApiRequest::class.java.packageName + "\\..*") - ) - .setScanners(SubTypes.filterResultsBy { true }) - ) - } - - private val getDtoClassesToCheck = lazy { - apiRequestClassesReflections - .value - .getSubTypesOf(Object::class.java) - .filterNot { clazz -> clazz.isInterface || clazz.isAnonymousClass || clazz.isLocalClass } - .filter { clazz -> - val kindId = clazz.getAnnotation(Metadata::class.java).kind - val kind = KotlinClassHeader.Kind.getById(kindId) - - kind == KotlinClassHeader.Kind.CLASS - } - .filterNot { clazz -> - try { - clazz.kotlin.isCompanion - } catch (ignore: UnsupportedOperationException) { - // Filtering file facades classes (*Kt classes) and synthetic classes (i.e. when-mappings classes) - true - } - } - .sortedBy { clazz -> clazz.canonicalName } - } - - @Test - @Order(0) - fun `test all DTOs marked as data classes`() { - val dtoClassesToCheck = getDtoClassesToCheck.value - assertFalse(dtoClassesToCheck.isEmpty()) - - val problemDtoClasses = dtoClassesToCheck.filter { dtoClass -> - !dtoClass.kotlin.isData && isDtoShouldBeMarkedAsDataClass(dtoClass) - } - assertTrue(problemDtoClasses.isEmpty()) { - "Some DTO classes are not marked as `data class`:\n" + classesToLoggableString(problemDtoClasses) - } - } - - @Test - @Order(1) - fun `test all data classes DTOs has default constructor`() { - val dtoClassesToCheck = getDtoClassesToCheck.value - .filter { dtoClass -> dtoClass.kotlin.isData } - assertFalse(dtoClassesToCheck.isEmpty()) - - val problemDtoClasses = dtoClassesToCheck.filter { dtoDataClass -> - val constructors = dtoDataClass.constructors - val hasZeroArgConstructor = constructors.any { constructor -> constructor.parameters.isEmpty() } - !hasZeroArgConstructor && isDtoShouldHaveZeroArgConstructor(constructors) - } - assertTrue(problemDtoClasses.isEmpty()) { - "Some DTO data classes does not have zero-arg constructors " + - "(you need to add default values for all primary constructor arguments):\n" + - classesToLoggableString(problemDtoClasses) - } - } - - @Test - @Order(2) - fun `test all data classes DTOs has only val parameters in their primary constructors`() { - val dtoClassesToCheck = getDtoClassesToCheck.value - .filter { dtoClass -> dtoClass.kotlin.isData } - assertFalse(dtoClassesToCheck.isEmpty()) - - val problemDtoClasses = dtoClassesToCheck.filter { dtoDataClass -> - isPrimaryConstructorHasMutableProperties(dtoDataClass) - } - assertTrue(problemDtoClasses.isEmpty()) { - "Some DTO data classes does have mutable properties in their primary constructors " + - "(you need to replace all parameters from `var` to `val`):\n" + - classesToLoggableString(problemDtoClasses) - } - } - - @Test - @Order(3) - fun `test all top level data classes DTOs implement one of DTO marker interface`() { - val dtoMarkerInterfaces = arrayOf( - ApiFetchedDTO::class.java, - ApiUpdatedDTO::class.java, - ApiRequestDTO::class.java, - ApiResultDTO::class.java - ) - - val dtoClassesToCheck = getDtoClassesToCheck.value - .filterNot { dtoClass -> dtoClass.isEnum } - .filterNot { dtoClass -> dtoClass.packageName.startsWith("com.ecwid.apiclient.v3.dto.common") } - assertFalse(dtoClassesToCheck.isEmpty()) - - val problemDtoClasses = dtoClassesToCheck - .filterNot { dtoClass -> dtoClass.isClassifiedDTOOrEnclosingClass(*dtoMarkerInterfaces) } - assertTrue(problemDtoClasses.isEmpty()) { - val interfacesStr = dtoMarkerInterfaces.joinToString(separator = ", ") { int -> int.simpleName } - "Some of top level DTO data classes do not implement any marker interfaces [$interfacesStr]:\n" + - classesToLoggableString(problemDtoClasses) - } - } - - @Test - @Order(4) - fun `test all DTOs marked as 'preferably having non-nullable fields' have only non-nullable fields or fields added to exclusion list`() { - val dtoClassesToCheck = getDtoClassesToCheck.value - .filter { dtoClass -> - dtoClass.isClassifiedDTOOrEnclosingClass( - ApiFetchedDTO::class.java, - ApiRequestDTO::class.java, - ApiResultDTO::class.java - ) - } - .filterNot { dtoClass -> dtoClass.kotlin.visibility == KVisibility.PRIVATE } - assertFalse(dtoClassesToCheck.isEmpty()) - - val allowedOrIgnoredNullableProperties = nullablePropertyRules - .filter { rule -> rule is AllowNullable || rule is IgnoreNullable } - .map { rule -> rule.property } - .toSet() - - val nullableProperties = dtoClassesToCheck - .flatMap { dtoDataClass -> - getPrimaryConstructorProperties(dtoDataClass) - .filter { property -> property.returnType.isMarkedNullable } - } - .toSet() - - val problemProperties = nullableProperties - allowedOrIgnoredNullableProperties - assertTrue(problemProperties.isEmpty()) { - "Some of DTO data classes have nullable properties but should not:\n" + - propertiesToLoggableString(problemProperties) + "\n" + - "Please make this properties non-nullable if possible.\n" + - "If Ecwid API sometimes return null as value for this property you CAN add it to as `AllowNullable()` exclusion in file `NullablePropertyRules.kt`\n" + - "You MUST NOT add exclusion with type IgnoreNullable() which is used only for old fields until they are fixed.\n" - } - } - - @Test - @Order(5) - fun `test no new exclusions added to file NullablePropertyRules`() { - val expectedNullablePropertiesCount = 931 - val ignoreNullablePropertiesCount = nullablePropertyRules - .filterIsInstance>() - .size - assertEquals(expectedNullablePropertiesCount, ignoreNullablePropertiesCount) { - "You MUST NOT add exclusion with type IgnoreNullable() which is used only for old fields until they are fixed.\n" + - "Please make added property non-nullable if possible.\n" + - "If Ecwid API sometimes return null as value for this property you CAN add it to as `AllowNullable()` exclusion type instead." - } - } - - @Test - @Order(6) - fun `test all DTOs marked as 'preferably having nullable fields' have only nullable fields or fields added to exclusion list`() { - val dtoClassesToCheck = getDtoClassesToCheck.value - .filter { dtoClass -> - dtoClass.isClassifiedDTOOrEnclosingClass( - ApiUpdatedDTO::class.java - ) - } - assertFalse(dtoClassesToCheck.isEmpty()) - - val allowedOrIgnoredNonnullProperties = nonnullPropertyRules - .filter { rule -> rule is AllowNonnull || rule is IgnoreNonnull } - .map { rule -> rule.property } - .toSet() - - val nonnullProperties = dtoClassesToCheck - .flatMap { dtoDataClass -> - getPrimaryConstructorProperties(dtoDataClass) - .filterNot { property -> property.returnType.isMarkedNullable } - } - .toSet() - - val problemProperties = nonnullProperties - allowedOrIgnoredNonnullProperties - assertTrue(problemProperties.isEmpty()) { - "Some of DTO data classes have nonnull properties but should not:\n" + - propertiesToLoggableString(problemProperties) + "\n" + - "Please make this properties nonnull if possible.\n" + - "If Ecwid API requires value for this property to be passed you CAN add it to as `AllowNonnull()` exclusion in file `NonnullPropertyRules.kt`\n" + - "You MUST NOT add exclusion with type IgnoreNonnull() which is used only for old fields until they are fixed.\n" - } - } - - @Test - @Order(7) - fun `test no new exclusions added to file NonnullPropertyRules`() { - val ignoreNullablePropertiesCount = nonnullPropertyRules - .filterIsInstance>() - .size - assertTrue(ignoreNullablePropertiesCount <= 42) { - "You MUST NOT add exclusion with type IgnoreNonnull() which is used only for old fields until they are fixed.\n" + - "Please make this properties nonnull if possible.\n" + - "If Ecwid API requires value for this property to be passed you CAN add it to as `AllowNonnull()` exclusion in file `NonnullPropertyRules.kt`" - } - } - - @Test - @Order(8) - fun `test fetched and updated DTOs correctly linked to each other`() { - val dtoClassesToCheck = getDtoClassesToCheck.value - assertFalse(dtoClassesToCheck.isEmpty()) - - val fetchedDTOClassesToModifyKindMap = getFetchedDTOClassesToModifyKindMap(dtoClassesToCheck) - val updatedDTOClassesToModifyKindMap = getUpdatedDTOClassesToModifyKindMap(dtoClassesToCheck) - - fetchedDTOClassesToModifyKindMap.forEach { (dtoClass, kind) -> - @Suppress("UNUSED_VARIABLE") - val guard = when (kind) { - ApiFetchedDTO.ModifyKind.ReadOnly -> { - // No UpdatedDTO to check - } - - is ApiFetchedDTO.ModifyKind.ReadWrite -> { - val updatedDTOClass = kind.updatedDTOClass - val updatedDtoModifyKind = updatedDTOClassesToModifyKindMap[updatedDTOClass] - val guard = when (updatedDtoModifyKind) { - is ApiUpdatedDTO.ModifyKind.ReadWrite -> { - assertEquals( - dtoClass, updatedDtoModifyKind.fetchedDTOClass, - "Classes ${dtoClass.qualifiedName} and ${updatedDTOClass.qualifiedName} does not links to each other" - ) - } - - null -> { - fail("Impossible situation") - } - } - } - } - } - - updatedDTOClassesToModifyKindMap.forEach { (dtoClass, kind) -> - @Suppress("UNUSED_VARIABLE") - val guard = when (kind) { - is ApiUpdatedDTO.ModifyKind.ReadWrite -> { - val fetchedDTOClass = kind.fetchedDTOClass - val fetchedDtoModifyKind = fetchedDTOClassesToModifyKindMap[fetchedDTOClass] - val guard = when (fetchedDtoModifyKind) { - ApiFetchedDTO.ModifyKind.ReadOnly -> { - fail("Updatable class ${dtoClass.qualifiedName} links to class ${fetchedDTOClass.qualifiedName} which is marked as read-only ") - } - - is ApiFetchedDTO.ModifyKind.ReadWrite -> { - // Backlink was checked before - } - - null -> { - fail("Impossible situation") - } - } - } - } - } - } - - @Test - @Order(9) - fun `test fetched and updated DTOs fields list and their types are synchronized`() { - val dtoClassesToCheck = getDtoClassesToCheck.value - assertFalse(dtoClassesToCheck.isEmpty()) - - val fetchedUpdatedDTOs = dtoClassesToCheck - .filter { dtoClass -> - ApiFetchedDTO::class.java.isAssignableFrom(dtoClass) - }.mapNotNull { fetchedDtoClass -> - val instance = fetchedDtoClass.getConstructor().newInstance() as ApiFetchedDTO - val dtoModifyKind = instance.getModifyKind() - if (dtoModifyKind is ApiFetchedDTO.ModifyKind.ReadWrite) { - FetchedUpdatedDTO( - fetchedClass = fetchedDtoClass, - updatedClass = dtoModifyKind.updatedDTOClass.java - ) - } else { - null - } - } - - val fieldsProblems = checkFetchedUpdatedDTOsFields(fetchedUpdatedDTOs, nonUpdatablePropertyRules) - - assertTrue(fieldsProblems.isEmpty()) { - fieldsProblems.joinToString(prefix = "\n\n", separator = "\n\n") { fieldsProblem -> - fieldsProblem.buildMessage() - } - } - } - - @Test - @Order(10) - fun `test no new exclusions added to file NonUpdatablePropertyRules`() { - val ignoreNonUpdatablePropertyRulesCount = nonUpdatablePropertyRules - .filterIsInstance>() - .size - assertTrue(ignoreNonUpdatablePropertyRulesCount <= 160) { - "You MUST NOT add exclusion with type Ignored() which is used only for old fields until they are fixed.\n" + - "Please add this field to Updated DTO if possible.\n" + - "If this field is read-only in Ecwid API you CAN add it as `ReadOnly()` exclusion to file `NonUpdatablePropertyRules.kt`." - } - } - - @Test - @Order(11) - fun `test toUpdated extension functions are implemented correctly for all updatable FetchedDTOs`() { - val dataStrategy = DTORandomDataProviderStrategy() - val factory = PodamFactoryImpl(dataStrategy) - - val dtoClassesToCheck = getDtoClassesToCheck.value - assertFalse(dtoClassesToCheck.isEmpty()) - - val fetchedDTOClassesToModifyKindMap = getFetchedDTOClassesToModifyKindMap(dtoClassesToCheck) - - val problemMessages = mutableListOf() - - val updatedDTOs = fetchedDTOClassesToModifyKindMap.mapNotNull { (fetchedDtoClass, kind) -> - when (kind) { - ApiFetchedDTO.ModifyKind.ReadOnly -> { - // No UpdatedDTO to check - null - } - - is ApiFetchedDTO.ModifyKind.ReadWrite -> { - @Suppress("UNCHECKED_CAST") - val fetchedDtoKClass = fetchedDtoClass as KClass - val updatedDTOClass = kind.updatedDTOClass - - val toUpdatedMethod: Method? = - findToUpdatedMethod(convertersReflections.value, fetchedDtoKClass, updatedDTOClass) - if (toUpdatedMethod == null) { - problemMessages += "Extension function with signature `${fetchedDtoKClass.java.canonicalName}.toUpdated(): ${updatedDTOClass.java.canonicalName}` is not implemented" - null - } else { - val fetchedDTO = factory.manufacturePojo(fetchedDtoKClass.java) - try { - toUpdatedMethod.invoke(null, fetchedDTO) as ApiUpdatedDTO - } catch (e: InvocationTargetException) { - problemMessages += "Exception occurred during invoking method `${fetchedDtoKClass.java.canonicalName}.toUpdated(): ${e.targetException.message}" - null - } - } - } - } - } - - problemMessages += checkDTOFieldsEmptiness( - values = updatedDTOs, - ignoredFields = nonDuplicablePropertyRules.map(NonDuplicablePropertyRule<*, *>::property) - ) - .map(FieldEmptinessProblem::buildMessage) - - if (problemMessages.isNotEmpty()) { - fail { - "Some of Fetched DTOs' fields are not copied to Updated DTOs in proper way:\n" + - messagesToLoggableString(problemMessages) + "\n" + - "Please implement proper toUpdate() extension function for this fields.\n" + - "If this field is really write-only according to Ecwid API documentation you CAN add it as `WriteOnly()` exclusion in file `NonDuplicablePropertyRules.kt`.\n" + - "You MUST NOT add exclusion of any other type to this list.\n" - } - } - } - - @Test - @Order(12) - fun `test no new non write-only exclusions added to file NonDuplicablePropertyRules`() { - val nonWriteOnlyPropertyRulesCount = nonDuplicablePropertyRules - .filter { it !is NonDuplicablePropertyRule.WriteOnly } - .size - if (nonWriteOnlyPropertyRulesCount > 1) { - fail { - "You MUST NOT add exclusion with types other than `WriteOnly()` to file `NonDuplicablePropertyRules.kt`.\n" + - "If this field is really write-only according to Ecwid API documentation you CAN add it as `WriteOnly()` exclusion.\n" + - "Otherwise you MUST add proper implementation of method toUpdate() for this field." - } - } - } -} - -private fun FieldProblem.buildMessage(): String { - val problemKind = kind - val fieldName = fieldName - - val fetchedDTOClassName = fetchedDTOClass.canonicalName - val updatedDTOClassName = updatedDTOClass.canonicalName - - val actualFieldClass = actualFieldClass - val actualFieldClassStr = if (actualFieldClass != null) actualFieldClass.canonicalName else "" - - val expectedFieldClass = expectedFieldClass - val expectedFieldClassStr = if (expectedFieldClass != null) expectedFieldClass.canonicalName else "" - - val problemTitle = when (problemKind) { - FieldProblemKind.FIELD_NOT_FOUND -> { - "All updatable fields from Fetched DTO must have corresponding field in Updated DTO." - } - - FieldProblemKind.TYPE_MUST_NOT_BE_REUSED -> { - "Fields with the same name in Fetched and Updated DTOs must not share the same DTO (except for primitives and enums)" - } - - FieldProblemKind.FIELD_IS_NOT_MAP, - FieldProblemKind.FIELD_IS_NOT_LIST, - FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE -> { - "n/a" - } - } - - val problemDescription = when (problemKind) { - FieldProblemKind.FIELD_NOT_FOUND -> { - "Please add this field to Updated DTO if possible.\n" + - "If this field is read-only in Ecwid API you CAN add it as `ReadOnly()` exclusion to file `NonUpdatablePropertyRules.kt`.\n" + - "You MUST NOT add exclusion with type Ignored() which is used only for old fields until they are fixed." - } - - FieldProblemKind.FIELD_IS_NOT_MAP, - FieldProblemKind.FIELD_IS_NOT_LIST, - FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - FieldProblemKind.TYPE_MUST_NOT_BE_REUSED -> "n/a" - } - - return """ -$problemKind: $problemTitle -Description: - ${problemDescription.split("\n").joinToString(separator = "\n\t\t")} -Details: - fetchedDTOField: $fetchedDTOClassName::$fieldName - updatedDTOField: $updatedDTOClassName::$fieldName - expectedFieldClass: $expectedFieldClassStr - actualFieldClass: $actualFieldClassStr -""" -} - -private fun FieldEmptinessProblem.buildMessage(): String { - val fieldName = "${fieldClass?.canonicalName}::$fieldName" - val fieldProblemMessage = when (kind) { - FieldEmptinessProblemKind.NULL_VALUE -> "has null value" - FieldEmptinessProblemKind.DEFAULT_VALUE -> "has null value" - FieldEmptinessProblemKind.EMPTY_LIST -> "is an empty list" - FieldEmptinessProblemKind.EMPTY_MAP -> "is an empty map" - } - return "Field `$fieldName` $fieldProblemMessage" -} - -private fun propertiesToLoggableString(properties: Collection>): String { - return properties - .sortedBy { property -> property.toString() } - .joinToString( - separator = "\n", - transform = { property -> "\t* ${property.declaringClass().canonicalName}::${property.name}" } - ) -} - -private fun classesToLoggableString(classes: Collection>): String { - return classes.joinToString( - separator = "\n", - transform = { clazz -> "\t* ${clazz.name}" } - ) -} - -private fun messagesToLoggableString(messages: Collection): String { - return messages.joinToString( - separator = "\n", - transform = { message -> "\t* $message" } - ) -} - -private fun isDtoShouldBeMarkedAsDataClass(dtoClass: Class<*>): Boolean { - val kclass = dtoClass.kotlin - - return when { - kclass.isSealed -> { - // Sealed classes must not be instantiated by themself but their inheritors must be marked as data classes - false - } - - kclass.objectInstance != null -> { - // Singleton classes has no explicit constructor arguments so it cannot be marked as data class - false - } - - else -> { - // Classes that has only one zero-arg constructor cannot be marked as data class - val constructors = dtoClass.constructors - val classHasOnlyZeroArgConstructor = constructors.size == 1 && constructors.first().parameters.isEmpty() - !classHasOnlyZeroArgConstructor - } - } -} - -private fun isDtoShouldHaveZeroArgConstructor(constructors: Array>): Boolean { - val maxParametersConstructor = constructors.maxByOrNull { constructor -> constructor.parameters.size } - if (maxParametersConstructor == null) { - // Strange things - return true - } - - val hasSpecialParameterType = maxParametersConstructor.parameters.any { parameter -> - // We have some DTOs with special primary constructor parameter types. - // We cannot assign a default value to them so will ignore them - parameter.type.isAssignableFrom(JsonTransformer::class.java) || - parameter.type.isAssignableFrom(File::class.java) || - parameter.type.isAssignableFrom(InputStream::class.java) || - parameter.type.isAssignableFrom(KClass::class.java) - } - - return !hasSpecialParameterType -} - -private fun isPrimaryConstructorHasMutableProperties(dtoDataClass: Class<*>): Boolean { - val primaryConstructorProperties = getPrimaryConstructorProperties(dtoDataClass) - return primaryConstructorProperties.any { property -> - property is KMutableProperty<*> - } -} - -private fun getPrimaryConstructorProperties(dtoDataClass: Class<*>): List> { - val kclass = dtoDataClass.kotlin - return kclass.declaredMemberProperties.filter { member -> - kclass.primaryConstructor?.parameters?.any { parameter -> member.name == parameter.name } ?: false - } -} - -internal fun getFetchedDTOClassesToModifyKindMap(dtoClassesToCheck: List>): Map, ApiFetchedDTO.ModifyKind> { - return dtoClassesToCheck - .filter { dtoClass -> - ApiFetchedDTO::class.java.isAssignableFrom(dtoClass) - }.associate { dtoClass -> - val instance = dtoClass.getConstructor().newInstance() as ApiFetchedDTO - dtoClass.kotlin to instance.getModifyKind() - } -} - -private fun getUpdatedDTOClassesToModifyKindMap(dtoClassesToCheck: List>): Map, ApiUpdatedDTO.ModifyKind> { - return dtoClassesToCheck - .filter { dtoClass -> - ApiUpdatedDTO::class.java.isAssignableFrom(dtoClass) - }.associate { dtoClass -> - val instance = dtoClass.getConstructor().newInstance() as ApiUpdatedDTO - dtoClass.kotlin as KClass<*> to instance.getModifyKind() - } -} - -private fun findToUpdatedMethod( - reflections: Reflections, - fetchedDtoClass: KClass, - updatedDtoClass: KClass -): Method? { - return reflections - .getMethodsReturn(updatedDtoClass.java) - .filter { method -> method.name == "toUpdated" } - .filter { method -> method.parameterCount == 1 } - .firstOrNull { method -> method.parameters[0].type == fetchedDtoClass.java } -} - -private fun Class<*>.isClassifiedDTOOrEnclosingClass(vararg dtoMarkerInterfaces: Class<*>): Boolean { - return dtoMarkerInterfaces.any { dtoMarkerInterface: Class<*> -> - isClassifiedDTOOrEnclosingClass(dtoMarkerInterface) - } -} - -private fun Class<*>.isClassifiedDTOOrEnclosingClass(dtoMarkerInterface: Class<*>): Boolean { - var clazz: Class<*>? = this - while (clazz != null) { - if (dtoMarkerInterface.isAssignableFrom(clazz)) { - return true - } - clazz = clazz.enclosingClass - } - return false -} - -fun KProperty<*>.declaringClass(): Class<*> { - return (this.javaField as Member? ?: this.javaGetter)?.declaringClass ?: error("Unable to access declaring class") -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/EncodeUtilsUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/EncodeUtilsUnitTest.kt deleted file mode 100644 index e926e2202..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/EncodeUtilsUnitTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.ecwid.apiclient.v3 - -import com.ecwid.apiclient.v3.util.buildEndpointPath -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class EncodeUtilsUnitTest { - - @Test - fun `test buildEndpointPath with single segment`() { - assertEquals( - "orders", - buildEndpointPath( - listOf( - "orders" - ) - ) - ) - } - - @Test - fun `test buildEndpointPath with multiple segments`() { - val expectedEncodedOptionName = - "option+with%25spaces%24and%23other%26special%2Bsymbols%5E%D0%B2%D0%BA%D0%BB%D1%8E%D1%87" + - "%D0%B0%D1%8F%28%D0%BD%D0%95%D0%BB%D0%90%D0%A2%D0%B8%D0%9D%D1%81%D0%9A%D0%B8%D0%95%29" - assertEquals( - "orders/order%2Fentity%2Fwith%2Fslashes%2F123/items/456/options/$expectedEncodedOptionName/files/789", - buildEndpointPath( - listOf( - "orders", - "order/entity/with/slashes/123", - "items", - "456", - "options", - "option with%spaces\$and#other&special+symbols^включая(нЕлАТиНсКиЕ)", - "files", - "789" - ) - ) - ) - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/FetchedUpdatedDTOsCheckerUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/FetchedUpdatedDTOsCheckerUnitTest.kt deleted file mode 100644 index 9448425dd..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/FetchedUpdatedDTOsCheckerUnitTest.kt +++ /dev/null @@ -1,379 +0,0 @@ -package com.ecwid.apiclient.v3 - -import com.ecwid.apiclient.v3.rule.NonUpdatablePropertyRule -import com.ecwid.apiclient.v3.util.FieldProblem -import com.ecwid.apiclient.v3.util.FieldProblemKind -import com.ecwid.apiclient.v3.util.checkFetchedUpdatedDTOsFields -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test - -class FetchedUpdatedDTOsCheckerUnitTest { - - @Test - fun `test field found in Fetched DTO but not found in Updated DTO`() { - data class FetchedDTO( - val field1: Int, - val field2: String - ) - - data class UpdatedDTO( - val field1: Int - ) - - val problems = checkFetchedUpdatedDTOsFields(FetchedDTO::class.java, UpdatedDTO::class.java, listOf()) - - val expectedProblems = listOf( - FieldProblem( - kind = FieldProblemKind.FIELD_NOT_FOUND, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field2", - expectedFieldClass = String::class.java, - actualFieldClass = null - ) - ) - Assertions.assertEquals(expectedProblems, problems) - } - - @Test - fun `test field in Fetched sub DTO but not found in Updated sub DTO`() { - data class FetchedSubDTO( - val subField1: Double, - val subField2: String - ) - - data class FetchedDTO( - val field1: Int, - val field2: FetchedSubDTO - ) - - data class UpdatedSubDTO( - val subField1: Double - ) - - data class UpdatedDTO( - val field1: Int, - val field2: UpdatedSubDTO - ) - - val problems = checkFetchedUpdatedDTOsFields(FetchedDTO::class.java, UpdatedDTO::class.java, listOf()) - - val expectedProblems = listOf( - FieldProblem( - kind = FieldProblemKind.FIELD_NOT_FOUND, - fetchedDTOClass = FetchedSubDTO::class.java, - updatedDTOClass = UpdatedSubDTO::class.java, - fieldName = "subField2", - expectedFieldClass = String::class.java, - actualFieldClass = null - ) - ) - Assertions.assertEquals(expectedProblems, problems) - } - - @Test - fun `test incompatible field types`() { - data class FetchedDTO( - val field1: Int, - val field2: String, - val field3: String - ) - - data class UpdatedSubDTO( - val subField2: Int - ) - - data class UpdatedDTO( - val field1: Int, - val field2: Double, - val field3: UpdatedSubDTO - ) - - val problems = checkFetchedUpdatedDTOsFields(FetchedDTO::class.java, UpdatedDTO::class.java, listOf()) - - val expectedProblems = listOf( - FieldProblem( - kind = FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field2", - expectedFieldClass = String::class.java, - actualFieldClass = Double::class.java - ), - FieldProblem( - kind = FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field3", - expectedFieldClass = String::class.java, - actualFieldClass = UpdatedSubDTO::class.java - ) - ) - Assertions.assertEquals(expectedProblems, problems) - } - - @Test - fun `test field is list in Fetched DTO but is not in Updated DTO`() { - data class FetchedDTO( - val field1: Int, - val field2: List - ) - - data class UpdatedSubDTO( - val subField1: Int - ) - - data class UpdatedDTO( - val field1: Int, - val field2: UpdatedSubDTO - ) - - val problems = checkFetchedUpdatedDTOsFields(FetchedDTO::class.java, UpdatedDTO::class.java, listOf()) - - val expectedProblems = listOf( - FieldProblem( - kind = FieldProblemKind.FIELD_IS_NOT_LIST, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field2", - expectedFieldClass = List::class.java, - actualFieldClass = UpdatedSubDTO::class.java - ) - ) - Assertions.assertEquals(expectedProblems, problems) - } - - @Test - fun `test field is map in Fetched DTO but is not in Updated DTO`() { - data class FetchedDTO( - val field1: Int, - val field2: Map - ) - - data class UpdatedSubDTO( - val subField1: Int - ) - - data class UpdatedDTO( - val field1: Int, - val field2: UpdatedSubDTO - ) - - val problems = checkFetchedUpdatedDTOsFields(FetchedDTO::class.java, UpdatedDTO::class.java, listOf()) - - val expectedProblems = listOf( - FieldProblem( - kind = FieldProblemKind.FIELD_IS_NOT_MAP, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field2", - expectedFieldClass = Map::class.java, - actualFieldClass = UpdatedSubDTO::class.java - ) - ) - Assertions.assertEquals(expectedProblems, problems) - } - - @Test - fun `test incompatible list generic type for field in Fetched and Updated DTOs`() { - class FetchedListWrapper : ArrayList() - - data class FetchedDTO( - val field1: Int, - val field2: List, - val field3: FetchedListWrapper - ) - - class UpdatedListWrapper : ArrayList() - - data class UpdatedDTO( - val field1: Int, - val field2: List, - val field3: UpdatedListWrapper - ) - - val problems = checkFetchedUpdatedDTOsFields(FetchedDTO::class.java, UpdatedDTO::class.java, listOf()) - - val expectedProblems = listOf( - FieldProblem( - kind = FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field2 (list value)", - expectedFieldClass = Int::class.javaObjectType, - actualFieldClass = String::class.java - ), - FieldProblem( - kind = FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field3 (list value)", - expectedFieldClass = Int::class.javaObjectType, - actualFieldClass = String::class.java - ) - ) - Assertions.assertEquals(expectedProblems, problems) - } - - @Test - fun `test incompatible map generic types for field in Fetched and Updated DTOs`() { - class FetchedMapWrapper : HashMap() - - data class FetchedDTO( - val field1: Int, - val field2: Map, - val field3: Map, - val field4: FetchedMapWrapper, - val field5: FetchedMapWrapper - ) - - class UpdatedMapWrapper1 : HashMap() - class UpdatedMapWrapper2 : HashMap() - - data class UpdatedDTO( - val field1: Int, - val field2: Map, - val field3: Map, - val field4: UpdatedMapWrapper1, - val field5: UpdatedMapWrapper2 - ) - - val problems = checkFetchedUpdatedDTOsFields(FetchedDTO::class.java, UpdatedDTO::class.java, listOf()) - - val expectedProblems = listOf( - FieldProblem( - kind = FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field2 (map value)", - expectedFieldClass = Int::class.javaObjectType, - actualFieldClass = String::class.java - ), - FieldProblem( - kind = FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field3 (map key)", - expectedFieldClass = Int::class.javaObjectType, - actualFieldClass = String::class.java - ), - FieldProblem( - kind = FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field4 (map value)", - expectedFieldClass = Int::class.javaObjectType, - actualFieldClass = String::class.java - ), - FieldProblem( - kind = FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field5 (map key)", - expectedFieldClass = Int::class.javaObjectType, - actualFieldClass = String::class.java - ) - ) - Assertions.assertEquals(expectedProblems, problems) - } - - @Test - fun `test non primitive fields types must not be shared between Fetched and Updated DTOs`() { - data class FetchedDTO( - val field1: Int, - val field2: SharedDTO, - val field3: SharedEnum - ) - - data class UpdatedDTO( - val field1: Int, - val field2: SharedDTO, - val field3: SharedEnum - ) - - val problems = checkFetchedUpdatedDTOsFields(FetchedDTO::class.java, UpdatedDTO::class.java, listOf()) - - val expectedProblems = listOf( - FieldProblem( - kind = FieldProblemKind.TYPE_MUST_NOT_BE_REUSED, - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - fieldName = "field2", - expectedFieldClass = null, - actualFieldClass = SharedDTO::class.java - ) - ) - Assertions.assertEquals(expectedProblems, problems) - } - - @Test - fun `test ignored fields`() { - data class FetchedDTO( - val field1: Int, - val field2: String - ) - - data class UpdatedDTO( - val field1: Int - ) - - val problems = checkFetchedUpdatedDTOsFields( - fetchedDTOClass = FetchedDTO::class.java, - updatedDTOClass = UpdatedDTO::class.java, - nonUpdatablePropertyRules = listOf( - NonUpdatablePropertyRule.Ignored(FetchedDTO::field2) - ) - ) - Assertions.assertEquals(listOf(), problems) - } - - @Test - fun `test success`() { - class FetchedListWrapper : ArrayList() - - class FetchedMapWrapper : HashMap() - - data class FetchedSubDTO( - val subField1: List, - val subField2: FetchedListWrapper, - val subField3: Map, - val subField4: FetchedMapWrapper - ) - - data class FetchedDTO( - val field1: Int, - val field2: String, - val field3: FetchedSubDTO - ) - - class UpdatedListWrapper : ArrayList() - - class UpdatedMapWrapper : HashMap() - - data class UpdatedSubDTO( - val subField1: List, - val subField2: UpdatedListWrapper, - val subField3: Map, - val subField4: UpdatedMapWrapper - ) - - data class UpdatedDTO( - val field1: Int, - val field2: String, - val field3: UpdatedSubDTO - ) - - val problems = checkFetchedUpdatedDTOsFields(FetchedDTO::class.java, UpdatedDTO::class.java, listOf()) - Assertions.assertEquals(listOf(), problems) - } -} - -data class SharedDTO( - val subField1: Int -) - -@Suppress("unused") -private enum class SharedEnum { - VALUE_ONE, - VALUE_TWO -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/MaskUtilsUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/MaskUtilsUnitTest.kt deleted file mode 100644 index a5b6c9063..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/MaskUtilsUnitTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.ecwid.apiclient.v3 - -import com.ecwid.apiclient.v3.util.SecurePattern -import com.ecwid.apiclient.v3.util.maskLogString -import com.ecwid.apiclient.v3.util.maskSensitive -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class MaskUtilsUnitTest { - - @Test - fun testMaskLogKeyValueString() { - val logString = - "token=secret_RandomToken0jwOrgYc5sSKBYcvO0DbP; PasswordCredentials(email=test@example.com, password=123456)" - val securePatterns = listOf( - SecurePattern(Regex("token=(?:secret_|public_|)([^;,)]+)"), 6), - SecurePattern(Regex("email=([^;,)]+)"), 4), - SecurePattern(Regex("password=([^;,)]+)"), 2), - ) - - val maskedLogString = logString.maskLogString(securePatterns) - val expectedMaskedLogString = "token=secret_Ran***DbP; PasswordCredentials(email=te***om, password=1***6)" - assertEquals(expectedMaskedLogString, maskedLogString) - } - - @Test - fun testMaskLogJsonString() { - val logString = - """{"billingPerson":{"email":"alexis@ecwid.com","firstName":"John","lastName":"Smith","phone":"123467890"}}""" - val securePatterns = listOf( - SecurePattern(Regex(""""email":\s*"([^"]*)""""), 6), - SecurePattern(Regex(""""firstName":\s*"([^"]*)""""), 6), - SecurePattern(Regex(""""lastName":\s*"([^"]*)""""), 6), - SecurePattern(Regex(""""phone":\s*"([^"]*)""""), 6), - ) - - val maskedLogString = logString.maskLogString(securePatterns) - val expectedMaskedLogString = - """{"billingPerson":{"email":"ale***com","firstName":"***","lastName":"***","phone":"***"}}""" - assertEquals(expectedMaskedLogString, maskedLogString) - } - - @Test - fun testMaskSensitive() { - assertEquals("te***ng", "test string".maskSensitive(4)) - assertEquals("***", "test string".maskSensitive(8)) - } - -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/BaseEntityTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/BaseEntityTest.kt deleted file mode 100644 index a4693b1ed..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/BaseEntityTest.kt +++ /dev/null @@ -1,254 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.ApiClient -import com.ecwid.apiclient.v3.ApiClientHelper -import com.ecwid.apiclient.v3.config.ApiServerDomain -import com.ecwid.apiclient.v3.config.ApiStoreCredentials -import com.ecwid.apiclient.v3.config.LoggingSettings -import com.ecwid.apiclient.v3.dto.category.request.CategoriesSearchRequest -import com.ecwid.apiclient.v3.dto.category.request.CategoryDeleteRequest -import com.ecwid.apiclient.v3.dto.category.result.CategoriesSearchResult -import com.ecwid.apiclient.v3.dto.category.result.FetchedCategory -import com.ecwid.apiclient.v3.dto.coupon.request.CouponDeleteRequest -import com.ecwid.apiclient.v3.dto.coupon.request.CouponSearchRequest -import com.ecwid.apiclient.v3.dto.coupon.result.FetchedCoupon -import com.ecwid.apiclient.v3.dto.customer.request.CustomerDeleteRequest -import com.ecwid.apiclient.v3.dto.customer.request.CustomersSearchRequest -import com.ecwid.apiclient.v3.dto.customer.result.FetchedCustomer -import com.ecwid.apiclient.v3.dto.customergroup.request.CustomerGroupDeleteRequest -import com.ecwid.apiclient.v3.dto.customergroup.request.CustomerGroupsSearchRequest -import com.ecwid.apiclient.v3.dto.customergroup.result.FetchedCustomerGroup -import com.ecwid.apiclient.v3.dto.order.request.OrderDeleteRequest -import com.ecwid.apiclient.v3.dto.order.request.OrdersSearchRequest -import com.ecwid.apiclient.v3.dto.order.result.FetchedOrder -import com.ecwid.apiclient.v3.dto.product.request.ProductDeleteRequest -import com.ecwid.apiclient.v3.dto.product.request.ProductsSearchRequest -import com.ecwid.apiclient.v3.dto.product.result.FetchedProduct -import com.ecwid.apiclient.v3.dto.product.result.ProductsSearchResult -import com.ecwid.apiclient.v3.dto.producttype.request.ProductTypeDeleteRequest -import com.ecwid.apiclient.v3.dto.producttype.request.ProductTypesGetAllRequest -import com.ecwid.apiclient.v3.dto.producttype.result.FetchedProductType -import com.ecwid.apiclient.v3.dto.profile.enums.ProductFilterType -import com.ecwid.apiclient.v3.dto.profile.request.StoreProfileUpdateRequest -import com.ecwid.apiclient.v3.dto.profile.request.UpdatedStoreProfile -import com.ecwid.apiclient.v3.dto.variation.request.DeleteAllProductVariationsRequest -import com.ecwid.apiclient.v3.exception.EcwidApiException -import com.ecwid.apiclient.v3.httptransport.impl.ApacheCommonsHttpClientTransport -import com.ecwid.apiclient.v3.jsontransformer.gson.GsonTransformerProvider -import com.ecwid.apiclient.v3.util.PropertiesLoader -import org.junit.jupiter.api.Assertions -import java.nio.file.Path -import java.nio.file.Paths - -abstract class BaseEntityTest { - - protected lateinit var apiClient: ApiClient - protected lateinit var apiClientHelper: ApiClientHelper - - protected open fun beforeEach() { - val properties = PropertiesLoader.load() - apiClientHelper = ApiClientHelper( - apiServerDomain = ApiServerDomain( - host = properties.apiHost, - securePort = properties.apiPort - ), - credentials = ApiStoreCredentials( - storeId = properties.storeId, - apiToken = properties.apiToken - ), - loggingSettings = LoggingSettings().copy( - logRequest = true, - logRequestBody = true, - logSuccessfulResponseBody = true, - maxLogSectionLength = 100 * 1024, - ), - httpTransport = ApacheCommonsHttpClientTransport(defaultHeaders = emptyList()), - jsonTransformerProvider = GsonTransformerProvider() - ) - apiClient = ApiClient(apiClientHelper) - } - - protected fun initStoreProfile() { - val expectedProfile = UpdatedStoreProfile( - generalInfo = UpdatedStoreProfile.GeneralInfo( - storeUrl = "" - ), - formatsAndUnits = UpdatedStoreProfile.FormatsAndUnits( - orderNumberPrefix = "", - orderNumberSuffix = "" - ), - languages = UpdatedStoreProfile.Languages( - enabledLanguages = listOf("en", "ru"), - defaultLanguage = "en" - ), - taxSettings = UpdatedStoreProfile.TaxSettings( - automaticTaxEnabled = false, - taxes = listOf(), - pricesIncludeTax = false - ), - productFiltersSettings = UpdatedStoreProfile.ProductFiltersSettings( - enabledInStorefront = true, - filterSections = listOf( - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.PRICE, - enabled = false, - ), - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.IN_STOCK, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.ON_SALE, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.CATEGORIES, - enabled = false, - ), - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.SEARCH, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - name = "Color", - type = ProductFilterType.OPTION, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - name = "Brand", - type = ProductFilterType.ATTRIBUTE, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - name = "UPC", - type = ProductFilterType.ATTRIBUTE, - enabled = true, - ), - ), - ) - ) - - apiClient.updateStoreProfile(StoreProfileUpdateRequest(expectedProfile)) - } - - protected fun removeAllVariations() { - apiClient - .searchProductsAsSequence(ProductsSearchRequest.ByFilters()) - .map(FetchedProduct::id) - .filterNotNull() - .forEach { productId -> - apiClient.deleteAllProductVariations(DeleteAllProductVariationsRequest(productId)) - } - } - - protected fun removeAllProducts() { - apiClient - .searchProductsAsSequence(ProductsSearchRequest.ByFilters()) - .map(FetchedProduct::id) - .forEach { productId -> - apiClient.deleteProduct(ProductDeleteRequest(productId)) - } - } - - protected fun removeAllCategories() { - apiClient - .searchCategoriesAsSequence(CategoriesSearchRequest(hiddenCategories = true)) - .map(FetchedCategory::id) - .forEach { categoryId -> - try { - apiClient.deleteCategory(CategoryDeleteRequest(categoryId)) - } catch (ignore: EcwidApiException) { - // ok - } - } - } - - protected fun removeAllOrders() { - // This test is very much tied to the number of orders. Therefore, we wait for some time, until the order to index - // and remove them again. - Thread.sleep(1000) - - apiClient - .searchOrdersAsSequence(OrdersSearchRequest()) - .map(FetchedOrder::orderNumber) - .filterNotNull() - .forEach { orderNumber -> - apiClient.deleteOrder(OrderDeleteRequest(orderNumber)) - } - } - - protected fun removeAllProductTypes() { - apiClient - .getAllProductTypes(ProductTypesGetAllRequest()) - .map(FetchedProductType::id) - .filter { productTypeId -> productTypeId > 0 } // We cannot delete “General” product type - .forEach { productTypeId -> - apiClient.deleteProductType(ProductTypeDeleteRequest(productTypeId)) - } - } - - protected fun removeAllCustomers() { - apiClient - .searchCustomersAsSequence(CustomersSearchRequest()) - .map(FetchedCustomer::id) - .filterNotNull() - .forEach { customerId -> - apiClient.deleteCustomer(CustomerDeleteRequest(customerId)) - } - } - - protected fun removeAllCustomerGroups() { - apiClient - .searchCustomerGroupsAsSequence(CustomerGroupsSearchRequest()) - .map(FetchedCustomerGroup::id) - .filterNotNull() - .filter { customerGroupId -> customerGroupId > 0 } // We cannot delete “General” customer group - .forEach { customerGroupId -> - apiClient.deleteCustomerGroup(CustomerGroupDeleteRequest(customerGroupId)) - } - } - - protected fun removeAllCoupons() { - apiClient - .searchCouponsAsSequence(CouponSearchRequest()) - .map(FetchedCoupon::code) - .filterNotNull() - .forEach { couponIdentifier -> - apiClient.deleteCoupon(CouponDeleteRequest(couponIdentifier)) - } - } - - protected fun getTestPngFilePath(): Path = Paths.get(javaClass.getResource("/logo-ecwid-small.png").toURI()) - - protected fun waitForIndexedProducts( - productsSearchRequest: ProductsSearchRequest.ByFilters, - desiredProductCount: Int - ): ProductsSearchResult { - return processDelay(1500L, 10) { - val productsSearchResult = apiClient.searchProducts(productsSearchRequest) - if (productsSearchResult.items.size == desiredProductCount) productsSearchResult else null - } - } - - protected fun waitForIndexedCategories( - categoriesSearchRequest: CategoriesSearchRequest, - desiredCategoriesCount: Int - ): CategoriesSearchResult { - return processDelay(1500L, 10) { - val productsSearchResult = apiClient.searchCategories(categoriesSearchRequest) - if (productsSearchResult.items.size == desiredCategoriesCount) productsSearchResult else null - } - } - - protected inline fun processDelay(delay: Long, totalTries: Int, crossinline block: () -> T?): T { - var tries = 0 - if (tries >= totalTries) return Assertions.fail("Expected 'totalTries' value must be > 0, but actual is '$totalTries'") - do { - val result = block() - if (result != null) return result - tries++ - Thread.sleep(delay * tries) - } while (tries < totalTries) - return Assertions.fail("After $tries tries, item was not processed") - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/BatchApiTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/BatchApiTest.kt deleted file mode 100644 index 68cf5ee29..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/BatchApiTest.kt +++ /dev/null @@ -1,115 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.dto.batch.request.CreateBatchRequestWithIds -import com.ecwid.apiclient.v3.dto.batch.request.GetEscapedBatchRequest -import com.ecwid.apiclient.v3.dto.batch.result.BatchStatus -import com.ecwid.apiclient.v3.dto.product.request.ProductCreateRequest -import com.ecwid.apiclient.v3.dto.product.request.ProductsSearchRequest -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct -import com.ecwid.apiclient.v3.dto.product.result.ProductCreateResult -import com.ecwid.apiclient.v3.dto.product.result.ProductsSearchResult -import com.ecwid.apiclient.v3.impl.TypedBatchResponse -import com.ecwid.apiclient.v3.util.randomAlphanumeric -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class BatchApiTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - } - - @Test - fun `Create a product with batch API and search it`() { - val name = randomAlphanumeric(8) - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = name - ) - ) - - val productSearchRequest = ProductsSearchRequest.ByFilters( - keyword = name - ) - - val createProductBatch = apiClient.createBatch( - CreateBatchRequestWithIds( - requests = mapOf( - "test_product" to productCreateRequest - ) - ) - ) - - waitForIndexedProducts(productSearchRequest, 1) - - val createProductBatchResult = apiClient.getTypedBatch( - GetEscapedBatchRequest( - ticket = createProductBatch.ticket - ) - ) - - val createResponses = createProductBatchResult.responses - require(createResponses != null) - when ( - val productCreateResult = - createResponses.first().toTypedResponse(ProductCreateResult::class.java) - ) { - is TypedBatchResponse.Ok -> { - Assertions.assertTrue(productCreateResult.value.id > 0) - } - - is TypedBatchResponse.ApiError -> Assertions.fail("Api error is unexpected") - is TypedBatchResponse.ParseError -> Assertions.fail("Parse error is unexpected") - is TypedBatchResponse.NotExecuted -> Assertions.fail("Not executed error is not expected") - } - - val searchProductBatch = apiClient.createBatch( - CreateBatchRequestWithIds( - requests = mapOf( - "search_product" to productSearchRequest - ) - ) - ) - - // No way to predict when this query will be executed, let's simply wait - awaitBatchExecution(searchProductBatch.ticket) - - val searchProductBatchResult = apiClient.getTypedBatch( - GetEscapedBatchRequest( - ticket = searchProductBatch.ticket - ) - ) - - val searchResponses = searchProductBatchResult.responses - require(searchResponses != null) - when ( - val productsSearchResult = - searchResponses.first().toTypedResponse(ProductsSearchResult::class.java) - ) { - is TypedBatchResponse.Ok -> { - Assertions.assertTrue(productsSearchResult.value.count > 0) - } - - is TypedBatchResponse.ApiError -> Assertions.fail("Api error is unexpected") - is TypedBatchResponse.ParseError -> Assertions.fail("Parse error is unexpected") - is TypedBatchResponse.NotExecuted -> Assertions.fail("Not executed error is not expected") - } - } - - private fun awaitBatchExecution(ticket: String) { - var tries = 0 - - do { - val batchResult = apiClient.getTypedBatch(GetEscapedBatchRequest(ticket = ticket)) - if (batchResult.status == BatchStatus.COMPLETED) { - return - } - tries++ - Thread.sleep(500L * tries) - } while (tries < 10) - - return Assertions.fail("Failed to await for batch completion") - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/BrandsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/BrandsTest.kt deleted file mode 100644 index 5b740896e..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/BrandsTest.kt +++ /dev/null @@ -1,96 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.dto.brand.request.BrandsSearchRequest -import com.ecwid.apiclient.v3.dto.product.request.ProductCreateRequest -import com.ecwid.apiclient.v3.dto.product.request.ProductsSearchRequest.ByFilters -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct.* -import com.ecwid.apiclient.v3.util.randomAlphanumeric -import com.ecwid.apiclient.v3.util.randomPrice -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.BeforeEach -import kotlin.test.Test -import kotlin.test.assertEquals - -class BrandsTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - - initStoreProfile() - removeAllProducts() - } - - @Test - fun getBrands() { - val brandedProductsCreateResult = createProductsWithBrands() - - // Waiting till product became available for searching - brandedProductsCreateResult.skus.forEach { sku -> - waitForIndexedProducts( - productsSearchRequest = ByFilters(sku = sku), - desiredProductCount = 1 - ) - } - - val result = apiClient.searchBrands(BrandsSearchRequest.ByFilters()) - assertEquals( - brandedProductsCreateResult.brandNames, - result.items.map { it.name } - ) - } - - private fun createProductsWithBrands(productsCount: Int = 5): BrandedProductsCreateResult { - val brands = mutableListOf() - val skus = mutableListOf() - - for (i in 1..productsCount) { - val randomBrand = randomAlphanumeric(8) - val randomSku = randomAlphanumeric(10) - val price = randomPrice() - - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product $i ${randomAlphanumeric(8)}", - sku = randomSku, - price = price, - compareToPrice = 2 * price, - enabled = true, - quantity = 10, - attributes = listOf( - AttributeValue.createBrandAttributeValue(randomBrand), - ), - options = listOf( - ProductOption.createSelectOption( - name = "Color", - choices = listOf( - ProductOptionChoice("Black"), - ProductOptionChoice("White"), - ProductOptionChoice("Yellow"), - ProductOptionChoice("Red") - ), - defaultChoice = 0, - required = true - ) - ) - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - skus.add(randomSku) - brands.add(randomBrand) - } - - return BrandedProductsCreateResult( - brandNames = brands, - skus = skus, - ) - } - - data class BrandedProductsCreateResult( - val brandNames: List, - val skus: List, - ) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt deleted file mode 100644 index 63f772fca..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CartsTest.kt +++ /dev/null @@ -1,719 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.cart.request.* -import com.ecwid.apiclient.v3.dto.cart.result.CalculateOrderDetailsResult -import com.ecwid.apiclient.v3.dto.cart.result.CalculateOrderDetailsResult.DiscountInfo -import com.ecwid.apiclient.v3.dto.order.enums.* -import com.ecwid.apiclient.v3.dto.order.request.OrderCreateRequest -import com.ecwid.apiclient.v3.dto.order.request.OrderDetailsRequest -import com.ecwid.apiclient.v3.dto.order.request.UpdatedOrder -import com.ecwid.apiclient.v3.util.* -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertNotNull -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import java.util.* - -class CartsTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - } - - @Test - fun testCreateAndGetCart() { - // Creating new cart - val testOrder = generateTestOrder() - val newCartId = createNewCart(testOrder) - - // Checking that cart was successfully created with necessary parameters - val cartDetailsRequest = CartDetailsRequest(newCartId) - val cartDetailsResult = apiClient.getCartDetails(cartDetailsRequest) - - assertEquals(testOrder.ipAddress, cartDetailsResult.ipAddress) - assertEquals(testOrder.email, cartDetailsResult.email) - assertEquals(testOrder.hidden, cartDetailsResult.hidden) - assertEquals(testOrder.refererUrl, cartDetailsResult.refererUrl) - assertEquals(testOrder.globalReferer, cartDetailsResult.globalReferer) - assertEquals(testOrder.affiliateId, cartDetailsResult.affiliateId) - assertEquals(testOrder.additionalInfo, cartDetailsResult.additionalInfo) - assertEquals(testOrder.orderComments, cartDetailsResult.orderComments) - assertEquals(testOrder.trackingNumber, cartDetailsResult.trackingNumber) - assertEquals(testOrder.paymentMethod, cartDetailsResult.paymentMethod) - assertEquals(testOrder.paymentModule, cartDetailsResult.paymentModule) - assertEquals(testOrder.paymentParams, cartDetailsResult.paymentParams) - assertEquals(testOrder.paymentParams, cartDetailsResult.paymentParams) - assertEquals(testOrder.paymentMessage, cartDetailsResult.paymentMessage) - assertEquals(testOrder.creditCardStatus?.avsMessage, cartDetailsResult.creditCardStatus?.avsMessage) - assertEquals(testOrder.creditCardStatus?.cvvMessage, cartDetailsResult.creditCardStatus?.cvvMessage) - assertEquals(testOrder.externalTransactionId, cartDetailsResult.externalTransactionId) - assertEquals(testOrder.customerGroup, cartDetailsResult.customerGroup) - assertEquals(testOrder.total, cartDetailsResult.total) - assertEquals(testOrder.subtotal, cartDetailsResult.subtotal) - assertEquals(testOrder.tax, cartDetailsResult.tax) - assertEquals(testOrder.customerTaxExempt, cartDetailsResult.customerTaxExempt) - assertEquals(testOrder.customerTaxId, cartDetailsResult.customerTaxId) - assertEquals(testOrder.customerTaxIdValid, cartDetailsResult.customerTaxIdValid) - assertEquals(testOrder.reversedTaxApplied, cartDetailsResult.reversedTaxApplied) - assertEquals(testOrder.couponDiscount, cartDetailsResult.couponDiscount) - assertEquals(testOrder.volumeDiscount, cartDetailsResult.volumeDiscount) - assertEquals(testOrder.membershipBasedDiscount, cartDetailsResult.membershipBasedDiscount) - assertEquals(testOrder.totalAndMembershipBasedDiscount, cartDetailsResult.totalAndMembershipBasedDiscount) - assertEquals(testOrder.discount, cartDetailsResult.discount) - assertEquals(testOrder.discountCoupon, cartDetailsResult.discountCoupon) - - assertEquals(testOrder.discountInfo?.count(), cartDetailsResult.discountInfo?.count()) - cartDetailsResult.discountInfo?.forEachIndexed { discountInfoIndex, cartDiscountInfo -> - val orderDiscountInfo = testOrder.discountInfo?.get(discountInfoIndex) - requireNotNull(orderDiscountInfo) { "testOrder.discountInfo[$discountInfoIndex] not found" } - - assertEquals(orderDiscountInfo.value, cartDiscountInfo.value) - assertEquals(orderDiscountInfo.type, cartDiscountInfo.type) - assertEquals(orderDiscountInfo.base, cartDiscountInfo.base) - assertEquals(orderDiscountInfo.orderTotal, cartDiscountInfo.orderTotal) - assertEquals(orderDiscountInfo.description, cartDiscountInfo.description) - } - - assertEquals(testOrder.items?.count(), cartDetailsResult.items?.count()) - cartDetailsResult.items?.forEachIndexed { itemIndex, cartItem -> - val orderItem = testOrder.items?.get(itemIndex) - requireNotNull(orderItem) { "testOrder.items[$itemIndex] not found" } - assertEquals(orderItem.categoryId, cartItem.categoryId) - assertEquals(orderItem.price, cartItem.price) - assertEquals(orderItem.productPrice, cartItem.productPrice) - assertEquals(orderItem.shipping, cartItem.shipping) - assertEquals(orderItem.tax, cartItem.tax) - assertEquals(orderItem.fixedShippingRate, cartItem.fixedShippingRate) - assertEquals(orderItem.couponAmount, cartItem.couponAmount) - assertEquals(orderItem.sku, cartItem.sku) - assertEquals(orderItem.name, cartItem.name) - assertEquals(orderItem.shortDescription, cartItem.shortDescription) - assertEquals(orderItem.quantity, cartItem.quantity) - assertEquals(orderItem.quantityInStock, cartItem.quantityInStock) - assertEquals(orderItem.weight, cartItem.weight) - assertEquals(orderItem.isShippingRequired, cartItem.isShippingRequired) - assertEquals(orderItem.trackQuantity, cartItem.trackQuantity) - assertEquals(orderItem.fixedShippingRateOnly, cartItem.fixedShippingRateOnly) - assertEquals(orderItem.digital, cartItem.digital) - assertEquals(orderItem.couponApplied, cartItem.couponApplied) - assertEquals(orderItem.giftCard, cartItem.giftCard) - - assertEquals(orderItem.dimensions?.length, cartItem.dimensions?.length) - assertEquals(orderItem.dimensions?.width, cartItem.dimensions?.width) - assertEquals(orderItem.dimensions?.height, cartItem.dimensions?.height) - - assertEquals(orderItem.selectedOptions?.count(), cartItem.selectedOptions?.count()) - cartItem.selectedOptions?.forEachIndexed { selectedOptionIndex, cartSelectedOptions -> - val orderSelectedOption = orderItem.selectedOptions?.get(selectedOptionIndex) - requireNotNull(orderSelectedOption) { "testOrder.items[$itemIndex].selectedOptions[$selectedOptionIndex] not found" } - assertEquals(orderSelectedOption.name, cartSelectedOptions.name) - assertEquals(orderSelectedOption.type, cartSelectedOptions.type) - // TODO Discover why after each create field `valuesArray` some times resets to null - } - assertEquals(orderItem.combinationId, cartItem.combinationId) - - assertEquals(orderItem.taxes?.count(), cartItem.taxes?.count()) - cartItem.taxes?.forEachIndexed { taxIndex, cartTaxes -> - val orderTaxes = orderItem.taxes?.get(taxIndex) - requireNotNull(orderTaxes) { "testOrder.items[$itemIndex].taxes[$taxIndex] not found" } - assertEquals(orderTaxes.name, cartTaxes.name) - assertEquals(orderTaxes.value, cartTaxes.value) - assertEquals(orderTaxes.total, cartTaxes.total) - assertEquals(orderTaxes.taxOnDiscountedSubtotal, cartTaxes.taxOnDiscountedSubtotal) - assertEquals(orderTaxes.taxOnShipping, cartTaxes.taxOnShipping) - assertEquals(orderTaxes.includeInPrice, cartTaxes.includeInPrice) - assertEquals(orderTaxes.taxType, cartTaxes.taxType) - } - - assertEquals(orderItem.discounts?.count(), cartItem.discounts?.count()) - cartItem.discounts?.forEachIndexed { discountIndex, cartDiscounts -> - val orderDiscounts = orderItem.discounts?.get(discountIndex) - requireNotNull(orderDiscounts) { "testOrder.items[$itemIndex].discounts[$discountIndex] not found" } - assertEquals(orderDiscounts.discountInfo?.value, cartDiscounts.discountInfo?.value) - assertEquals(orderDiscounts.discountInfo?.type, cartDiscounts.discountInfo?.type) - assertEquals(orderDiscounts.discountInfo?.base, cartDiscounts.discountInfo?.base) - assertEquals(orderDiscounts.discountInfo?.orderTotal, cartDiscounts.discountInfo?.orderTotal) - assertEquals(orderDiscounts.total, cartDiscounts.total) - } - } - - assertEquals(testOrder.billingPerson?.name, cartDetailsResult.billingPerson?.name) - assertEquals(testOrder.billingPerson?.companyName, cartDetailsResult.billingPerson?.companyName) - assertEquals(testOrder.billingPerson?.street, cartDetailsResult.billingPerson?.street) - assertEquals(testOrder.billingPerson?.city, cartDetailsResult.billingPerson?.city) - assertEquals(testOrder.billingPerson?.countryCode, cartDetailsResult.billingPerson?.countryCode) - assertEquals(testOrder.billingPerson?.postalCode, cartDetailsResult.billingPerson?.postalCode) - assertEquals(testOrder.billingPerson?.stateOrProvinceCode, cartDetailsResult.billingPerson?.stateOrProvinceCode) - assertEquals(testOrder.billingPerson?.phone, cartDetailsResult.billingPerson?.phone) - - assertEquals(testOrder.shippingPerson?.name, cartDetailsResult.shippingPerson?.name) - assertEquals(testOrder.shippingPerson?.companyName, cartDetailsResult.shippingPerson?.companyName) - assertEquals(testOrder.shippingPerson?.street, cartDetailsResult.shippingPerson?.street) - assertEquals(testOrder.shippingPerson?.city, cartDetailsResult.shippingPerson?.city) - assertEquals(testOrder.shippingPerson?.countryCode, cartDetailsResult.shippingPerson?.countryCode) - assertEquals(testOrder.shippingPerson?.postalCode, cartDetailsResult.shippingPerson?.postalCode) - assertEquals( - testOrder.shippingPerson?.stateOrProvinceCode, - cartDetailsResult.shippingPerson?.stateOrProvinceCode - ) - assertEquals(testOrder.shippingPerson?.phone, cartDetailsResult.shippingPerson?.phone) - - assertEquals( - testOrder.shippingOption?.shippingCarrierName, - cartDetailsResult.shippingOption?.shippingCarrierName - ) - assertEquals(testOrder.shippingOption?.shippingMethodId, cartDetailsResult.shippingOption?.shippingMethodId) - assertEquals(testOrder.shippingOption?.shippingMethodName, cartDetailsResult.shippingOption?.shippingMethodName) - assertEquals(testOrder.shippingOption?.shippingRate, cartDetailsResult.shippingOption?.shippingRate) - assertEquals( - testOrder.shippingOption?.estimatedTransitTime, - cartDetailsResult.shippingOption?.estimatedTransitTime - ) - assertEquals(testOrder.shippingOption?.isPickup, cartDetailsResult.shippingOption?.isPickup) - assertEquals(testOrder.shippingOption?.pickupInstruction, cartDetailsResult.shippingOption?.pickupInstruction) - - assertEquals(testOrder.handlingFee?.name, cartDetailsResult.handlingFee?.name) - assertEquals(testOrder.handlingFee?.value, cartDetailsResult.handlingFee?.value) - assertEquals(testOrder.handlingFee?.description, cartDetailsResult.handlingFee?.description) - } - - @Test - fun testUpdateCart() { - // Creating new cart - val newCartId = createNewCart(generateTestOrder()) - - // Updating cart - val cartUpdateRequest = CartUpdateRequest( - cartId = newCartId, - updatedCart = generateTestCartForUpdate() - ) - val cartUpdateResult = apiClient.updateCart(cartUpdateRequest) - assertEquals(1, cartUpdateResult.updateCount) - - // Checking that cart was successfully updated with necessary parameters - val cartDetailsRequest1 = CartDetailsRequest(newCartId) - val cartDetailsResult1 = apiClient.getCartDetails(cartDetailsRequest1) - assertEquals( - cartUpdateRequest.updatedCart, - cartDetailsResult1.toUpdated() - ) - } - - @Test - fun testConvertCartToOrder() { - // Creating new cart - val testOrder = generateTestOrder() - val newCartId = createNewCart(testOrder) - - // Converting cart to order - val convertCartToOrderRequest = ConvertCartToOrderRequest(newCartId) - val convertCartToOrderResult = apiClient.convertCartToOrder(convertCartToOrderRequest) - - // Checking that cart was converted to order - assertNotNull(convertCartToOrderResult.orderNumber) - assertNotNull(convertCartToOrderResult.vendorOrderNumber) - - // Checking that order was created with necessary parameters - val orderDetailsRequest = OrderDetailsRequest(convertCartToOrderResult.orderNumber!!) - val createdOrder = apiClient.getOrderDetails(orderDetailsRequest).toUpdated() - - val testOrderCopy = testOrder.copy( - createDate = createdOrder.createDate, - paymentStatus = OrderPaymentStatus.AWAITING_PAYMENT, - paymentMessage = null, // TODO Discover why after each create this field resets to null - items = testOrder.items?.mapIndexed { itemIndex, item -> - val createdOrderItem = createdOrder.items?.get(itemIndex) - val selectedOptions2 = item.selectedOptions?.mapIndexed { selectedOptionIndex, selectedOption -> - // TODO Discover why after create these two fields some times resets to null - val createdOptionSelectedOption = - createdOrderItem?.selectedOptions?.get(selectedOptionIndex) - selectedOption.copy( - valuesArray = createdOptionSelectedOption?.valuesArray, - selections = createdOptionSelectedOption?.selections - ) - } - item.copy( - id = createdOrderItem?.id, - selectedOptions = selectedOptions2 - ) - } - ) - - assertEquals( - testOrderCopy, - createdOrder.cleanupForComparison(testOrderCopy) - ) - } - - @Test - fun testCalculateOrderDetails() { - // Calculate order details - val orderForCalculate = generateTestOrderForCalculate() - val calculateOrderDetailsRequest = CalculateOrderDetailsRequest(orderForCalculate) - val calculatedOrder = apiClient.calculateOrderDetails(calculateOrderDetailsRequest) - - // Check that all parameters of the calculated order are correct - assertEquals(orderForCalculate.email, calculatedOrder.email) - assertEquals(orderForCalculate.ipAddress, calculatedOrder.ipAddress) - assertEquals(orderForCalculate.customerId, calculatedOrder.customerId) - - calculateOrderDetailsRequest.orderForCalculate.discountCoupon - - val resultDiscountCoupon = calculatedOrder.discountCoupon - val requestDiscountCoupon = orderForCalculate.discountCoupon - requireNotNull(requestDiscountCoupon) - requireNotNull(resultDiscountCoupon) - assertEquals(requestDiscountCoupon.name, resultDiscountCoupon.name) - assertEquals(requestDiscountCoupon.code, resultDiscountCoupon.code) - assertEquals(requestDiscountCoupon.discountType, resultDiscountCoupon.discountType) - assertEquals(requestDiscountCoupon.status, resultDiscountCoupon.status) - assertEquals(requestDiscountCoupon.discount, resultDiscountCoupon.discount) - assertEquals(requestDiscountCoupon.launchDate, resultDiscountCoupon.launchDate) - assertEquals(requestDiscountCoupon.expirationDate, resultDiscountCoupon.expirationDate) - assertEquals(requestDiscountCoupon.totalLimit, resultDiscountCoupon.totalLimit) - assertEquals(requestDiscountCoupon.usesLimit, resultDiscountCoupon.usesLimit) - assertEquals(requestDiscountCoupon.applicationLimit, resultDiscountCoupon.applicationLimit) - assertNotNull(resultDiscountCoupon.creationDate) - assertEquals(requestDiscountCoupon.name, resultDiscountCoupon.name) - assertEquals(0, resultDiscountCoupon.orderCount) - requireNotNull(resultDiscountCoupon.catalogLimit) - assertEquals(requestDiscountCoupon.catalogLimit?.products, resultDiscountCoupon.catalogLimit?.products) - assertEquals(requestDiscountCoupon.catalogLimit?.categories, resultDiscountCoupon.catalogLimit?.categories) - - assertEquals(orderForCalculate.items?.count(), calculatedOrder.items?.count()) - calculatedOrder.items?.forEachIndexed { itemIndex, calculatedItem -> - val forCalculateItem = orderForCalculate.items?.get(itemIndex) - requireNotNull(forCalculateItem) { "orderForCalculate.items[$itemIndex] not found" } - - assertEquals(forCalculateItem.id, calculatedItem.id) - assertEquals(forCalculateItem.categoryId, calculatedItem.categoryId) - assertEquals(forCalculateItem.price, calculatedItem.price) - assertEquals(forCalculateItem.productPrice, calculatedItem.productPrice) - assertEquals(0.0, calculatedItem.shipping) - assertEquals(forCalculateItem.fixedShippingRate, calculatedItem.fixedShippingRate) - assertEquals( - null, - calculatedItem.couponAmount - ) // TODO Discover why after each calculation this field resets to null - assertEquals(forCalculateItem.sku, calculatedItem.sku) - assertEquals(forCalculateItem.name, calculatedItem.name) - assertEquals(forCalculateItem.shortDescription, calculatedItem.shortDescription) - assertEquals(forCalculateItem.quantity, calculatedItem.quantity) - assertEquals(forCalculateItem.quantityInStock, calculatedItem.quantityInStock) - assertEquals(forCalculateItem.weight, calculatedItem.weight) - assertEquals(forCalculateItem.isShippingRequired, calculatedItem.isShippingRequired) - assertEquals(forCalculateItem.trackQuantity, calculatedItem.trackQuantity) - assertEquals(forCalculateItem.fixedShippingRateOnly, calculatedItem.fixedShippingRateOnly) - assertEquals(forCalculateItem.digital, calculatedItem.digital) - assertEquals(false, calculatedItem.couponApplied) - assertEquals(false, calculatedItem.giftCard) - - assertEquals(forCalculateItem.selectedOptions?.count(), calculatedItem.selectedOptions?.count()) - calculatedItem.selectedOptions?.forEachIndexed { selectedOptionIndex, calculatedOrderItemOptions -> - val forCalculateItemOption = forCalculateItem.selectedOptions?.get(selectedOptionIndex) - requireNotNull(forCalculateItemOption) { - "orderForCalculate.items[$itemIndex].selectedOptions[$selectedOptionIndex] not found" - } - - assertEquals(forCalculateItemOption.name, calculatedOrderItemOptions.name) - assertEquals(forCalculateItemOption.type, calculatedOrderItemOptions.type) - // TODO Discover why after each calculation field `valuesArray` some times resets to null - assertEquals( - null, - calculatedOrderItemOptions.files?.count() - ) // TODO Discover why after each calculation this field resets to null - } - assertEquals(forCalculateItem.combinationId, calculatedItem.combinationId) - - assertEquals(forCalculateItem.files?.count(), calculatedItem.files?.count()) - calculatedItem.files?.forEachIndexed { taxIndex, calculatedFile -> - val forCalculateFile = calculatedItem.files?.get(taxIndex) - requireNotNull(forCalculateFile) { "orderForCalculate.items[$itemIndex].taxes[$taxIndex] not found" } - - assertEquals(forCalculateFile.productFileId, calculatedFile.productFileId) - assertEquals(forCalculateFile.maxDownloads, calculatedFile.maxDownloads) - assertEquals(forCalculateFile.remainingDownloads, calculatedFile.remainingDownloads) - assertEquals(forCalculateFile.expire, calculatedFile.expire) - assertEquals(forCalculateFile.name, calculatedFile.name) - assertEquals(forCalculateFile.description, calculatedFile.description) - assertEquals(forCalculateFile.size, calculatedFile.size) - assertEquals(forCalculateFile.adminUrl, calculatedFile.adminUrl) - assertEquals(forCalculateFile.customerUrl, calculatedFile.customerUrl) - } - - assertEquals( - null, - calculatedItem.discounts?.count() - ) // TODO Discover why after each calculation this field resets to null - } - - checkPersonsEquals(orderForCalculate.billingPerson, calculatedOrder.billingPerson) - checkPersonsEquals(orderForCalculate.shippingPerson, calculatedOrder.shippingPerson) - assertEquals( - emptyList(), - calculatedOrder.discountInfo - ) // TODO Discover why after each calculation this field resets to null - } - - @Test - @Disabled("Will be fixed in ECWID-75364") - fun testSearchCarts() { - // Create two carts - val totalPrice = randomPrice() - val cartForSearch1 = generateCartForTestingSearch(totalPrice, false) - val newCartId1 = createNewCart(cartForSearch1) - val cartDetailsRequest1 = CartDetailsRequest(newCartId1) - val fetchedCart1 = apiClient.getCartDetails(cartDetailsRequest1) - - val cartForSearch2 = generateCartForTestingSearch(totalPrice, true) - createNewCart(cartForSearch2) - - val cartsSearchRequest1 = CartsSearchRequest( - totalFrom = totalPrice - 1, - totalTo = totalPrice + 1, - showHidden = false - ) - val cartsSearchResult1 = apiClient.searchCarts(cartsSearchRequest1) - assertEquals(1, cartsSearchResult1.count) - - val cartsSearchRequest2 = CartsSearchRequest( - totalFrom = totalPrice - 1, - totalTo = totalPrice + 1, - showHidden = true - ) - val cartsSearchResult2 = apiClient.searchCarts(cartsSearchRequest2) - assertEquals(2, cartsSearchResult2.count) - - val createDate = fetchedCart1.createDate - requireNotNull(createDate) { "fetchedCart.createDate not found" } - val instantCreate = createDate.toInstant() - val instantCreateFrom = instantCreate.minusSeconds(1) - val instantCreateTo = instantCreate.plusSeconds(2) - val cartsSearchRequest3 = CartsSearchRequest( - createdFrom = Date.from(instantCreateFrom), - createdTo = Date.from(instantCreateTo) - ) - val cartsSearchResult3 = apiClient.searchCarts(cartsSearchRequest3) - assertEquals(1, cartsSearchResult3.count) - - val updateDate = fetchedCart1.updateDate - requireNotNull(updateDate) { "fetchedCart.updateDate not found" } - val instantUpdate = updateDate.toInstant() - val instantUpdateFrom = instantUpdate.minusSeconds(1) - val instantUpdateTo = instantUpdate.plusSeconds(2) - val cartsSearchRequest4 = CartsSearchRequest( - updatedFrom = Date.from(instantUpdateFrom), - updatedTo = Date.from(instantUpdateTo) - ) - val cartsSearchResult4 = apiClient.searchCarts(cartsSearchRequest4) - assertEquals(1, cartsSearchResult4.count) - } - - private fun createNewCart(updatedOrder: UpdatedOrder): String { - val cartsSearchRequest = CartsSearchRequest() - val cartsSearchResult1 = apiClient.searchCartsAsSequence(cartsSearchRequest) - val orderCreateRequest = OrderCreateRequest( - newOrder = updatedOrder.copy( - paymentStatus = OrderPaymentStatus.INCOMPLETE - ) - ) - - apiClient.createOrder(orderCreateRequest) - - return processDelay(1500L, 10) { - val cartsSearchResult2 = apiClient.searchCartsAsSequence(cartsSearchRequest) - val newCartList = cartsSearchResult2 - cartsSearchResult1 - if (newCartList.count() == 1) newCartList[0].cartId else null - } - } - - private fun checkPersonsEquals( - billingPerson1: OrderForCalculate.PersonInfo?, - billingPerson2: CalculateOrderDetailsResult.PersonInfo? - ) { - assertEquals(billingPerson1?.name, billingPerson2?.name) - assertEquals(billingPerson1?.companyName, billingPerson2?.companyName) - assertEquals(billingPerson1?.street, billingPerson2?.street) - assertEquals(billingPerson1?.city, billingPerson2?.city) - assertEquals(billingPerson1?.countryCode, billingPerson2?.countryCode) - assertEquals(billingPerson1?.countryName, billingPerson2?.countryName) - assertEquals(billingPerson1?.postalCode, billingPerson2?.postalCode) - assertEquals(billingPerson1?.stateOrProvinceCode, billingPerson2?.stateOrProvinceCode) - assertEquals(billingPerson1?.stateOrProvinceName, billingPerson2?.stateOrProvinceName) - assertEquals(billingPerson1?.phone, billingPerson2?.phone) - } - - private fun generateTestCartForUpdate(): UpdatedCart { - return UpdatedCart( - hidden = randomBoolean(), - taxesOnShipping = listOf() - ) - } - - private fun generateTestOrderForCalculate(): OrderForCalculate { - return OrderForCalculate( - email = randomEmail(), - ipAddress = randomIp(), - customerId = randomId(), - discountCoupon = generateTestDiscountCoupon(), - items = listOf(generateTestItem()), - billingPerson = generatePersonInfo(), - shippingPerson = generatePersonInfo(), - discountInfo = listOf( - generateTestDiscountInfo(), - generateTestDiscountInfo() - ) - ) - } - - private fun generateTestItem(): OrderForCalculate.OrderItem { - return OrderForCalculate.OrderItem( - id = randomId(), - productId = randomId(), - categoryId = randomId(), - price = 22.2, - productPrice = 33.3, - shipping = 44.4, - tax = 55.5, - fixedShippingRate = 66.6, - couponAmount = 15.0, - sku = randomAlphanumeric(16), - name = "Order item " + randomAlphanumeric(8), - shortDescription = "Order item description " + randomAlphanumeric(32), - quantity = 2, - quantityInStock = 10, - weight = 3.0, - imageUrl = randomUrl(), - isShippingRequired = true, // true for weight field - trackQuantity = true, - fixedShippingRateOnly = true, - digital = true, - couponApplied = true, - giftCard = false, - selectedOptions = listOf( - generateChoiceSelectedOption(), - generateChoicesSelectedOption(), - generateTextSelectedOption(), - generateDateSelectedOption(), - generateFilesSelectedOption() - ), - combinationId = randomId(), - taxes = listOf( - generateTestOrderItemTax() - ), - dimensions = OrderForCalculate.ProductDimensions( - length = 12.0, - width = 5.2, - height = 6.6 - ), - discounts = listOf( - generateOrderItemDiscounts() - ) - ) - } - - private fun generateChoiceSelectedOption(): OrderForCalculate.OrderItemOption { - return OrderForCalculate.OrderItemOption.createForChoiceOption( - name = "Choice Option " + randomAlphanumeric(8), - selection = "Selection #1, " + randomAlphanumeric(8), - files = listOf( - OrderForCalculate.OrderItemOptionFile( - id = randomId(), - name = "Order item option file" + randomAlphanumeric(4), - size = randomInt(1, 10), - url = randomUrl() - ) - ) - ) - } - - private fun generateChoicesSelectedOption(): OrderForCalculate.OrderItemOption { - val value1 = "Selection #1, " + randomAlphanumeric(8) - val value3 = "Selection #3, " + randomAlphanumeric(8) - return OrderForCalculate.OrderItemOption.createForChoicesOption( - name = "Choices Option " + randomAlphanumeric(8), - selections = listOf( - OrderForCalculate.SelectionInfo( - selectionTitle = value1, - selectionModifier = 10.0, - selectionModifierType = PriceModifierType.ABSOLUTE - ), - OrderForCalculate.SelectionInfo( - selectionTitle = value3, - selectionModifier = 5.5, - selectionModifierType = PriceModifierType.ABSOLUTE - ) - ), - files = listOf( - OrderForCalculate.OrderItemOptionFile( - id = randomId(), - name = "Order item option file" + randomAlphanumeric(4), - size = randomInt(1, 10), - url = randomUrl() - ) - ) - ) - } - - private fun generateTextSelectedOption(): OrderForCalculate.OrderItemOption { - return OrderForCalculate.OrderItemOption.createForTextOption( - name = "Text Option " + randomAlphanumeric(8), - value = randomAlphanumeric(8) - ) - } - - private fun generateDateSelectedOption(): OrderForCalculate.OrderItemOption { - return OrderForCalculate.OrderItemOption.createForDateOption( - name = "Date Option " + randomAlphanumeric(8), - date = randomDate() - ) - } - - private fun generateFilesSelectedOption(): OrderForCalculate.OrderItemOption { - return OrderForCalculate.OrderItemOption.createForFilesOption(name = "Files Option " + randomAlphanumeric(8)) - } - - private fun generateTestOrderItemTax(): OrderForCalculate.OrderItemTax { - return OrderForCalculate.OrderItemTax( - name = "Tax " + randomAlphanumeric(8), - value = 12.2, - total = 22.6, - taxOnDiscountedSubtotal = 4.4, - taxOnShipping = 3.3, - includeInPrice = true, - taxType = OrderItemTaxType.STATE - ) - } - - private fun generatePersonInfo(): OrderForCalculate.PersonInfo { - return OrderForCalculate.PersonInfo( - name = "Name " + randomAlphanumeric(8), - companyName = "Company " + randomAlphanumeric(8), - street = "Line 1 " + randomAlphanumeric(8) + "\nLine 2 " + randomAlphanumeric(8), - city = "City " + randomAlphanumeric(8), - countryCode = "US", - countryName = "United States", - postalCode = randomAlphanumeric(5), - stateOrProvinceCode = "CA", - stateOrProvinceName = "California", - phone = randomAlphanumeric(10) - ) - } - - private fun generateOrderItemDiscounts(): OrderForCalculate.OrderItemDiscounts { - return OrderForCalculate.OrderItemDiscounts( - discountInfo = generateTestCustomDiscountInfo(), - total = 12.5 - ) - } - - private fun generateTestDiscountCoupon(): OrderForCalculate.DiscountCouponInfo { - val creationDate = randomDateFrom(Date()) - val launchDate = randomDateFrom(creationDate) - val expirationDate = randomDateFrom(launchDate) - return OrderForCalculate.DiscountCouponInfo( - name = "Discount Coupon " + randomAlphanumeric(8), - code = randomAlphanumeric(16), - discountType = DiscountCouponType.ABS_AND_SHIPPING, - status = DiscountCouponStatus.ACTIVE, - discount = 50.0, - launchDate = launchDate, - expirationDate = expirationDate, - totalLimit = 5555.5, - usesLimit = DiscountCouponUsesLimit.UNLIMITED, - applicationLimit = DiscountCouponApplicationLimit.UNLIMITED, - creationDate = creationDate, - orderCount = 1, - catalogLimit = generateTestDiscountCouponCatalogLimit() - ) - } - - private fun generateTestCustomDiscountInfo() = OrderForCalculate.OrderItemDiscountInfo( - value = 22.2, - type = DiscountType.ABS, - base = DiscountBase.CUSTOM, - orderTotal = 33.3 - ) - - private fun generateTestDiscountInfo() = OrderForCalculate.DiscountInfo( - value = 55.3, - type = DiscountType.ABS, - base = DiscountBase.ON_TOTAL, - orderTotal = 66.6, - description = "On total discount " + randomAlphanumeric(8) - ) - - private fun generateTestDiscountCouponCatalogLimit(): OrderForCalculate.DiscountCouponCatalogLimit { - return OrderForCalculate.DiscountCouponCatalogLimit( - products = listOf(1, 2, 3), - categories = listOf(1) - ) - } - - private fun generateCartForTestingSearch(price: Double, hidden: Boolean): UpdatedOrder { - return UpdatedOrder( - paymentStatus = OrderPaymentStatus.INCOMPLETE, - fulfillmentStatus = OrderFulfillmentStatus.PROCESSING, - items = generateItemsForTestingSearch(), - discountCoupon = UpdatedOrder.DiscountCouponInfo( - name = "testCoupon", - code = "123abc555" - ), - // customerId = TODO Discover why this field not specified when creating an order - hidden = hidden, - total = price - ) - } - - private fun generateItemsForTestingSearch(): List { - return listOf( - UpdatedOrder.OrderItem( - name = "AAA", - price = 200.0 - ), - UpdatedOrder.OrderItem( - name = "BBB", - price = 300.0 - ) - ) - } -} - -private fun UpdatedOrder.cleanupForComparison(order: UpdatedOrder): UpdatedOrder { - return copy( - pickupTime = order.pickupTime, - customerId = order.customerId, - items = this.items?.mapIndexed { index, item -> - item.copy( - nameTranslated = order.items?.get(index)?.nameTranslated, - shortDescriptionTranslated = order.items?.get(index)?.shortDescriptionTranslated, - selectedPrice = order.items?.get(index)?.selectedPrice, - selectedOptions = this.items?.get(index)?.selectedOptions?.mapIndexed { optIndex, option -> - option.copy( - valueTranslated = order.items?.get(index)?.selectedOptions?.get(optIndex)?.valueTranslated - ) - }, - discounts = order.items?.get(index)?.discounts?.mapIndexed { discountIndex, discount -> - discount.copy( - discountInfo = order.items?.get(index)?.discounts?.get(discountIndex)?.discountInfo?.copy( - appliesToItems = null - ) - ) - } - ) - }, - customerFiscalCode = null, // ApiOrder has empty string instead of null - electronicInvoicePecEmail = null, - electronicInvoiceSdiCode = null, - commercialRelationshipScheme = null, - discountInfo = order.discountInfo?.map { - it.copy( - appliesToItems = null - ) - }, - lang = order.lang - ) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt deleted file mode 100644 index d69adeac2..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CategoriesTest.kt +++ /dev/null @@ -1,726 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.category.request.* -import com.ecwid.apiclient.v3.dto.category.request.CategoriesSearchRequest.ParentCategory -import com.ecwid.apiclient.v3.dto.category.result.CategoriesSearchResult -import com.ecwid.apiclient.v3.dto.category.result.FetchedCategory -import com.ecwid.apiclient.v3.dto.common.AsyncPictureData -import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap -import com.ecwid.apiclient.v3.dto.common.UploadFileData -import com.ecwid.apiclient.v3.dto.product.request.ProductCreateRequest -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct -import com.ecwid.apiclient.v3.exception.EcwidApiException -import com.ecwid.apiclient.v3.util.randomAlphanumeric -import com.ecwid.apiclient.v3.util.randomBoolean -import org.junit.jupiter.api.* -import org.junit.jupiter.api.Assertions.* -import java.io.FileInputStream -import java.nio.file.Files - -class CategoriesTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - - // We need to start from scratch each time - initStoreProfile() - removeAllCategories() - removeAllProducts() - } - - @Test - fun testSearchByFilters() { - // Creating some products to put into new categories - - val productCreateRequest1 = ProductCreateRequest( - newProduct = generateTestProduct(nameSuffix = "testSearchByFilters", enabled = true) - ) - val productCreateResult1 = apiClient.createProduct(productCreateRequest1) - assertTrue(productCreateResult1.id > 0) - - val productCreateRequest2 = ProductCreateRequest( - newProduct = generateTestProduct(nameSuffix = "testSearchByFilters", enabled = false) - ) - val productCreateResult2 = apiClient.createProduct(productCreateRequest2) - assertTrue(productCreateResult2.id > 0) - - val productCreateRequest3 = ProductCreateRequest( - newProduct = generateTestProduct(nameSuffix = "testSearchByFilters", enabled = true) - ) - val productCreateResult3 = apiClient.createProduct(productCreateRequest3) - assertTrue(productCreateResult3.id > 0) - - // Creating some categories - val requestTrunkA = CategoryCreateRequest( - newCategory = generateTestCategory(enabled = true) - ) - val trunkA = apiClient.createCategory(requestTrunkA) - assertTrue(trunkA.id > 0) - - val requestBranchAA = CategoryCreateRequest( - newCategory = generateTestCategory( - parentCategoryId = trunkA.id, - enabled = true - ) - ) - val branchAA = apiClient.createCategory(requestBranchAA) - assertTrue(branchAA.id > 0) - - val requestTrunkB = CategoryCreateRequest( - newCategory = generateTestCategory(enabled = false) - ) - val trunkB = apiClient.createCategory(requestTrunkB) - assertTrue(trunkB.id > 0) - - val requestBranchBA = CategoryCreateRequest( - newCategory = generateTestCategory( - parentCategoryId = trunkB.id, - productIds = listOf(productCreateResult1.id, productCreateResult2.id), - enabled = false - ) - ) - val branchBA = apiClient.createCategory(requestBranchBA) - assertTrue(branchBA.id > 0) - - val requestLeafBAA = CategoryCreateRequest( - newCategory = generateTestCategory( - parentCategoryId = branchBA.id, - productIds = listOf(productCreateResult3.id), - enabled = false - ) - ) - val leafBAA = apiClient.createCategory(requestLeafBAA) - assertTrue(leafBAA.id > 0) - - // Trying to search by different filters - val searchDescendantsOfTrunkB = waitForIndexedCategories( - categoriesSearchRequest = CategoriesSearchRequest( - parentCategoryId = ParentCategory.WithId(trunkB.id), - hiddenCategories = true - ), - desiredCategoriesCount = 1 - ) - assertEquals(1, searchDescendantsOfTrunkB.total) - assertCategory( - desiredId = branchBA.id, - desiredProductIds = null, - categoriesSearchResult = searchDescendantsOfTrunkB - ) - - val searchRootCategories = waitForIndexedCategories( - categoriesSearchRequest = CategoriesSearchRequest( - parentCategoryId = ParentCategory.Root, - hiddenCategories = true - ), - desiredCategoriesCount = 2 - ) - assertEquals(2, searchRootCategories.total) - assertCategory( - desiredId = trunkA.id, - desiredProductIds = null, - categoriesSearchResult = searchRootCategories - ) - assertCategory( - desiredId = trunkB.id, - desiredProductIds = null, - categoriesSearchResult = searchRootCategories - ) - - val searchAllCategoriesWithProducts = waitForIndexedCategories( - categoriesSearchRequest = CategoriesSearchRequest( - parentCategoryId = ParentCategory.Any, - hiddenCategories = true, - returnProductIds = true - ), - desiredCategoriesCount = 5 - ) - assertEquals(5, searchAllCategoriesWithProducts.total) - assertCategory( - desiredId = trunkA.id, - desiredProductIds = null, - categoriesSearchResult = searchAllCategoriesWithProducts - ) - assertCategory( - desiredId = branchAA.id, - desiredProductIds = null, - categoriesSearchResult = searchAllCategoriesWithProducts - ) - assertCategory( - desiredId = trunkB.id, - desiredProductIds = null, - categoriesSearchResult = searchAllCategoriesWithProducts - ) - assertCategory( - desiredId = branchBA.id, - desiredProductIds = listOf(productCreateResult1.id, productCreateResult2.id), - categoriesSearchResult = searchAllCategoriesWithProducts - ) - assertCategory( - desiredId = leafBAA.id, - desiredProductIds = listOf(productCreateResult3.id), - categoriesSearchResult = searchAllCategoriesWithProducts - ) - - val searchAllCategories = waitForIndexedCategories( - categoriesSearchRequest = CategoriesSearchRequest( - parentCategoryId = ParentCategory.Any, - hiddenCategories = true - ), - desiredCategoriesCount = 5 - ) - assertEquals(5, searchAllCategoriesWithProducts.total) - assertCategory( - desiredId = trunkA.id, - desiredProductIds = null, - categoriesSearchResult = searchAllCategories - ) - assertCategory( - desiredId = branchAA.id, - desiredProductIds = null, - categoriesSearchResult = searchAllCategories - ) - assertCategory( - desiredId = trunkB.id, - desiredProductIds = null, - categoriesSearchResult = searchAllCategories - ) - assertCategory( - desiredId = branchBA.id, - desiredProductIds = null, - categoriesSearchResult = searchAllCategories - ) - assertCategory( - desiredId = leafBAA.id, - desiredProductIds = null, - categoriesSearchResult = searchAllCategories - ) - - val searchActiveCategories = waitForIndexedCategories( - categoriesSearchRequest = CategoriesSearchRequest( - parentCategoryId = ParentCategory.Any, - hiddenCategories = false - ), - desiredCategoriesCount = 2 - ) - assertEquals(2, searchActiveCategories.total) - assertCategory( - desiredId = trunkA.id, - desiredProductIds = null, - categoriesSearchResult = searchActiveCategories - ) - assertCategory( - desiredId = branchAA.id, - desiredProductIds = null, - categoriesSearchResult = searchActiveCategories - ) - - val searchDirectDescendantsOfTrunkB = waitForIndexedCategories( - categoriesSearchRequest = CategoriesSearchRequest( - parentCategoryIds = listOf(trunkB.id.toLong()), - withSubcategories = false, - hiddenCategories = true, - ), - desiredCategoriesCount = 1 - ) - assertEquals(1, searchDirectDescendantsOfTrunkB.total) - assertCategory( - desiredId = branchBA.id, - desiredProductIds = null, - categoriesSearchResult = searchDirectDescendantsOfTrunkB - ) - - val searchAllDescendantsOfTrunkB = waitForIndexedCategories( - categoriesSearchRequest = CategoriesSearchRequest( - parentCategoryIds = listOf(trunkB.id.toLong()), - withSubcategories = true, - hiddenCategories = true, - ), - desiredCategoriesCount = 2 - ) - assertEquals(2, searchAllDescendantsOfTrunkB.total) - assertCategory( - desiredId = branchBA.id, - desiredProductIds = null, - categoriesSearchResult = searchAllDescendantsOfTrunkB - ) - assertCategory( - desiredId = leafBAA.id, - desiredProductIds = null, - categoriesSearchResult = searchAllDescendantsOfTrunkB - ) - - val searchDescendantsViaTwoFields = waitForIndexedCategories( - categoriesSearchRequest = CategoriesSearchRequest( - parentCategoryId = ParentCategory.WithId(trunkA.id), - parentCategoryIds = listOf(trunkB.id.toLong()), - withSubcategories = true, - hiddenCategories = true, - ), - desiredCategoriesCount = 3 - ) - assertEquals(3, searchDescendantsViaTwoFields.total) - assertCategory( - desiredId = branchAA.id, - desiredProductIds = null, - categoriesSearchResult = searchDescendantsViaTwoFields - ) - assertCategory( - desiredId = branchBA.id, - desiredProductIds = null, - categoriesSearchResult = searchDescendantsViaTwoFields - ) - assertCategory( - desiredId = leafBAA.id, - desiredProductIds = null, - categoriesSearchResult = searchDescendantsViaTwoFields - ) - } - - @Test - fun testSearchUrls() { - // Create one category - val categoryCreateRequest = CategoryCreateRequest( - newCategory = generateTestCategory(enabled = true) - ) - val categoryCreateResult = apiClient.createCategory(categoryCreateRequest) - assertTrue(categoryCreateResult.id > 0) - - // Searching categories with different combinations of baseUrl and cleanUrls parameters - assertCategoryUrlMatchesRegex( - categorySearchRequest = CategoriesSearchRequest(), - urlPattern = "https://.*.company.site.*/products/Category-.*c.*" - ) - assertCategoryUrlMatchesRegex( - categorySearchRequest = CategoriesSearchRequest( - cleanUrls = true - ), - urlPattern = "https://.*.company.site.*/Category-.*-c.*" - ) - assertCategoryUrlMatchesRegex( - categorySearchRequest = CategoriesSearchRequest( - cleanUrls = false - ), - urlPattern = "https://.*.company.site.*/products#!/Category-.*/c/.*" - ) - assertCategoryUrlMatchesRegex( - categorySearchRequest = CategoriesSearchRequest( - baseUrl = "https://google.com/" - ), - urlPattern = "https://google.com/#!/Category-.*/c/.*" - ) - assertCategoryUrlMatchesRegex( - categorySearchRequest = CategoriesSearchRequest( - baseUrl = "https://google.com/", - cleanUrls = true - ), - urlPattern = "https://google.com/Category-.*-c.*" - ) - assertCategoryUrlMatchesRegex( - categorySearchRequest = CategoriesSearchRequest( - baseUrl = "https://google.com/", - cleanUrls = false - ), - urlPattern = "https://google.com/#!/Category-.*/c/.*" - ) - } - - @Test - fun testSearchPaging() { - // Create some categories - repeat(3) { - val categoryCreateRequest = CategoryCreateRequest( - newCategory = generateTestCategory(enabled = true) - ) - val categoryCreateResult = apiClient.createCategory(categoryCreateRequest) - assertTrue(categoryCreateResult.id > 0) - } - - val categorySearchRequest = CategoriesSearchRequest(offset = 2, limit = 2) - val categoriesSearchResult = apiClient.searchCategories(categorySearchRequest) - assertEquals(1, categoriesSearchResult.count) - assertEquals(3, categoriesSearchResult.total) - } - - @Test - @Disabled("Will be fixed in ECWID-75364") - fun testCategoryLifecycle() { - val nameSuffix = "testCategoryLifecycle" - - // Creating some products to put into new categories - - val productCreateRequest1 = ProductCreateRequest( - newProduct = generateTestProduct(nameSuffix = nameSuffix) - ) - val productCreateResult1 = apiClient.createProduct(productCreateRequest1) - assertTrue(productCreateResult1.id > 0) - - val productCreateRequest2 = ProductCreateRequest( - newProduct = generateTestProduct(nameSuffix = nameSuffix) - ) - val productCreateResult2 = apiClient.createProduct(productCreateRequest2) - assertTrue(productCreateResult2.id > 0) - - // Creating two categories in hierarchy - - val categoryCreateRequest1 = CategoryCreateRequest( - newCategory = generateTestCategory() - ) - val categoryCreateResult1 = apiClient.createCategory(categoryCreateRequest1) - assertTrue(categoryCreateResult1.id > 0) - - val categoryCreateRequest2 = CategoryCreateRequest( - newCategory = generateTestCategory( - parentCategoryId = categoryCreateResult1.id, - productIds = listOf(productCreateResult1.id, productCreateResult2.id) - ) - ) - val categoryCreateResult2 = apiClient.createCategory(categoryCreateRequest2) - assertTrue(categoryCreateResult2.id > 0) - - // Checking that inner category was successfully created with necessary parameters - val categoryDetailsRequest = CategoryDetailsRequest(categoryId = categoryCreateResult2.id) - val categoryDetails1 = apiClient.getCategoryDetails(categoryDetailsRequest) - assertEquals( - categoryCreateRequest2.newCategory, - categoryDetails1.toUpdated() - ) - - // Completely updating newly created category - val categoryUpdateRequest = CategoryUpdateRequest( - categoryId = categoryDetails1.id, - updatedCategory = generateTestCategory( - parentCategoryId = 0, - productIds = listOf(productCreateResult2.id) - ) - ) - val categoryUpdateResult1 = apiClient.updateCategory(categoryUpdateRequest) - assertEquals(1, categoryUpdateResult1.updateCount) - - // Checking that category was successfully updated with necessary parameters - val categoryDetails2 = apiClient.getCategoryDetails(categoryDetailsRequest) - assertEquals( - categoryUpdateRequest.updatedCategory, - categoryDetails2.toUpdated().cleanupForComparison() - ) - - // Deleting category - val categoryDeleteRequest = CategoryDeleteRequest(categoryId = categoryDetails1.id) - val categoryDeleteResult = apiClient.deleteCategory(categoryDeleteRequest) - assertEquals(1, categoryDeleteResult.deleteCount) - - // Checking that deleted category is not accessible anymore - try { - apiClient.getCategoryDetails(categoryDetailsRequest) - } catch (e: EcwidApiException) { - assertEquals(404, e.statusCode) - assertEquals("Category #${categoryCreateResult2.id} not found", e.message) - } - } - - @Test - fun testTranslations() { - // Creating new category - val categoryCreateRequest = CategoryCreateRequest( - newCategory = generateTestCategory() - ) - val categoryCreateResult = apiClient.createCategory(categoryCreateRequest) - assertTrue(categoryCreateResult.id > 0) - - val categoryDetails = apiClient.getCategoryDetails( - CategoryDetailsRequest( - categoryId = categoryCreateResult.id - ) - ) - val descriptionTranslated = categoryDetails.descriptionTranslated - require(descriptionTranslated != null) - assertTrue(descriptionTranslated.size > 0) - assertTrue(descriptionTranslated.containsKey("ru")) - assertTrue(descriptionTranslated.getValue("ru").startsWith("Описание")) - - val nameTranslated = categoryDetails.nameTranslated - require(nameTranslated != null) - assertTrue(nameTranslated.size > 0) - assertTrue(nameTranslated.containsKey("ru")) - assertTrue(nameTranslated.getValue("ru").startsWith("Категория")) - } - - @Test - fun testManipulateCategoryImage() { - // Creating new category - val categoryCreateRequest = CategoryCreateRequest( - newCategory = generateTestCategory() - ) - val categoryCreateResult = apiClient.createCategory(categoryCreateRequest) - assertTrue(categoryCreateResult.id > 0) - - // Upload some images from different sources - - val categoryImageUploadRequest1 = CategoryImageUploadRequest( - categoryId = categoryCreateResult.id, - fileData = UploadFileData.ExternalUrlData(externalUrl = "https://don16obqbay2c.cloudfront.net/favicons/apple-touch-icon-180x180.png") - ) - val categoryImageUploadResult1 = apiClient.uploadCategoryImage(categoryImageUploadRequest1) - assertTrue(categoryImageUploadResult1.id > 0) - - val categoryImageUploadRequest2 = CategoryImageUploadRequest( - categoryId = categoryCreateResult.id, - fileData = UploadFileData.LocalFileData(file = getTestPngFilePath().toFile()) - ) - val categoryImageUploadResult2 = apiClient.uploadCategoryImage(categoryImageUploadRequest2) - assertTrue(categoryImageUploadResult2.id > 0) - - val categoryImageUploadRequest3 = CategoryImageUploadRequest( - categoryId = categoryCreateResult.id, - fileData = UploadFileData.InputStreamData(stream = FileInputStream(getTestPngFilePath().toFile())) - ) - val categoryImageUploadResult3 = apiClient.uploadCategoryImage(categoryImageUploadRequest3) - assertTrue(categoryImageUploadResult3.id > 0) - - val categoryImageUploadRequest4 = CategoryImageUploadRequest( - categoryId = categoryCreateResult.id, - fileData = UploadFileData.ByteArrayData(bytes = Files.readAllBytes(getTestPngFilePath())) - ) - val categoryImageUploadResult4 = apiClient.uploadCategoryImage(categoryImageUploadRequest4) - assertTrue(categoryImageUploadResult4.id > 0) - - // Checking that category has last uploaded image - val categoryDetailsRequest = CategoryDetailsRequest(categoryId = categoryCreateResult.id) - val categoryDetails1 = apiClient.getCategoryDetails(categoryDetailsRequest) - assertCategoryImage( - expectedThumbnailImageId = categoryImageUploadResult4.id, - categoryDetails = categoryDetails1 - ) - - // Now delete category image - val categoryImageDeleteRequest = CategoryImageDeleteRequest(categoryId = categoryCreateResult.id) - val categoryImageDeleteResult = apiClient.deleteCategoryImage(categoryImageDeleteRequest) - assertTrue(categoryImageDeleteResult.deleteCount > 0) - - // Check that category has now no main image now - val categoryDetails2 = apiClient.getCategoryDetails(categoryDetailsRequest) - assertNoCategoryImage(categoryDetails = categoryDetails2) - } - - @Test - fun testUploadCategoryImageAsync() { - // Creating new category - val categoryCreateRequest = CategoryCreateRequest( - newCategory = generateTestCategory() - ) - val categoryCreateResult = apiClient.createCategory(categoryCreateRequest) - assertTrue(categoryCreateResult.id > 0) - - val categoryDetailsRequest = CategoryDetailsRequest(categoryId = categoryCreateResult.id) - val categoryDetails = apiClient.getCategoryDetails(categoryDetailsRequest) - assertNull(categoryDetails.imageUrl) - - // Try to send async image upload request - val request = CategoryImageAsyncUploadRequest( - categoryId = categoryCreateResult.id, - asyncPictureData = AsyncPictureData( - url = "https://don16obqbay2c.cloudfront.net/favicons/apple-touch-icon-180x180.png", - width = 180, - height = 180 - ) - ) - apiClient.uploadCategoryImageAsync(request) - - val categoryDetailsAfterUpload = apiClient.getCategoryDetails(categoryDetailsRequest) - assertNotNull(categoryDetailsAfterUpload.imageUrl) - - val requestWithBlankUrl = CategoryImageAsyncUploadRequest( - categoryId = categoryCreateResult.id, - asyncPictureData = AsyncPictureData( - url = " ", - width = 180, - height = 180 - ) - ) - try { - apiClient.uploadCategoryImageAsync(requestWithBlankUrl) - fail(message = "Request must return error") - } catch (ignore: EcwidApiException) { - // ok - } - - val requestWithWrongUrl = CategoryImageAsyncUploadRequest( - categoryId = categoryCreateResult.id, - asyncPictureData = AsyncPictureData( - url = "htt://sssss", - width = 180, - height = 180 - ) - ) - try { - apiClient.uploadCategoryImageAsync(requestWithWrongUrl) - fail(message = "Request must return error") - } catch (ignore: EcwidApiException) { - // ok - } - } - - @Test - fun testAssignProductsToCategory() { - // Create new products to put into new categories - val productCreateRequest1 = ProductCreateRequest(generateTestProduct("testAssignProductsToCategory", enabled = true)) - val productCreateResult1 = apiClient.createProduct(productCreateRequest1) - assertTrue(productCreateResult1.id > 0) - - val productCreateRequest2 = ProductCreateRequest(generateTestProduct("testAssignProductsToCategory", enabled = false)) - val productCreateResult2 = apiClient.createProduct(productCreateRequest2) - assertTrue(productCreateResult2.id > 0) - - // Create new categories - val categoryCreateRequest1 = CategoryCreateRequest(generateTestCategory(enabled = true)) - val categoryCreateResult1 = apiClient.createCategory(categoryCreateRequest1) - assertTrue(categoryCreateResult1.id > 0) - - val categoryCreateRequest2 = CategoryCreateRequest(generateTestCategory(enabled = false)) - val categoryCreateResult2 = apiClient.createCategory(categoryCreateRequest2) - assertTrue(categoryCreateResult2.id > 0) - - // Assign products to category - val productIds = listOf(productCreateResult1.id, productCreateResult2.id) - - val assignRequest1 = AssignProductsToCategoryRequest(categoryCreateResult1.id, productIds) - val assignResult1 = apiClient.assignProductsToCategory(assignRequest1) - assertEquals(1, assignResult1.updateCount) - - val assignRequest2 = AssignProductsToCategoryRequest(categoryCreateResult2.id, productIds) - val assignResult2 = apiClient.assignProductsToCategory(assignRequest2) - assertEquals(1, assignResult2.updateCount) - - val categoryAfterAssign1 = apiClient.getCategoryDetails(CategoryDetailsRequest(categoryCreateResult1.id)) - assertEquals(productIds.toSet(), categoryAfterAssign1.productIds?.toSet()) - - val categoryAfterAssign2 = apiClient.getCategoryDetails(CategoryDetailsRequest(categoryCreateResult2.id)) - assertEquals(productIds.toSet(), categoryAfterAssign2.productIds?.toSet()) - - // Unassign products from category - val unassignRequest1 = UnassignProductsFromCategoryRequest(categoryCreateResult1.id, listOf(productCreateResult1.id)) - val unassignResult1 = apiClient.unassignProductsFromCategory(unassignRequest1) - assertEquals(1, unassignResult1.deleteCount) - - val unassignRequest2 = UnassignProductsFromCategoryRequest(categoryCreateResult2.id, listOf(productCreateResult2.id)) - val unassignResult2 = apiClient.unassignProductsFromCategory(unassignRequest2) - assertEquals(1, unassignResult2.deleteCount) - - val categoryAfterUnassign1 = apiClient.getCategoryDetails(CategoryDetailsRequest(categoryCreateResult1.id)) - assertEquals(listOf(productCreateResult2.id), categoryAfterUnassign1.productIds) - - val categoryAfterUnassign2 = apiClient.getCategoryDetails(CategoryDetailsRequest(categoryCreateResult2.id)) - assertEquals(listOf(productCreateResult1.id), categoryAfterUnassign2.productIds) - } - - private fun assertCategory( - desiredId: Int, - desiredProductIds: List?, - categoriesSearchResult: CategoriesSearchResult - ) { - val category = categoriesSearchResult.items.find { category -> - category.id == desiredId - } ?: fail("Category with id $desiredId not found") - - assertAll( - { assertEquals(desiredId, category.id) }, - { assertEquals(desiredProductIds, category.productIds) } - ) - } - - private fun assertCategoryUrlMatchesRegex(categorySearchRequest: CategoriesSearchRequest, urlPattern: String) { - val searchCategories = apiClient.searchCategories(categorySearchRequest) - assertEquals(1, searchCategories.total) - - val url = searchCategories.items[0].url ?: "" - assertTrue( - url.matches(Regex(urlPattern)), - "Url '$url' is not matching regex pattern '$urlPattern'" - ) - } - - private fun assertCategoryImage(expectedThumbnailImageId: Long, categoryDetails: FetchedCategory) { - assertAll( - { - assertTrue( - categoryDetails.thumbnailUrl?.endsWith("/$expectedThumbnailImageId.png") - ?: false, - "thumbnailUrl mismatch" - ) - }, - { assertFalse(categoryDetails.hdThumbnailUrl.isNullOrEmpty(), "hdThumbnailUrl is empty") }, - // { assertFalse(categoryDetails.imageUrl.isNullOrEmpty(), "imageUrl is empty") }, // TODO Cannot test due to bug https://track.ecwid.com/youtrack/issue/ECWID-53222 - { assertFalse(categoryDetails.originalImageUrl.isNullOrEmpty(), "originalImageUrl is empty") }, - { assertFalse(categoryDetails.originalImage?.url.isNullOrEmpty(), "originalImage.url is empty") }, - { assertTrue((categoryDetails.originalImage?.width ?: 0) > 0, "originalImage.width is zero") }, - { assertTrue((categoryDetails.originalImage?.height ?: 0) > 0, "originalImage.height is zero") } - ) - } - - private fun assertNoCategoryImage(categoryDetails: FetchedCategory) { - assertAll( - { assertNull(categoryDetails.thumbnailUrl, "thumbnailUrl not empty") }, - { assertNull(categoryDetails.hdThumbnailUrl, "hdThumbnailUrl is not empty") }, - // { assertNull(categoryDetails.imageUrl, "imageUrl is not empty") }, // TODO Cannot test due to bug https://track.ecwid.com/youtrack/issue/ECWID-53222 - { assertNull(categoryDetails.originalImageUrl, "originalImageUrl is not empty") }, - { assertNull(categoryDetails.originalImage, "originalImage is not null") } - ) - } -} - -private fun generateTestProduct( - nameSuffix: String, - enabled: Boolean = randomBoolean() -): UpdatedProduct { - return UpdatedProduct( - name = "Product $nameSuffix: ${randomAlphanumeric(8)}", - enabled = enabled - ) -} - -private fun generateTestCategory( - parentCategoryId: Int? = null, - productIds: List = listOf(), - enabled: Boolean = randomBoolean() -): UpdatedCategory { - val name = "Category " + randomAlphanumeric(8) - val description = "Description " + randomAlphanumeric(16) - - return UpdatedCategory( - parentId = parentCategoryId, - orderBy = 10, - name = name, - nameTranslated = LocalizedValueMap( - "ru" to "Категория " + randomAlphanumeric(8), - "en" to name - ), - description = description, - descriptionTranslated = LocalizedValueMap( - "ru" to "Описание " + randomAlphanumeric(16), - "en" to description - ), - enabled = enabled, - productIds = productIds, - isSampleCategory = false, - seoTitle = "", - seoTitleTranslated = LocalizedValueMap( - "ru" to "", - "en" to "" - ), - seoDescription = "", - seoDescriptionTranslated = LocalizedValueMap( - "ru" to "", - "en" to "" - ), - customSlug = "" - ) -} - -private fun UpdatedCategory.cleanupForComparison(): UpdatedCategory { - return copy( - parentId = parentId ?: 0, - // orderBy can be changed by internal ecwid rules so reset it - orderBy = 10 - ) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CouponsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CouponsTest.kt deleted file mode 100644 index 336be1b9f..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CouponsTest.kt +++ /dev/null @@ -1,320 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.category.request.CategoryCreateRequest -import com.ecwid.apiclient.v3.dto.category.request.UpdatedCategory -import com.ecwid.apiclient.v3.dto.category.result.CategoryCreateResult -import com.ecwid.apiclient.v3.dto.coupon.request.* -import com.ecwid.apiclient.v3.dto.order.enums.DiscountCouponApplicationLimit -import com.ecwid.apiclient.v3.dto.order.enums.DiscountCouponStatus -import com.ecwid.apiclient.v3.dto.order.enums.DiscountCouponType -import com.ecwid.apiclient.v3.dto.order.enums.DiscountCouponUsesLimit -import com.ecwid.apiclient.v3.dto.product.request.ProductCreateRequest -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct -import com.ecwid.apiclient.v3.dto.product.result.ProductCreateResult -import com.ecwid.apiclient.v3.exception.EcwidApiException -import com.ecwid.apiclient.v3.util.* -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import java.util.* - -class CouponsTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - - // We need to start from scratch each time - removeAllCoupons() - removeAllCategories() - removeAllProducts() - } - - @Test - fun testCouponLifecycle() { - // Create two products - val productCreateResult1 = createTestProduct() - val productCreateResult2 = createTestProduct() - assertTrue(productCreateResult1.id > 0) - assertTrue(productCreateResult2.id > 0) - - // Create two categories - val categoryCreateResult1 = createTestCategory() - val categoryCreateResult2 = createTestCategory() - assertTrue(categoryCreateResult1.id > 0) - assertTrue(categoryCreateResult2.id > 0) - - // Creating new coupon - val couponCreateRequest = CouponCreateRequest( - newCoupon = generateTestCouponForCreate(productCreateResult1.id, categoryCreateResult1.id) - ) - val couponCreateResult = apiClient.createCoupon(couponCreateRequest) - assertTrue(couponCreateResult.id > 0) - - // Checking that coupon was successfully created with necessary parameters - val couponDetailsRequest = CouponDetailsRequest(couponIdentifier = couponCreateRequest.newCoupon.code) - val couponDetails = apiClient.getCouponDetails(couponDetailsRequest) - assertEquals( - couponCreateRequest.newCoupon, - couponDetails.toUpdated() - ) - - // Completely updating newly created coupon - val couponUpdateRequest = CouponUpdateRequest( - couponIdentifier = couponDetails.code, - updatedCoupon = generateTestCouponForUpdate(productCreateResult2.id, categoryCreateResult2.id) - ) - val couponUpdateResult = apiClient.updateCoupon(couponUpdateRequest) - assertEquals(1, couponUpdateResult.updateCount) - - // Checking that coupon was successfully updated with necessary parameters - val couponDetailsRequest1 = CouponDetailsRequest(couponIdentifier = couponUpdateRequest.updatedCoupon.code) - val couponDetails1 = apiClient.getCouponDetails(couponDetailsRequest1) - assertEquals( - couponUpdateRequest.updatedCoupon, - couponDetails1.toUpdated() - ) - - // Deleting coupon - val couponDeleteRequest = CouponDeleteRequest(couponIdentifier = couponDetails1.code) - val couponDeleteResult = apiClient.deleteCoupon(couponDeleteRequest) - assertEquals(1, couponDeleteResult.deleteCount) - - // Checking that deleted coupon is not accessible anymore - try { - apiClient.getCouponDetails(couponDetailsRequest1) - } catch (e: EcwidApiException) { - assertEquals(404, e.statusCode) - assertEquals("Coupon is not found", e.message) - } - } - - @Test - fun testSearchFields() { - // We need to start from scratch - removeAllCoupons() - - // Creating 2 new coupons - val couponCreateRequest1 = CouponCreateRequest( - newCoupon = generateTestCouponForSearch1() - ) - val couponCreateResult1 = apiClient.createCoupon(couponCreateRequest1) - assertTrue(couponCreateResult1.id > 0) - - val couponCreateRequest2 = CouponCreateRequest( - newCoupon = generateTestCouponForSearch2() - ) - val couponCreateResult2 = apiClient.createCoupon(couponCreateRequest2) - assertTrue(couponCreateResult2.id > 0) - - // Trying to search by different fields - - assertCouponsSearch( - positiveSearchRequest = CouponSearchRequest( - code = couponCreateRequest1.newCoupon.code, - offset = 0 - ), - negativeSearchRequest = CouponSearchRequest( - code = couponCreateRequest1.newCoupon.code, - offset = 1 - ) - ) - - assertCouponsSearch( - positiveSearchRequest = CouponSearchRequest( - offset = 1, - limit = 1 - ), - negativeSearchRequest = CouponSearchRequest( - offset = 2, - limit = 1 - ) - ) - - assertCouponsSearch( - positiveSearchRequest = CouponSearchRequest( - code = couponCreateRequest1.newCoupon.code, - discountType = setOf(couponCreateRequest1.newCoupon.discountType!!) - - ), - negativeSearchRequest = CouponSearchRequest( - code = couponCreateRequest1.newCoupon.code, - discountType = setOf(couponCreateRequest2.newCoupon.discountType!!) - ) - ) - - val instant = Date().toInstant() - val instantFrom = instant.minusSeconds(10) - val instantTo = instant.plusSeconds(10) - - assertCouponsSearch( - positiveSearchRequest = CouponSearchRequest( - code = couponCreateRequest1.newCoupon.code, - createdTo = Date.from(instantTo), - createdFrom = Date.from(instantFrom) - ), - negativeSearchRequest = CouponSearchRequest( - code = couponCreateRequest1.newCoupon.code, - createdTo = Date.from(instantFrom), - createdFrom = Date.from(instantFrom) - ) - ) - - assertCouponsSearch( - positiveSearchRequest = CouponSearchRequest( - code = couponCreateRequest1.newCoupon.code, - updatedTo = Date.from(instantTo), - updatedFrom = Date.from(instantFrom) - ), - negativeSearchRequest = CouponSearchRequest( - code = couponCreateRequest1.newCoupon.code, - updatedTo = Date.from(instantFrom), - updatedFrom = Date.from(instantFrom) - ) - ) - } - - @Test - fun testDeletedCoupon() { - // Creating new coupon - val couponCreateRequest = CouponCreateRequest( - newCoupon = UpdatedCoupon( - name = randomAlphanumeric(10).lowercase(), - code = randomAlphanumeric(10).lowercase() - ) - ) - val couponCreateResult = apiClient.createCoupon(couponCreateRequest) - assertTrue(couponCreateResult.id > 0) - - // Deleting customer - val customerDeleteRequest = CouponDeleteRequest(couponIdentifier = couponCreateResult.code) - val customerDeleteResult = apiClient.deleteCoupon(customerDeleteRequest) - assertEquals(1, customerDeleteResult.deleteCount) - } - - private fun createTestProduct(): ProductCreateResult { - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}" - ) - ) - - return apiClient.createProduct(productCreateRequest) - } - - private fun createTestCategory(): CategoryCreateResult { - val categoryCreateRequest = CategoryCreateRequest( - newCategory = UpdatedCategory( - name = "Category " + randomAlphanumeric(8) - ) - ) - - return apiClient.createCategory(categoryCreateRequest) - } - - private fun generateTestCouponForCreate(existingProductId: Int, existingCategoryId: Int): UpdatedCoupon { - val launchDate = randomDateFrom(Date()) - val expirationDate = randomDateFrom(launchDate) - - val applicationLimit = randomEnumValue() - - return UpdatedCoupon( - name = randomAlphanumeric(10), - code = randomAlphanumeric(10).uppercase(), - discountType = randomEnumValue(DiscountCouponType.SHIPPING), // DiscountCouponType.SHIPPING is not compatible with catalogLimit - status = DiscountCouponStatus.ACTIVE, - discount = randomDouble(0.0, 100000.0), - expirationDate = expirationDate, - launchDate = launchDate, - totalLimit = randomDouble(0.0, 100000.0), - usesLimit = randomEnumValue(), - repeatCustomerOnly = applicationLimit.toRepeatCustomerOnly(), - applicationLimit = applicationLimit, - orderCount = 0, - catalogLimit = UpdatedCoupon.DiscountCouponCatalogLimit( - products = listOf(existingProductId), - categories = listOf(existingCategoryId) - ) - ) - } - - private fun generateTestCouponForUpdate(existingProductId: Int, existingCategoryId: Int): UpdatedCoupon { - val launchDate = randomDateFrom(Date()) - val expirationDate = randomDateFrom(launchDate) - - val applicationLimit = randomEnumValue() - - return UpdatedCoupon( - name = randomAlphanumeric(10), - code = randomAlphanumeric(10).uppercase(), - discountType = randomEnumValue(DiscountCouponType.SHIPPING), // DiscountCouponType.SHIPPING is not compatible with catalogLimit - status = DiscountCouponStatus.ACTIVE, - discount = randomDouble(0.0, 100000.0), - expirationDate = expirationDate, - launchDate = launchDate, - totalLimit = randomDouble(0.0, 100000.0), - usesLimit = randomEnumValue(), - repeatCustomerOnly = applicationLimit.toRepeatCustomerOnly(), - applicationLimit = applicationLimit, - orderCount = 0, - catalogLimit = UpdatedCoupon.DiscountCouponCatalogLimit( - products = listOf(existingProductId), - categories = listOf(existingCategoryId) - ) - ) - } - - private fun generateTestCouponForSearch1(): UpdatedCoupon { - val launchDate = randomDateFrom(Date()) - val expirationDate = randomDateFrom(launchDate) - return UpdatedCoupon( - name = randomAlphanumeric(10), - code = randomAlphanumeric(10).uppercase(), - discountType = DiscountCouponType.ABS, - status = DiscountCouponStatus.ACTIVE, - discount = randomDouble(0.0, 100000.0), - expirationDate = expirationDate, - launchDate = launchDate, - totalLimit = randomDouble(0.0, 100000.0), - usesLimit = randomEnumValue(), - repeatCustomerOnly = randomBoolean(), - applicationLimit = randomEnumValue(), - orderCount = 0 - ) - } - - private fun generateTestCouponForSearch2(): UpdatedCoupon { - val launchDate = randomDateFrom(Date()) - val expirationDate = randomDateFrom(launchDate) - return UpdatedCoupon( - name = randomAlphanumeric(10), - code = randomAlphanumeric(10).uppercase(), - discountType = DiscountCouponType.PERCENT, - status = DiscountCouponStatus.ACTIVE, - discount = randomDouble(0.0, 100000.0), - expirationDate = expirationDate, - launchDate = launchDate, - totalLimit = randomDouble(0.0, 100000.0), - usesLimit = randomEnumValue(), - repeatCustomerOnly = randomBoolean(), - applicationLimit = randomEnumValue(), - orderCount = 0 - ) - } - - private fun assertCouponsSearch( - positiveSearchRequest: CouponSearchRequest, - negativeSearchRequest: CouponSearchRequest - ) { - val positiveCouponsSearchResult = apiClient.searchCoupons(positiveSearchRequest) - assertEquals(1, positiveCouponsSearchResult.count) - - val negativeCouponsSearchResult = apiClient.searchCoupons(negativeSearchRequest) - assertEquals(0, negativeCouponsSearchResult.count) - } -} - -private fun DiscountCouponApplicationLimit.toRepeatCustomerOnly() = - this == DiscountCouponApplicationLimit.REPEAT_CUSTOMER_ONLY diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CustomerGroupsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CustomerGroupsTest.kt deleted file mode 100644 index a4145afaa..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CustomerGroupsTest.kt +++ /dev/null @@ -1,129 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.customergroup.request.* -import com.ecwid.apiclient.v3.exception.EcwidApiException -import com.ecwid.apiclient.v3.util.randomAlphanumeric -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -const val TEST_SEARCH_PHRASE = "Test" -const val TEST_CUSTOMER_GROUP = "Customer group" - -class CustomerGroupsTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - - // We need to start from scratch each time - removeAllCustomerGroups() - } - - @Test - fun testCustomerGroupLifecycle() { - // Creating new customer group - val customerGroupCreateRequest = CustomerGroupCreateRequest( - newCustomerGroup = generateTestCustomerGroup() - ) - val customerGroupCreateResult = apiClient.createCustomerGroup(customerGroupCreateRequest) - assertTrue(customerGroupCreateResult.id > 0) - - // Checking that customer group was successfully created with necessary parameters - val customerGroupDetailsRequest = CustomerGroupDetailsRequest(customerGroupId = customerGroupCreateResult.id) - val customerGroupDetails1 = apiClient.getCustomerGroupDetails(customerGroupDetailsRequest) - assertEquals(customerGroupCreateRequest.newCustomerGroup, customerGroupDetails1.toUpdated()) - - // Completely updating newly created customer group - val customerGroupUpdateRequest = CustomerGroupUpdateRequest( - customerGroupId = customerGroupDetails1.id, - updatedCustomerGroup = generateTestCustomerGroup() - ) - val customerGroupUpdateResult1 = apiClient.updateCustomerGroup(customerGroupUpdateRequest) - assertEquals(1, customerGroupUpdateResult1.updateCount) - - // Checking that customer group was successfully updated with necessary parameters - val customerGroupDetails2 = apiClient.getCustomerGroupDetails(customerGroupDetailsRequest) - assertEquals(customerGroupUpdateRequest.updatedCustomerGroup, customerGroupDetails2.toUpdated()) - - // Deleting customer group - val customerGroupDeleteRequest = CustomerGroupDeleteRequest(customerGroupId = customerGroupDetails1.id) - val customerGroupDeleteResult = apiClient.deleteCustomerGroup(customerGroupDeleteRequest) - assertEquals(1, customerGroupDeleteResult.deleteCount) - - // Checking that deleted customer group is not accessible anymore - try { - apiClient.getCustomerGroupDetails(customerGroupDetailsRequest) - } catch (e: EcwidApiException) { - assertEquals(404, e.statusCode) - assertEquals("Customer group #${customerGroupCreateResult.id} not found", e.message) - } - } - - @Test - fun testSearchPaging() { - // Create 6 customer groups to test paging - val customerGroups = generateSearchTestCustomerGroups() - repeat(customerGroups.size) { - val customerGroupCreateRequest = CustomerGroupCreateRequest( - newCustomerGroup = customerGroups[it] - ) - val customerGroupCreateResult = apiClient.createCustomerGroup(customerGroupCreateRequest) - assertTrue(customerGroupCreateResult.id > 0) - } - - // Trying to request first page - val customerGroupsSearchRequest1 = CustomerGroupsSearchRequest(offset = 0, limit = 2) - val customerGroupsSearchResult1 = apiClient.searchCustomerGroups(customerGroupsSearchRequest1) - assertEquals(2, customerGroupsSearchResult1.count) // “General” group exists only of first page - assertEquals(7, customerGroupsSearchResult1.total) - - // Trying to request second and the last page - val customerGroupsSearchRequest2 = CustomerGroupsSearchRequest(offset = 6, limit = 2) - val customerGroupsSearchResult2 = apiClient.searchCustomerGroups(customerGroupsSearchRequest2) - assertEquals(1, customerGroupsSearchResult2.count) // “General” group exists only of first page - assertEquals(7, customerGroupsSearchResult2.total) - - // test by keyword "Customer group" - val customerGroupsSearchRequest3 = CustomerGroupsSearchRequest( - keyword = TEST_CUSTOMER_GROUP, - ) - val customerGroupsSearchResult3 = apiClient.searchCustomerGroups(customerGroupsSearchRequest3) - assertEquals(true, customerGroupsSearchResult3.items.all { it.name.contains(TEST_CUSTOMER_GROUP) }) - - // test by keyword "Test" - val customerGroupsSearchRequest4 = CustomerGroupsSearchRequest( - keyword = TEST_SEARCH_PHRASE, - ) - val customerGroupsSearchResult4 = apiClient.searchCustomerGroups(customerGroupsSearchRequest4) - assertEquals(true, customerGroupsSearchResult4.items.all { it.name.contains(TEST_SEARCH_PHRASE) }) - - val testGroupIds = customerGroupsSearchResult4.items.map { it.id } - - // test by customerGroupIds - val customerGroupsSearchRequest5 = CustomerGroupsSearchRequest( - customerGroupIds = testGroupIds, - ) - val customerGroupsSearchResult5 = apiClient.searchCustomerGroups(customerGroupsSearchRequest5) - assertEquals(testGroupIds.size, customerGroupsSearchResult5.total) - assertEquals(testGroupIds, customerGroupsSearchResult5.items.map { it.id }) - - } -} - -private fun generateTestCustomerGroup(): UpdatedCustomerGroup { - return UpdatedCustomerGroup( - name = "$TEST_CUSTOMER_GROUP " + randomAlphanumeric(8) - ) -} - -private fun generateSearchTestCustomerGroups(): List { - val result = mutableListOf() - repeat(3) { - result.add(UpdatedCustomerGroup("$TEST_CUSTOMER_GROUP $it")) - result.add(UpdatedCustomerGroup("$TEST_SEARCH_PHRASE $it")) - } - return result -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CustomersTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/CustomersTest.kt deleted file mode 100644 index d87b640a3..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/CustomersTest.kt +++ /dev/null @@ -1,478 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.customer.enums.CommercialRelationshipScheme -import com.ecwid.apiclient.v3.dto.customer.request.* -import com.ecwid.apiclient.v3.dto.customer.request.CustomersSearchRequest.SortOrder -import com.ecwid.apiclient.v3.dto.customer.result.FetchedCustomer -import com.ecwid.apiclient.v3.dto.customergroup.request.CustomerGroupCreateRequest -import com.ecwid.apiclient.v3.dto.customergroup.request.UpdatedCustomerGroup -import com.ecwid.apiclient.v3.dto.order.request.OrderCreateRequest -import com.ecwid.apiclient.v3.dto.order.request.UpdatedOrder -import com.ecwid.apiclient.v3.exception.EcwidApiException -import com.ecwid.apiclient.v3.util.randomAlphanumeric -import com.ecwid.apiclient.v3.util.randomBoolean -import com.ecwid.apiclient.v3.util.randomEmail -import org.junit.jupiter.api.Assertions.* -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import java.util.* - -class CustomersTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - - // We need to start from scratch each time - removeAllCustomerGroups() - removeAllCustomers() - removeAllOrders() - } - - @Test - @Disabled - fun testCustomerLifecycle() { - // Creating one customer group - val customerGroupCreateRequest1 = CustomerGroupCreateRequest( - newCustomerGroup = UpdatedCustomerGroup( - name = "Customer group " + randomAlphanumeric(8) - ) - ) - val customerGroupCreateResult1 = apiClient.createCustomerGroup(customerGroupCreateRequest1) - assertTrue(customerGroupCreateResult1.id > 0) - - // Creating another one customer group - val customerGroupCreateRequest2 = CustomerGroupCreateRequest( - newCustomerGroup = UpdatedCustomerGroup( - name = "Customer group " + randomAlphanumeric(8) - ) - ) - val customerGroupCreateResult2 = apiClient.createCustomerGroup(customerGroupCreateRequest2) - assertTrue(customerGroupCreateResult2.id > 0) - - // Creating new customer - val customerCreateRequest = CustomerCreateRequest( - newCustomer = generateTestCustomerForCreate(customerGroupId = customerGroupCreateResult1.id) - ) - val customerCreateResult = apiClient.createCustomer(customerCreateRequest) - assertTrue(customerCreateResult.id > 0) - - // Checking that customer was successfully created with necessary parameters - - val customerDetailsRequest = CustomerDetailsRequest(customerId = customerCreateResult.id) - val customerDetails1 = apiClient.getCustomerDetails(customerDetailsRequest) - assertEquals( - customerCreateRequest.newCustomer, - customerDetails1.withSortedShippingAddresses().toUpdated().cleanupForComparison(customerCreateRequest) - ) - assertEquals(customerGroupCreateRequest1.newCustomerGroup.name, customerDetails1.customerGroupName) - - assertNotNull(customerDetails1.id) - assertNotNull(customerDetails1.registered) - assertNotNull(customerDetails1.updated) - - val billingPerson = customerDetails1.billingPerson - require(billingPerson != null) - assertNotNull(billingPerson.countryName) - assertNotNull(billingPerson.stateOrProvinceName) - - val shippingAddresses = customerDetails1.shippingAddresses - require(shippingAddresses != null) - shippingAddresses.onEach { shippingAddress -> - assertNotNull(shippingAddress.id) - assertNotNull(shippingAddress.countryName) - assertNotNull(shippingAddress.stateOrProvinceName) - } - - // Completely updating newly created customer, leaving shipping addresses ids to update not recreate them - val customerUpdateRequest = CustomerUpdateRequest( - customerId = customerDetails1.id, - updatedCustomer = generateTestCustomerForUpdate( - customerGroupId = customerGroupCreateResult2.id, - oldShippingAddresses = customerDetails1.withSortedShippingAddresses().shippingAddresses - ) - ) - val customerUpdateResult1 = apiClient.updateCustomer(customerUpdateRequest) - assertEquals(1, customerUpdateResult1.updateCount) - - // Checking that customer was successfully updated with necessary parameters - val customerDetails2 = apiClient.getCustomerDetails(customerDetailsRequest) - assertEquals( - customerUpdateRequest.updatedCustomer, - customerDetails2.withSortedShippingAddresses().toUpdated().cleanupForComparisonAfterUpdate() - ) - - // Deleting customer - val customerDeleteRequest = CustomerDeleteRequest(customerId = customerDetails1.id) - val customerDeleteResult = apiClient.deleteCustomer(customerDeleteRequest) - assertEquals(1, customerDeleteResult.deleteCount) - - // Checking that deleted customer is not accessible anymore - try { - apiClient.getCustomerDetails(customerDetailsRequest) - } catch (e: EcwidApiException) { - assertEquals(404, e.statusCode) - assertEquals("Customer #${customerCreateResult.id} not found", e.message) - } - } - - @Test - fun testSearchFields() { - // Creating new customer group - val customerGroupCreateRequest = CustomerGroupCreateRequest( - newCustomerGroup = UpdatedCustomerGroup( - name = "Customer group " + randomAlphanumeric(8) - ) - ) - val customerGroupCreateResult = apiClient.createCustomerGroup(customerGroupCreateRequest) - assertTrue(customerGroupCreateResult.id > 0) - - val customerName = randomAlphanumeric(16) - // Creating new customer attached to this customer group - val customerCreateRequest = CustomerCreateRequest( - newCustomer = UpdatedCustomer( - email = randomEmail(), - billingPerson = UpdatedCustomer.BillingPerson( - name = customerName, - ), - customerGroupId = customerGroupCreateResult.id - ) - ) - val customerCreateResult = apiClient.createCustomer(customerCreateRequest) - assertTrue(customerCreateResult.id > 0) - - // Creating new order for this customer - val orderCreateRequest = OrderCreateRequest( - newOrder = UpdatedOrder( - email = customerCreateRequest.newCustomer.email, - billingPerson = UpdatedOrder.PersonInfo( - name = customerName, - ) - ) - ) - val orderCreateResult = apiClient.createOrder(orderCreateRequest) - assertTrue(orderCreateResult.id > 0) - - // Trying to search by different fields - - assertCustomersSearch( - positiveCustomerId = customerCreateResult.id, - positiveSearchRequest = CustomersSearchRequest(keyword = customerCreateRequest.newCustomer.billingPerson?.name), - negativeSearchRequest = CustomersSearchRequest(keyword = customerCreateRequest.newCustomer.billingPerson?.name + "foo") - ) - - assertCustomersSearch( - positiveCustomerId = customerCreateResult.id, - positiveSearchRequest = CustomersSearchRequest(name = customerCreateRequest.newCustomer.billingPerson?.name), - negativeSearchRequest = CustomersSearchRequest(name = customerCreateRequest.newCustomer.billingPerson?.name + "foo") - ) - - assertCustomersSearch( - positiveCustomerId = customerCreateResult.id, - positiveSearchRequest = CustomersSearchRequest(email = customerCreateRequest.newCustomer.email), - negativeSearchRequest = CustomersSearchRequest(email = customerCreateRequest.newCustomer.email + "foo") - ) - - assertCustomersSearch( - positiveCustomerId = customerCreateResult.id, - positiveSearchRequest = CustomersSearchRequest(customerGroupId = customerCreateRequest.newCustomer.customerGroupId), - negativeSearchRequest = CustomersSearchRequest(customerGroupId = 0) - ) - - assertCustomersSearch( - positiveCustomerId = customerCreateResult.id, - positiveSearchRequest = CustomersSearchRequest( - minOrderCount = 1, - maxOrderCount = 1 - ), - negativeSearchRequest = CustomersSearchRequest( - minOrderCount = 2, - maxOrderCount = 2 - ) - ) - - assertCustomersSearch( - positiveCustomerId = customerCreateResult.id, - positiveSearchRequest = CustomersSearchRequest( - createdFrom = Date.from(Date().toInstant().minusSeconds(60)), - createdTo = Date.from(Date().toInstant().plusSeconds(60)) - ), - negativeSearchRequest = CustomersSearchRequest( - createdFrom = Date(0), - createdTo = Date(0) - ) - ) - - assertCustomersSearch( - positiveCustomerId = customerCreateResult.id, - positiveSearchRequest = CustomersSearchRequest( - updatedFrom = Date.from(Date().toInstant().minusSeconds(60)), - updatedTo = Date.from(Date().toInstant().plusSeconds(60)) - ), - negativeSearchRequest = CustomersSearchRequest( - updatedFrom = Date(0), - updatedTo = Date(0) - ) - ) - } - - @Test - fun testSearchPaging() { - // Create some customers - repeat(3) { - val customerCreateRequest = CustomerCreateRequest( - newCustomer = generateTestCustomerForCreate(customerGroupId = null) - ) - val customerCreateResult = apiClient.createCustomer(customerCreateRequest) - assertTrue(customerCreateResult.id > 0) - } - - // Trying to request first page - val customersSearchRequest1 = CustomersSearchRequest(offset = 0, limit = 2) - val customersSearchResult1 = apiClient.searchCustomers(customersSearchRequest1) - assertEquals(2, customersSearchResult1.count) - assertEquals(3, customersSearchResult1.total) - - // Trying to request second and the last page - val customersSearchRequest2 = CustomersSearchRequest(offset = 2, limit = 2) - val customersSearchResult2 = apiClient.searchCustomers(customersSearchRequest2) - assertEquals(1, customersSearchResult2.count) - assertEquals(3, customersSearchResult2.total) - } - - @Test - fun testSearchSorting() { - // Creating some customers - - val customerCreateRequest1 = CustomerCreateRequest( - newCustomer = UpdatedCustomer( - email = "aaa@example.com", - billingPerson = UpdatedCustomer.BillingPerson( - name = "aaa" - ) - ) - ) - val customerCreateResult1 = apiClient.createCustomer(customerCreateRequest1) - assertTrue(customerCreateResult1.id > 0) - - val customerCreateRequest2 = CustomerCreateRequest( - newCustomer = UpdatedCustomer( - email = "bbb@example.com", - billingPerson = UpdatedCustomer.BillingPerson( - name = "bbb" - ) - ) - ) - val customerCreateResult2 = apiClient.createCustomer(customerCreateRequest2) - assertTrue(customerCreateResult2.id > 0) - - val orderCreateRequest = OrderCreateRequest( - newOrder = UpdatedOrder( - email = customerCreateRequest1.newCustomer.email, - total = 5.0 - ) - ) - val orderCreateResult = apiClient.createOrder(orderCreateRequest) - assertTrue(orderCreateResult.id > 0) - - val orderCreateRequest2 = OrderCreateRequest( - newOrder = UpdatedOrder( - email = customerCreateRequest2.newCustomer.email, - total = 5.0 - ) - ) - val orderCreateResult2 = apiClient.createOrder(orderCreateRequest2) - assertTrue(orderCreateResult2.id > 0) - - - val orderCreateRequest3 = OrderCreateRequest( - newOrder = UpdatedOrder( - email = customerCreateRequest2.newCustomer.email, - total = 5.0 - ) - ) - val orderCreateResult3 = apiClient.createOrder(orderCreateRequest3) - assertTrue(orderCreateResult3.id > 0) - - // Trying to search using different sorts - - assertCustomersSortBySearch(customerCreateResult1.id, SortOrder.NAME_ASC) - assertCustomersSortBySearch(customerCreateResult2.id, SortOrder.NAME_DESC) - - assertCustomersSortBySearch(customerCreateResult1.id, SortOrder.EMAIL_ASC) - assertCustomersSortBySearch(customerCreateResult2.id, SortOrder.EMAIL_DESC) - - assertCustomersSortBySearch(customerCreateResult1.id, SortOrder.ORDER_COUNT_ASC) - assertCustomersSortBySearch(customerCreateResult2.id, SortOrder.ORDER_COUNT_DESC) - - assertCustomersSortBySearch(customerCreateResult1.id, SortOrder.REGISTERED_DATE_ASC) - assertCustomersSortBySearch(customerCreateResult2.id, SortOrder.REGISTERED_DATE_DESC) - - assertCustomersSortBySearch(customerCreateResult1.id, SortOrder.UPDATED_DATE_ASC) - assertCustomersSortBySearch(customerCreateResult2.id, SortOrder.UPDATED_DATE_DESC) - - assertCustomersSortBySearch(customerCreateResult1.id, SortOrder.SALES_VALUE_ASC) - assertCustomersSortBySearch(customerCreateResult2.id, SortOrder.SALES_VALUE_DESC) - - assertCustomersSortBySearch(customerCreateResult1.id, SortOrder.FIRST_ORDER_DATE_ASC) - assertCustomersSortBySearch(customerCreateResult2.id, SortOrder.FIRST_ORDER_DATE_DESC) - - assertCustomersSortBySearch(customerCreateResult1.id, SortOrder.LAST_ORDER_DATE_ASC) - assertCustomersSortBySearch(customerCreateResult2.id, SortOrder.LAST_ORDER_DATE_DESC) - } - - @Test - fun testDeletedCustomers() { - // Creating new customer - val customerCreateRequest = CustomerCreateRequest( - newCustomer = UpdatedCustomer( - email = randomEmail() - ) - ) - val customerCreateResult = apiClient.createCustomer(customerCreateRequest) - assertTrue(customerCreateResult.id > 0) - - // Deleting customer - val customerDeleteRequest = CustomerDeleteRequest(customerId = customerCreateResult.id) - val customerDeleteResult = apiClient.deleteCustomer(customerDeleteRequest) - assertEquals(1, customerDeleteResult.deleteCount) - - val instant = Date().toInstant() - val instantFrom = instant.minusSeconds(10) - val instantTo = instant.plusSeconds(10) - - // Checking that just deleted customer returned from api - val deletedCustomersSearchRequest = DeletedCustomersSearchRequest( - deletedFrom = Date.from(instantFrom), - deletedTo = Date.from(instantTo) - ) - val deletedCustomers = apiClient.searchDeletedCustomersAsSequence(deletedCustomersSearchRequest) - val deletedCustomer = - deletedCustomers.firstOrNull { deletedCustomer -> deletedCustomer.id == customerCreateResult.id } - require(deletedCustomer != null) - assertTrue(instantFrom.isBefore(deletedCustomer.date.toInstant())) - assertTrue(instantTo.isAfter(deletedCustomer.date.toInstant())) - } - - private fun assertCustomersSearch( - positiveCustomerId: Int, - positiveSearchRequest: CustomersSearchRequest, - negativeSearchRequest: CustomersSearchRequest - ) { - val positiveCustomersSearchResult = apiClient.searchCustomers(positiveSearchRequest) - assertEquals(1, positiveCustomersSearchResult.total) - assertEquals(positiveCustomerId, positiveCustomersSearchResult.items[0].id) - - val negativeCustomersSearchResult = apiClient.searchCustomers(negativeSearchRequest) - assertEquals(0, negativeCustomersSearchResult.total) - } - - private fun assertCustomersSortBySearch(expectedCustomerId: Int, sortBy: SortOrder) { - val customersSearchRequest = CustomersSearchRequest( - sortBy = sortBy, - offset = 0, - limit = 1 - ) - val positiveCustomersSearchResult = apiClient.searchCustomers(customersSearchRequest) - assertEquals(expectedCustomerId, positiveCustomersSearchResult.items[0].id) - } -} - -private fun UpdatedCustomer.cleanupForComparison(customerCreateRequest: CustomerCreateRequest): UpdatedCustomer { - return copy( - // Password is write only field - password = customerCreateRequest.newCustomer.password, - // Shipping address ids were just added by server side - shippingAddresses = shippingAddresses?.map { shippingAddress -> - shippingAddress.copy(id = null, defaultAddress = null, orderBy = null) - } - ) -} - -private fun UpdatedCustomer.cleanupForComparisonAfterUpdate(): UpdatedCustomer { - return copy( - // Shipping address defaultAddresses and ordersBy were just added by server side - shippingAddresses = shippingAddresses?.map { shippingAddress -> - shippingAddress.copy(defaultAddress = null, orderBy = null) - } - ) -} - -private fun FetchedCustomer.withSortedShippingAddresses(): FetchedCustomer { - return copy( - // TODO Probably API bug (see https://track.ecwid.com/youtrack/issue/ECWID-49859) - shippingAddresses = shippingAddresses?.sortedBy(FetchedCustomer.ShippingAddress::id) - ) -} - -private fun generateTestCustomerForCreate(customerGroupId: Int?): UpdatedCustomer { - return UpdatedCustomer( - email = randomEmail(), - password = randomAlphanumeric(8), - customerGroupId = customerGroupId, - billingPerson = generateBillingPerson(), - shippingAddresses = listOf( - generateShippingAddress(), - generateShippingAddress(), - generateShippingAddress(), - generateShippingAddress() - ), - taxId = randomAlphanumeric(8), - taxIdValid = randomBoolean(), - taxExempt = randomBoolean(), - acceptMarketing = randomBoolean(), - privateAdminNotes = "test note", - lang = "en", - commercialRelationshipScheme = CommercialRelationshipScheme.b2b, - ) -} - -private fun generateTestCustomerForUpdate( - customerGroupId: Int, - oldShippingAddresses: List? -): UpdatedCustomer { - return UpdatedCustomer( - email = randomEmail(), - password = null, - customerGroupId = customerGroupId, - billingPerson = generateBillingPerson(), - shippingAddresses = listOf( - generateShippingAddress(oldShippingAddresses?.get(0)?.id), - generateShippingAddress(oldShippingAddresses?.get(1)?.id), - generateShippingAddress(oldShippingAddresses?.get(2)?.id), - generateShippingAddress(oldShippingAddresses?.get(3)?.id) - ), - taxId = randomAlphanumeric(8), - taxIdValid = randomBoolean(), - taxExempt = randomBoolean(), - acceptMarketing = randomBoolean(), - lang = "ru", - privateAdminNotes = "test note", - commercialRelationshipScheme = CommercialRelationshipScheme.b2c, - ) -} - -private fun generateBillingPerson() = UpdatedCustomer.BillingPerson( - name = "Name " + randomAlphanumeric(8), - companyName = "Company name " + randomAlphanumeric(8), - street = "Street " + randomAlphanumeric(16), - city = "City " + randomAlphanumeric(8), - countryCode = "US", - postalCode = randomAlphanumeric(6), - stateOrProvinceCode = "CA", - phone = randomAlphanumeric(10) -) - -private fun generateShippingAddress(id: Int? = null) = UpdatedCustomer.ShippingAddress( - id = id, - name = "Name " + randomAlphanumeric(8), - companyName = "Company name " + randomAlphanumeric(8), - street = "Street " + randomAlphanumeric(16), - city = "City " + randomAlphanumeric(8), - countryCode = "US", - postalCode = randomAlphanumeric(6), - stateOrProvinceCode = "CA", - phone = randomAlphanumeric(10) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ExtRequestTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ExtRequestTest.kt deleted file mode 100644 index 8b38d293b..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ExtRequestTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.dto.ApiRequest -import com.ecwid.apiclient.v3.dto.customer.request.CustomerDetailsRequest -import com.ecwid.apiclient.v3.dto.customer.result.CustomerCreateResult -import com.ecwid.apiclient.v3.httptransport.HttpBody -import com.ecwid.apiclient.v3.impl.RequestInfo -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class ExtRequestTest : BaseEntityTest() { - @BeforeEach - override fun beforeEach() { - super.beforeEach() - removeAllCustomers() - } - - @Test - fun testCreateExtCustomer() { - val email = "test@mail.com" - val taxId = "10" - val newTaxId = "11" - val customerData = CustomerData(email = email, taxId = taxId) - val customerDataExt = CustomerDataExt(taxId = newTaxId) - - val customerCreateRequest = CustomerCreateRequestExt( - newCustomer = customerData, - newCustomerExt = customerDataExt - ) - - val result = apiClientHelper.makeObjectResultRequest(customerCreateRequest) - - // Checks the customer was successfully created. - val customerDetailsRequest = CustomerDetailsRequest(customerId = result.id) - val customerDetails = apiClient.getCustomerDetails(customerDetailsRequest) - - assertEquals(customerDetails.email, email) - assertEquals(customerDetails.taxId, newTaxId) - } -} - -private data class CustomerData( - var email: String? = null, - var taxId: String? = null -) - -private data class CustomerDataExt( - var taxId: String? = null -) - -private data class CustomerCreateRequestExt( - var newCustomer: CustomerData = CustomerData(), - var newCustomerExt: CustomerDataExt = CustomerDataExt() -) : ApiRequest { - override fun toRequestInfo() = RequestInfo.createPostRequest( - pathSegments = listOf( - "customers" - ), - httpBody = HttpBody.JsonBody( - obj = newCustomer, - objExt = newCustomerExt - ) - ) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/OrdersTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/OrdersTest.kt deleted file mode 100644 index c390cb84d..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/OrdersTest.kt +++ /dev/null @@ -1,481 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.common.UploadFileData -import com.ecwid.apiclient.v3.dto.order.enums.OrderFulfillmentStatus -import com.ecwid.apiclient.v3.dto.order.enums.OrderPaymentStatus -import com.ecwid.apiclient.v3.dto.order.request.* -import com.ecwid.apiclient.v3.dto.order.result.FetchedOrder -import com.ecwid.apiclient.v3.exception.EcwidApiException -import com.ecwid.apiclient.v3.util.* -import org.junit.jupiter.api.Assertions.* -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertAll -import java.io.FileInputStream -import java.nio.file.Files -import java.util.* - -class OrdersTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - - // We need to start from scratch each time - initStoreProfile() - removeAllOrders() - } - - @Test - fun testOrderLifecycle() { - // Creating new order - val orderCreateRequest = OrderCreateRequest( - newOrder = generateTestOrder() - ) - val orderCreateResult = apiClient.createOrder(orderCreateRequest) - assertTrue(orderCreateResult.id > 0) - - // Checking that order was successfully created with necessary parameters - val orderDetailsRequest = OrderDetailsRequest(orderNumber = orderCreateResult.id) - val orderDetails1 = apiClient.getOrderDetails(orderDetailsRequest) - assertEquals( - orderCreateRequest.newOrder, - orderDetails1.toUpdated().cleanupForComparison(orderCreateRequest.newOrder) - ) - - // Completely updating newly created order - val orderUpdateRequest = OrderUpdateRequest( - orderNumber = orderDetails1.orderNumber, - updatedOrder = generateTestOrder().copy( - customerGroup = null, // TODO Discover why after each update this field resets to null - orderExtraFields = listOf( - UpdatedOrder.OrderExtraFields( - customerInputType = "DATETIME", - title = "Pickup date and time", - id = "pickup_time", - value = "2020-11-22 17:30:00 +0000", - orderDetailsDisplaySection = "shipping_info", - orderBy = "3" - ) - ) - ) - ) - val orderUpdateResult1 = apiClient.updateOrder(orderUpdateRequest) - assertEquals(1, orderUpdateResult1.updateCount) - - // Checking that order was successfully updated with necessary parameters - val orderDetails2 = apiClient.getOrderDetails(orderDetailsRequest) - assertEquals( - orderUpdateRequest.updatedOrder, - orderDetails2.toUpdated().cleanupForComparison(orderUpdateRequest.updatedOrder) - ) - - // Deleting order - val orderDeleteRequest = OrderDeleteRequest(orderNumber = orderDetails1.orderNumber) - val orderDeleteResult = apiClient.deleteOrder(orderDeleteRequest) - assertEquals(1, orderDeleteResult.deleteCount) - - // Checking that deleted order is not accessible anymore - try { - apiClient.getOrderDetails(orderDetailsRequest) - } catch (e: EcwidApiException) { - assertEquals(404, e.statusCode) - assertEquals("Order #${orderCreateResult.id} not found", e.message) - } - } - - @Test - fun testManipulateOrderItemOptionFiles() { - // Creating order with item with FILES option - val filesOptionName = "File option / With Slashes / НеЛатиНсКиМи СиМвОлАМи / !@#\$%^&*()+" - - val orderCreateRequest = OrderCreateRequest( - newOrder = UpdatedOrder( - email = randomEmail(), - items = listOf( - UpdatedOrder.OrderItem( - name = "Order item with files", - selectedOptions = listOf( - UpdatedOrder.OrderItemSelectedOption.createForFilesOption( - name = filesOptionName - ) - ) - ) - ) - ) - ) - val orderCreateResult = apiClient.createOrder(orderCreateRequest) - val orderNumber = orderCreateResult.id - assertTrue(orderNumber > 0) - - // Get order item ID in newly created order - val orderDetailsRequest = OrderDetailsRequest(orderNumber = orderNumber) - val orderDetails1 = apiClient.getOrderDetails(orderDetailsRequest) - val orderItemId = orderDetails1.items?.firstOrNull()?.id - require(orderItemId != null) - - // Upload some order files from different sources - val orderItemOptionFileUploadRequest1 = OrderItemOptionFileUploadRequest( - orderNumber = orderNumber, - orderItemId = orderItemId, - optionName = filesOptionName, - fileName = randomFileName("test", "png"), - fileData = UploadFileData.ExternalUrlData(externalUrl = "https://don16obqbay2c.cloudfront.net/favicons/apple-touch-icon-180x180.png") - ) - val orderItemOptionFileUploadRequest2 = OrderItemOptionFileUploadRequest( - orderNumber = orderNumber, - orderItemId = orderItemId, - optionName = filesOptionName, - fileName = randomFileName("test", "png"), - fileData = UploadFileData.LocalFileData(file = getTestPngFilePath().toFile()) - ) - val orderItemOptionFileUploadRequest3 = OrderItemOptionFileUploadRequest( - orderNumber = orderNumber, - orderItemId = orderItemId, - optionName = filesOptionName, - fileName = randomFileName("test", "png"), - fileData = UploadFileData.InputStreamData(stream = FileInputStream(getTestPngFilePath().toFile())) - ) - val orderItemOptionFileUploadRequest4 = OrderItemOptionFileUploadRequest( - orderNumber = orderNumber, - orderItemId = orderItemId, - optionName = filesOptionName, - fileName = randomFileName("test", "png"), - fileData = UploadFileData.ByteArrayData(bytes = Files.readAllBytes(getTestPngFilePath())) - ) - - val orderItemOptionFileUploadResult1 = apiClient.uploadOrderItemOptionFile(orderItemOptionFileUploadRequest1) - val orderItemOptionFileUploadResult2 = apiClient.uploadOrderItemOptionFile(orderItemOptionFileUploadRequest2) - val orderItemOptionFileUploadResult3 = apiClient.uploadOrderItemOptionFile(orderItemOptionFileUploadRequest3) - val orderItemOptionFileUploadResult4 = apiClient.uploadOrderItemOptionFile(orderItemOptionFileUploadRequest4) - - assertAll( - { assertTrue(orderItemOptionFileUploadResult1.id > 0) }, - { assertTrue(orderItemOptionFileUploadResult2.id > 0) }, - { assertTrue(orderItemOptionFileUploadResult3.id > 0) }, - { assertTrue(orderItemOptionFileUploadResult4.id > 0) } - ) - - // Check that files option has accurate 4 attached files - val orderDetails2 = apiClient.getOrderDetails(orderDetailsRequest) - val filesOption2 = orderDetails2.items?.first()?.selectedOptions?.first()?.files - require(filesOption2 != null) - assertEquals(4, filesOption2.size) - assertFileOption(filesOption2[0], orderItemOptionFileUploadRequest1.fileName) - assertFileOption(filesOption2[1], orderItemOptionFileUploadRequest2.fileName) - assertFileOption(filesOption2[2], orderItemOptionFileUploadRequest3.fileName) - assertFileOption(filesOption2[3], orderItemOptionFileUploadRequest4.fileName) - - // Now delete first attached to option file - val deleteOrderItemOptionFileRequest = OrderItemOptionFileDeleteRequest( - orderNumber = orderNumber, - orderItemId = orderItemId, - optionName = filesOptionName, - fileId = orderItemOptionFileUploadResult1.id - ) - val orderItemOptionFileDeleteResult = apiClient.deleteOrderItemOptionFile(deleteOrderItemOptionFileRequest) - assertEquals(1, orderItemOptionFileDeleteResult.deleteCount) - - // Check that only 3 attached files left - val orderDetails3 = apiClient.getOrderDetails(orderDetailsRequest) - val filesOption3 = orderDetails3.items?.first()?.selectedOptions?.first()?.files - assertEquals(3, filesOption3?.size) - - // Now delete the rest attached to option files - val deleteOrderItemOptionFilesRequest = OrderItemOptionFilesDeleteRequest( - orderNumber = orderNumber, - orderItemId = orderItemId, - optionName = filesOptionName - ) - val orderItemOptionFilesDeleteResult = apiClient.deleteOrderItemOptionFiles(deleteOrderItemOptionFilesRequest) - assertEquals(3, orderItemOptionFilesDeleteResult.deleteCount) - - // Check that no attached files remain - val orderDetails4 = apiClient.getOrderDetails(orderDetailsRequest) - val filesOption4 = orderDetails4.items?.first()?.selectedOptions?.first()?.files - assertNull(filesOption4) - } - - @Test - @Disabled - fun testSearchFields() { - // Creating new order - val orderCreateRequest = OrderCreateRequest( - newOrder = UpdatedOrder( - email = randomEmail(), - total = randomPrice(), -// discountCoupon = UpdatedOrder.DiscountCouponInfo( -// name = "Discount coupon " + randomAlphanumeric(16), -// code = randomAlphanumeric(16) -// ), - paymentMethod = "Payment method " + randomAlphanumeric(8), - shippingOption = UpdatedOrder.ShippingOption( - shippingMethodName = "Method " + randomAlphanumeric(8) - ), - paymentStatus = OrderPaymentStatus.AWAITING_PAYMENT, - fulfillmentStatus = OrderFulfillmentStatus.AWAITING_PROCESSING, - orderComments = randomAlphanumeric(16), - billingPerson = UpdatedOrder.PersonInfo( - name = randomAlphanumeric(16) - ) - ) - ) - val orderCreateResult = apiClient.createOrder(orderCreateRequest) - assertTrue(orderCreateResult.id > 0) - - // Waiting till order became available for searching - processDelay(1500, 10) { - val ordersSearchRequest = OrdersSearchRequest(keywords = orderCreateRequest.newOrder.orderComments) - val ordersSearchResult = apiClient.searchOrders(ordersSearchRequest) - if (ordersSearchResult.total > 0) ordersSearchResult else null - } - - // Trying to search by different fields - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest(keywords = orderCreateRequest.newOrder.orderComments), - negativeSearchRequest = OrdersSearchRequest(keywords = orderCreateRequest.newOrder.orderComments + "foo") - ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest( - totalFrom = orderCreateRequest.newOrder.total!! - 10.0, - totalTo = orderCreateRequest.newOrder.total!! + 10.0 - ), - negativeSearchRequest = OrdersSearchRequest( - totalFrom = orderCreateRequest.newOrder.total!! - 20.0, - totalTo = orderCreateRequest.newOrder.total!! - 10.0 - ) - ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest( - createdFrom = Date.from(Date().toInstant().minusSeconds(60)), - createdTo = Date.from(Date().toInstant().plusSeconds(60)) - ), - negativeSearchRequest = OrdersSearchRequest( - createdFrom = Date(0), - createdTo = Date(0) - ) - ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest( - updatedFrom = Date.from(Date().toInstant().minusSeconds(60)), - updatedTo = Date.from(Date().toInstant().plusSeconds(60)) - ), - negativeSearchRequest = OrdersSearchRequest( - updatedFrom = Date(0), - updatedTo = Date(0) - ) - ) - - // TODO We should create real discount coupon to make this search works correctly -// assertOrderSearch( -// positiveOrderNumber = createOrderResult.id, -// positiveSearchRequest = SearchOrdersRequest(couponCode = createOrderRequest.newOrder.discountCoupon?.code), -// negativeSearchRequest = SearchOrdersRequest(couponCode = createOrderRequest.newOrder.discountCoupon?.code + "foo") -// ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest(orderNumber = orderCreateResult.id), - negativeSearchRequest = OrdersSearchRequest(orderNumber = Int.MAX_VALUE) - ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest(vendorOrderNumber = orderCreateResult.id.toString()), - negativeSearchRequest = OrdersSearchRequest(vendorOrderNumber = "foo") - ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest(customer = orderCreateRequest.newOrder.billingPerson?.name), - negativeSearchRequest = OrdersSearchRequest(customer = "foo") - ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest(paymentMethod = orderCreateRequest.newOrder.paymentMethod), - negativeSearchRequest = OrdersSearchRequest(paymentMethod = "foo") - ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest(shippingMethod = orderCreateRequest.newOrder.shippingOption?.shippingMethodName), - negativeSearchRequest = OrdersSearchRequest(shippingMethod = "foo") - ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest(paymentStatus = listOf(OrderPaymentStatus.AWAITING_PAYMENT)), - negativeSearchRequest = OrdersSearchRequest(paymentStatus = listOf(OrderPaymentStatus.PAID)) - ) - - assertOrdersSearch( - positiveOrderNumber = orderCreateResult.id, - positiveSearchRequest = OrdersSearchRequest(fulfillmentStatus = OrderFulfillmentStatus.AWAITING_PROCESSING), - negativeSearchRequest = OrdersSearchRequest(fulfillmentStatus = OrderFulfillmentStatus.SHIPPED) - ) - } - - @Test - @Disabled - fun testSearchPaging() { - // Create some orders - repeat(3) { - val orderCreateRequest = OrderCreateRequest(newOrder = UpdatedOrder()) - val orderCreateResult = apiClient.createOrder(orderCreateRequest) - assertTrue(orderCreateResult.id > 0) - } - - // Waiting till order became available for searching and trying to request only one page - val ordersSearchRequest = OrdersSearchRequest(offset = 2, limit = 2) - val ordersSearchResult = processDelay(1500, 10) { - val result = apiClient.searchOrders(ordersSearchRequest) - if (result.count == 1 && result.total == 3) result else null - } - - assertEquals(1, ordersSearchResult.count) - assertEquals(3, ordersSearchResult.total) - } - - @Test - fun testGetOrderInvoice() { - val orderCreateRequest = OrderCreateRequest( - newOrder = UpdatedOrder( - email = randomEmail() - ) - ) - val orderCreateResult = apiClient.createOrder(orderCreateRequest) - assertTrue(orderCreateResult.id > 0) - - processDelay(1500, 10) { - val result = apiClient.searchOrders(OrdersSearchRequest()) - if (result.count == 1) result else null - } - - val orderInvoiceRequest = OrderInvoiceRequest(orderNumber = orderCreateResult.id) - val invoiceHtml = apiClient.getOrderInvoice(orderInvoiceRequest) - assertTrue(invoiceHtml.contains("")) - assertTrue(invoiceHtml.contains("")) - assertTrue(invoiceHtml.contains("#${orderCreateResult.id}")) - } - - @Test - fun testDeletedOrders() { - // Creating new order - val orderCreateRequest = OrderCreateRequest( - newOrder = generateTestOrder() - ) - val orderCreateResult = apiClient.createOrder(orderCreateRequest) - assertTrue(orderCreateResult.id > 0) - - // Deleting order - val orderDeleteRequest = OrderDeleteRequest(orderNumber = orderCreateResult.id) - val orderDeleteResult = apiClient.deleteOrder(orderDeleteRequest) - assertEquals(1, orderDeleteResult.deleteCount) - - val instant = Date().toInstant() - val instantFrom = instant.minusSeconds(10) - val instantTo = instant.plusSeconds(10) - - // Checking that just deleted order returned from api - val deletedOrdersSearchRequest = DeletedOrdersSearchRequest( - deletedFrom = Date.from(instantFrom), - deletedTo = Date.from(instantTo) - ) - val deletedOrders = apiClient.searchDeletedOrdersAsSequence(deletedOrdersSearchRequest) - val deletedOrder = deletedOrders.firstOrNull { deletedOrder -> deletedOrder.id == orderCreateResult.id } - require(deletedOrder != null) - assertTrue(instantFrom.isBefore(deletedOrder.date.toInstant())) - assertTrue(instantTo.isAfter(deletedOrder.date.toInstant())) - } - - private fun assertOrdersSearch( - positiveOrderNumber: Int, - positiveSearchRequest: OrdersSearchRequest, - negativeSearchRequest: OrdersSearchRequest - ) { - val positiveOrdersSearchResult = apiClient.searchOrders(positiveSearchRequest) - assertEquals(1, positiveOrdersSearchResult.total) - assertEquals(positiveOrderNumber, positiveOrdersSearchResult.items[0].orderNumber) - - val negativeOrdersSearchResult = apiClient.searchOrders(negativeSearchRequest) - assertEquals(0, negativeOrdersSearchResult.total) - } -} - -private fun assertFileOption(orderItemProductFile: FetchedOrder.OrderItemOptionFile, fileName: String) { - assertAll( - { assertTrue(orderItemProductFile.id ?: 0 > 0) }, - { assertEquals(fileName, orderItemProductFile.name) }, - { assertTrue(orderItemProductFile.size ?: 0 > 0) }, - { assertTrue(orderItemProductFile.url?.contains(fileName) ?: false) } - ) -} - -private fun UpdatedOrder.cleanupForComparison(order: UpdatedOrder): UpdatedOrder { - return copy( - // Customer id and customer group updated during order creation - customerId = order.customerId, - customerGroup = order.customerGroup, - - // Delete after bug ECWID-71481 fix - items = items?.mapIndexed { index, item -> - val requestItem = order.items?.get(index) - item.cleanupForComparison(requestItem) - }, - customerFiscalCode = null, // ApiOrder has empty string instead of null - electronicInvoicePecEmail = null, - electronicInvoiceSdiCode = null, - commercialRelationshipScheme = null, - discountInfo = order.discountInfo?.map { - it.copy( - appliesToItems = null - ) - }, - lang = order.lang - ) -} - -private fun UpdatedOrder.OrderItem.cleanupForComparison(orderItem: UpdatedOrder.OrderItem?): UpdatedOrder.OrderItem { - return copy( - id = null, - nameTranslated = orderItem?.nameTranslated, - shortDescriptionTranslated = orderItem?.shortDescriptionTranslated, - selectedPrice = orderItem?.selectedPrice, - selectedOptions = selectedOptions?.mapIndexed { index, option -> - val requestOption = orderItem?.selectedOptions?.get(index) - option.cleanupForComparison(requestOption) - }, - discounts = discounts?.mapIndexed { index, discount -> - val requestDiscount = orderItem?.discounts?.get(index) - discount.cleanupForComparison(requestDiscount) - }, - ) -} - -private fun UpdatedOrder.OrderItemSelectedOption.cleanupForComparison(orderItemSelectedOption: UpdatedOrder.OrderItemSelectedOption?): UpdatedOrder.OrderItemSelectedOption { - return copy( - valuesArray = orderItemSelectedOption?.valuesArray, - valueTranslated = orderItemSelectedOption?.valueTranslated, - selections = orderItemSelectedOption?.selections?.map { selectionInfo -> - selectionInfo.copy() - } - ) -} - -private fun UpdatedOrder.OrderItemDiscounts.cleanupForComparison(orderItemSelectedDiscount: UpdatedOrder.OrderItemDiscounts?): UpdatedOrder.OrderItemDiscounts { - return copy( - discountInfo = orderItemSelectedDiscount?.discountInfo?.copy( - appliesToItems = null - ) - ) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductTypesTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductTypesTest.kt deleted file mode 100644 index 7a8467995..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductTypesTest.kt +++ /dev/null @@ -1,193 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.producttype.enums.AttributeDisplayType -import com.ecwid.apiclient.v3.dto.producttype.enums.AttributeType -import com.ecwid.apiclient.v3.dto.producttype.request.* -import com.ecwid.apiclient.v3.dto.producttype.result.FetchedProductType -import com.ecwid.apiclient.v3.exception.EcwidApiException -import com.ecwid.apiclient.v3.util.randomAlphanumeric -import com.ecwid.apiclient.v3.util.randomEnumValue -import com.ecwid.apiclient.v3.util.randomOf -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class ProductTypesTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - - // We need to start from scratch each time - removeAllProductTypes() - } - - @Test - fun testGeneralProductTypeLifecycle() { - val productTypeCreateRequest = ProductTypeCreateRequest( - newProductType = UpdatedProductType( - name = randomOf("Shirts & Tops", "Books", "Tablet Computers"), - attributes = listOf( - UpdatedProductType.Attribute( - name = "Attribute Upc", - type = AttributeType.UPC, - show = AttributeDisplayType.DESCR - ), - UpdatedProductType.Attribute( - name = "Attribute Brand", - type = AttributeType.BRAND, - show = AttributeDisplayType.DESCR - ), - UpdatedProductType.Attribute( - name = "Attribute Gender", - type = AttributeType.GENDER, - show = AttributeDisplayType.PRICE - ), - UpdatedProductType.Attribute( - name = "Attribute Age Group", - type = AttributeType.AGE_GROUP, - show = AttributeDisplayType.PRICE - ), - UpdatedProductType.Attribute( - name = "Attribute Color", - type = AttributeType.COLOR, - show = AttributeDisplayType.DESCR - ), - UpdatedProductType.Attribute( - name = "Attribute Size", - type = AttributeType.SIZE, - show = AttributeDisplayType.NOTSHOW - ), - UpdatedProductType.Attribute( - name = "Attribute Ebay", - type = AttributeType.EBAY, - show = AttributeDisplayType.DESCR - ), - UpdatedProductType.Attribute( - name = "Attribute Ebay required", - type = AttributeType.EBAY_REQUIRED, - show = AttributeDisplayType.NOTSHOW - ), - UpdatedProductType.Attribute( - name = "Attribute Price Per Unit", - type = AttributeType.PRICE_PER_UNIT, - show = AttributeDisplayType.DESCR - ), - UpdatedProductType.Attribute( - name = "Attribute Units in product", - type = AttributeType.UNITS_IN_PRODUCT, - show = AttributeDisplayType.NOTSHOW - ) - ) - ) - ) - - val productTypeCreateResult = apiClient.createProductType(productTypeCreateRequest) - assertTrue(productTypeCreateResult.id > 0) - - // Checking that product type was successfully created with necessary parameters - val productTypeDetailsRequest = ProductTypeDetailsRequest(productTypeId = productTypeCreateResult.id) - val productTypeDetails1 = apiClient.getProductTypeDetails(productTypeDetailsRequest) - - val cleanedDetails = productTypeDetails1.toUpdated() - .cleanupAttributeIds() - - assertEquals(productTypeCreateRequest.newProductType, cleanedDetails) - } - - @Test - fun testProductTypeLifecycle() { - // Creating new product type - val productTypeCreateRequest = ProductTypeCreateRequest( - newProductType = generateTestProductTypeForCreate() - ) - val productTypeCreateResult = apiClient.createProductType(productTypeCreateRequest) - assertTrue(productTypeCreateResult.id > 0) - - // Checking that product type was successfully created with necessary parameters - val productTypeDetailsRequest = ProductTypeDetailsRequest(productTypeId = productTypeCreateResult.id) - val productTypeDetails1 = apiClient.getProductTypeDetails(productTypeDetailsRequest) - assertEquals(productTypeCreateRequest.newProductType, productTypeDetails1.toUpdated().cleanupAttributeIds()) - - // Renaming and replacing all product type attributes - val productTypeUpdateRequest = ProductTypeUpdateRequest( - productTypeId = productTypeDetails1.id, - updatedProductType = generateTestProductTypeForUpdate(productTypeDetails1) - ) - val productTypeUpdateResult1 = apiClient.updateProductType(productTypeUpdateRequest) - assertEquals(1, productTypeUpdateResult1.updateCount) - - // Checking that product type was successfully updated with necessary parameters and - // product attributes ware just renamed not recreated - val productTypeDetails2 = apiClient.getProductTypeDetails(productTypeDetailsRequest) - assertEquals(productTypeUpdateRequest.updatedProductType, productTypeDetails2.toUpdated()) - productTypeDetails1.attributes?.forEachIndexed { index, attribute -> - assertEquals(attribute.id, productTypeDetails2.attributes?.get(index)?.id) - } - - // Deleting product type - val productTypeDeleteRequest = ProductTypeDeleteRequest(productTypeId = productTypeDetails1.id) - val productTypeDeleteResult = apiClient.deleteProductType(productTypeDeleteRequest) - assertEquals(1, productTypeDeleteResult.deleteCount) - - // Checking that deleted product type is not accessible anymore - try { - apiClient.getProductTypeDetails(productTypeDetailsRequest) - } catch (e: EcwidApiException) { - assertEquals(404, e.statusCode) - assertEquals("Product class #${productTypeCreateResult.id} not found", e.message) - } - } - - @Test - fun testGetAllProductTypes() { - // Create three product types additionally to always existing “General” product type - repeat(3) { - val productTypeCreateRequest = ProductTypeCreateRequest( - newProductType = UpdatedProductType( - name = "Product type " + randomAlphanumeric(8) - ) - ) - val productTypeCreateResult = apiClient.createProductType(productTypeCreateRequest) - assertTrue(productTypeCreateResult.id > 0) - } - - // Trying to request all product types - val customerGroupsSearchResult = apiClient.getAllProductTypes(ProductTypesGetAllRequest()) - assertEquals(3 + 1, customerGroupsSearchResult.size) // “General” product type always exists in every store - } -} - -private fun generateTestProductTypeForCreate(): UpdatedProductType { - return UpdatedProductType( - name = randomOf("Shirts & Tops", "Books", "Tablet Computers"), - attributes = AttributeType.values().map(::generateProductAttribute) - ) -} - -private fun generateTestProductTypeForUpdate(source: FetchedProductType): UpdatedProductType { - return UpdatedProductType( - name = "Product type " + randomAlphanumeric(8), - attributes = source.attributes?.map { attribute -> - attribute.toUpdated().copy( - name = "Updated " + attribute.name - ) - } - ) -} - -private fun generateProductAttribute(attributeType: AttributeType): UpdatedProductType.Attribute { - return UpdatedProductType.Attribute( - name = "Attribute ${attributeType.name}: ${randomAlphanumeric(8)}", - type = attributeType, - show = randomEnumValue() - ) -} - -private fun UpdatedProductType.cleanupAttributeIds(): UpdatedProductType { - return this.copy( - attributes = attributes?.map { attribute -> attribute.copy(id = null) } - ) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt deleted file mode 100644 index 6dd92a0da..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ProductsTest.kt +++ /dev/null @@ -1,1668 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.category.request.CategoriesSearchRequest -import com.ecwid.apiclient.v3.dto.category.request.CategoriesSearchRequest.ParentCategory -import com.ecwid.apiclient.v3.dto.category.request.CategoryCreateRequest -import com.ecwid.apiclient.v3.dto.category.request.UpdatedCategory -import com.ecwid.apiclient.v3.dto.common.* -import com.ecwid.apiclient.v3.dto.product.enums.PriceModifierType -import com.ecwid.apiclient.v3.dto.product.enums.ShippingSettingsType -import com.ecwid.apiclient.v3.dto.product.request.* -import com.ecwid.apiclient.v3.dto.product.request.GetProductFiltersRequest.* -import com.ecwid.apiclient.v3.dto.product.request.ProductInventoryUpdateRequest.InventoryAdjustment -import com.ecwid.apiclient.v3.dto.product.request.ProductsSearchRequest.* -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct.* -import com.ecwid.apiclient.v3.dto.product.result.FetchedProduct -import com.ecwid.apiclient.v3.dto.product.result.GetProductFiltersResult -import com.ecwid.apiclient.v3.dto.product.result.GetProductFiltersResult.AttributeFilterValues -import com.ecwid.apiclient.v3.dto.product.result.GetProductFiltersResult.InventoryFilterValues.InventoryFilterValue -import com.ecwid.apiclient.v3.dto.product.result.GetProductFiltersResult.OnSaleFilterValues.OnSaleFilterValue -import com.ecwid.apiclient.v3.dto.product.result.GetProductFiltersResult.OptionFilterValues -import com.ecwid.apiclient.v3.exception.EcwidApiException -import com.ecwid.apiclient.v3.util.* -import org.junit.jupiter.api.* -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import java.io.FileInputStream -import java.nio.file.Files -import java.util.* - -class ProductsTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - - // We need to start from scratch each time - initStoreProfile() - removeAllCategories() - removeAllProducts() - } - - @Test - @Disabled - fun testSearchByFilters() { - // Create some categories - - val categoryCreateRequest1 = CategoryCreateRequest(newCategory = generateTestCategory()) - val categoryCreateResult1 = apiClient.createCategory(categoryCreateRequest1) - assertTrue(categoryCreateResult1.id > 0) - - val categoryCreateRequest2 = CategoryCreateRequest( - newCategory = generateTestCategory(parentId = categoryCreateResult1.id) - ) - val categoryCreateResult2 = apiClient.createCategory(categoryCreateRequest2) - assertTrue(categoryCreateResult2.id > 0) - - // Creating new product - - val productNameSuffix = randomAlphanumeric(8) - val brandName = "Brand " + randomAlphanumeric(8) - val upc = "UPC " + randomAlphanumeric(8) - val price = randomPrice() - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product $productNameSuffix", - sku = "testSearchByFilters", - price = price, - compareToPrice = 2 * price, - enabled = true, - quantity = 10, - categoryIds = listOf(categoryCreateResult2.id), - attributes = listOf( - AttributeValue.createBrandAttributeValue(brandName), - AttributeValue.createUpcAttributeValue(upc) - ), - options = listOf( - ProductOption.createSelectOption( - name = "Color", - choices = listOf( - ProductOptionChoice("Black"), - ProductOptionChoice("White"), - ProductOptionChoice("Yellow"), - ProductOptionChoice("Red") - ), - defaultChoice = 0, - required = true - ) - ) - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - // Waiting till product became available for searching - waitForIndexedProducts( - productsSearchRequest = ByFilters(keyword = productCreateRequest.newProduct.sku), - desiredProductCount = 1 - ) - - val productDetails = apiClient.getProductDetails(ProductDetailsRequest(productId = productCreateResult.id)) - - // Trying to search by different fields - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters(keyword = productNameSuffix), - negativeSearchRequest = ByFilters(keyword = productNameSuffix + "foo") - ) - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters(sku = productCreateRequest.newProduct.sku), - negativeSearchRequest = ByFilters(sku = productCreateRequest.newProduct.sku + "foo") - ) - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters( - priceFrom = productCreateRequest.newProduct.price!! - 10.0, - priceTo = productCreateRequest.newProduct.price!! + 10.0 - ), - negativeSearchRequest = ByFilters( - priceFrom = productCreateRequest.newProduct.price!! - 20.0, - priceTo = productCreateRequest.newProduct.price!! - 10.0 - ) - ) - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters( - createdFrom = Date.from(productDetails.created.toInstant().minusSeconds(1)), - createdTo = Date.from(productDetails.created.toInstant().plusSeconds(1)) - ), - negativeSearchRequest = ByFilters( - createdFrom = Date(0), - createdTo = Date(0) - ) - ) - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters( - updatedFrom = Date.from(productDetails.updated.toInstant().minusSeconds(1)), - updatedTo = Date.from(productDetails.updated.toInstant().plusSeconds(1)) - ), - negativeSearchRequest = ByFilters( - updatedFrom = Date(0), - updatedTo = Date(0) - ) - ) - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters(enabled = true), - negativeSearchRequest = ByFilters(enabled = false) - ) - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters(inventory = true), - negativeSearchRequest = ByFilters(inventory = false) - ) - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters(onSale = true), - negativeSearchRequest = ByFilters(onSale = false) - ) - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters( - attributes = ProductSearchAttributes( - listOf( - ProductSearchAttributes.AttributeValue("Brand", brandName), - ProductSearchAttributes.AttributeValue("UPC", upc) - ) - ) - ), - negativeSearchRequest = ByFilters( - attributes = ProductSearchAttributes( - listOf( - ProductSearchAttributes.AttributeValue("Brand", brandName + "foo"), - ProductSearchAttributes.AttributeValue("UPC", upc + "foo") - ) - ) - ) - ) - - assertProductsSearch( - positiveProductId = productCreateResult.id, - positiveSearchRequest = ByFilters( - options = ProductSearchOptions( - listOf( - ProductSearchOptions.OptionValue("Color", "Yellow") - ) - ) - ), - negativeSearchRequest = ByFilters( - options = ProductSearchOptions( - listOf( - ProductSearchOptions.OptionValue("Color", "Blue") - ) - ) - ) - ) - - assertProductsSearch( - productSearchRequest = ByFilters( - categories = listOf(categoryCreateResult1.id) - ), - desiredSkus = listOf() - ) - assertProductsSearch( - productSearchRequest = ByFilters( - categories = listOf(categoryCreateResult1.id), - includeProductsFromSubcategories = true - ), - desiredSkus = listOf(productDetails.sku) - ) - } - - @Test - fun testSearchUrls() { - // Create one product - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}", - sku = "testSearchUrls" - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - // Waiting till product became available for searching - waitForIndexedProducts( - productsSearchRequest = ByFilters(keyword = productCreateRequest.newProduct.sku), - desiredProductCount = 1 - ) - - // Searching products with different combinations of baseUrl and cleanUrls parameters - assertProductUrlMatchesRegex( - productSearchRequest = ByFilters(keyword = productCreateRequest.newProduct.sku), - urlPattern = "https://.*.company.site.*/products/Product-.*p.*" - ) - assertProductUrlMatchesRegex( - productSearchRequest = ByFilters( - cleanUrls = true, - keyword = productCreateRequest.newProduct.sku - ), - urlPattern = "https://.*.company.site.*/Product-.*-p.*" - ) - assertProductUrlMatchesRegex( - productSearchRequest = ByFilters( - cleanUrls = false, - keyword = productCreateRequest.newProduct.sku - ), - urlPattern = "https://.*.company.site.*/products#!/Product-.*/p/.*" - ) - assertProductUrlMatchesRegex( - productSearchRequest = ByFilters( - baseUrl = "https://google.com/", - keyword = productCreateRequest.newProduct.sku - ), - urlPattern = "https://google.com/#!/Product-.*/p/.*" - ) - assertProductUrlMatchesRegex( - productSearchRequest = ByFilters( - baseUrl = "https://google.com/", - cleanUrls = true, - keyword = productCreateRequest.newProduct.sku - ), - urlPattern = "https://google.com/Product-.*-p.*" - ) - assertProductUrlMatchesRegex( - productSearchRequest = ByFilters( - baseUrl = "https://google.com/", - cleanUrls = false, - keyword = productCreateRequest.newProduct.sku - ), - urlPattern = "https://google.com/#!/Product-.*/p/.*" - ) - } - - @Test - fun testSearchOrder() { - val testName = "testSearchOrder" - - val productSku1 = "${testName}1" - val productSku2 = "${testName}2" - val productSku3 = "${testName}3" - - // Create three product - val productCreateRequest1 = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product $testName A: ${randomAlphanumeric(8)}", - sku = productSku1, - price = 10.0, - description = "Description B B" - ) - ) - val productCreateRequest2 = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product $testName B: ${randomAlphanumeric(8)}", - sku = productSku2, - price = 20.0 - ) - ) - - val productCreateRequest3 = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product $testName C: ${randomAlphanumeric(8)}", - sku = productSku3, - price = 30.0 - ) - ) - - val productCreateResult1 = apiClient.createProduct(productCreateRequest1) - assertTrue(productCreateResult1.id > 0) - - val productCreateResult2 = apiClient.createProduct(productCreateRequest2) - assertTrue(productCreateResult2.id > 0) - - val productCreateResult3 = apiClient.createProduct(productCreateRequest3) - assertTrue(productCreateResult3.id > 0) - - // Waiting till product became available for searching - waitForIndexedProducts( - productsSearchRequest = ByFilters(keyword = testName), - desiredProductCount = 3 - ) - - // Trying to search with different sort order - - assertProductsSearch( - productSearchRequest = ByFilters(keyword = testName, sortBy = SortOrder.ADDED_TIME_ASC), - desiredSkus = listOf(productSku1, productSku2, productSku3) - ) - assertProductsSearch( - productSearchRequest = ByFilters(keyword = testName, sortBy = SortOrder.ADDED_TIME_DESC), - desiredSkus = listOf(productSku3, productSku2, productSku1) - ) - - assertProductsSearch( - productSearchRequest = ByFilters(keyword = testName, sortBy = SortOrder.UPDATED_TIME_ASC), - desiredSkus = listOf(productSku1, productSku2, productSku3) - ) - assertProductsSearch( - productSearchRequest = ByFilters(keyword = testName, sortBy = SortOrder.UPDATED_TIME_DESC), - desiredSkus = listOf(productSku3, productSku2, productSku1) - ) - - assertProductsSearch( - productSearchRequest = ByFilters(keyword = testName, sortBy = SortOrder.NAME_ASC), - desiredSkus = listOf(productSku1, productSku2, productSku3) - ) - assertProductsSearch( - productSearchRequest = ByFilters(keyword = testName, sortBy = SortOrder.NAME_DESC), - desiredSkus = listOf(productSku3, productSku2, productSku1) - ) - - assertProductsSearch( - productSearchRequest = ByFilters(keyword = testName, sortBy = SortOrder.PRICE_ASC), - desiredSkus = listOf(productSku1, productSku2, productSku3) - ) - assertProductsSearch( - productSearchRequest = ByFilters(keyword = testName, sortBy = SortOrder.PRICE_DESC), - desiredSkus = listOf(productSku3, productSku2, productSku1) - ) - - assertProductsSearch( - productSearchRequest = ByFilters(keyword = "B", sortBy = SortOrder.RELEVANCE), - desiredSkus = listOf(productSku2, productSku1) - ) - } - - @Test - fun testSearchPaging() { - val testName = "testSearchPaging" - - // Create some products - for (i in 1..3) { - val productCreateRequest = ProductCreateRequest( - newProduct = - UpdatedProduct( - name = "Product $testName " + randomAlphanumeric(8), - sku = "$testName$i" - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - } - - // Waiting till product became available for searching and trying to request only one page - waitForIndexedProducts( - productsSearchRequest = ByFilters(keyword = testName), - desiredProductCount = 3 - ) - - val productSearchRequest = ByFilters(keyword = testName, offset = 2, limit = 2) - val productsSearchResult = apiClient.searchProducts(productSearchRequest) - assertEquals(1, productsSearchResult.count) - assertEquals(3, productsSearchResult.total) - } - - @Test - @Disabled("Will be fixed in ECWID-75364") - fun testProductLifecycle() { - // Create some categories - - val categoryCreateRequest1 = CategoryCreateRequest(newCategory = generateTestCategory()) - val categoryCreateResult1 = apiClient.createCategory(categoryCreateRequest1) - assertTrue(categoryCreateResult1.id > 0) - - val categoryCreateRequest2 = CategoryCreateRequest(newCategory = generateTestCategory()) - val categoryCreateResult2 = apiClient.createCategory(categoryCreateRequest2) - assertTrue(categoryCreateResult2.id > 0) - - val categoryCreateRequest3 = CategoryCreateRequest(newCategory = generateTestCategory()) - val categoryCreateResult3 = apiClient.createCategory(categoryCreateRequest3) - assertTrue(categoryCreateResult3.id > 0) - - val categoryIds = listOf( - categoryCreateResult1.id, - categoryCreateResult2.id, - categoryCreateResult3.id - ) - - // Creating new product - val productCreateRequest = ProductCreateRequest( - newProduct = generateTestProduct(categoryIds = categoryIds, discountsAllowed = true) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - // Checking that product was successfully created with necessary parameters - val productDetailsRequest = ProductDetailsRequest(productId = productCreateResult.id) - val productDetails1 = apiClient.getProductDetails(productDetailsRequest) - assertEquals( - productCreateRequest.newProduct, - productDetails1.toUpdated().cleanupForComparison(productCreateRequest) - ) - - // Completely updating newly created product - val productUpdateRequest = ProductUpdateRequest( - productId = productDetails1.id, - updatedProduct = generateTestProduct(categoryIds = categoryIds, discountsAllowed = false) - .withUnchangedShowOnFrontend(productCreateRequest) - ) - val productUpdateResult1 = apiClient.updateProduct(productUpdateRequest) - assertEquals(1, productUpdateResult1.updateCount) - - // Checking that product was successfully updated with necessary parameters - val productDetails2 = apiClient.getProductDetails(productDetailsRequest) - assertEquals( - productUpdateRequest.updatedProduct, - productDetails2.toUpdated().cleanupForComparison(productCreateRequest) - ) - assertEquals(3, productDetails2.categories?.size) - assertTrue( - productDetails2.categories?.contains( - FetchedProduct.CategoryInfo( - id = categoryCreateResult1.id, - enabled = true - ) - ) - ?: false - ) - assertTrue( - productDetails2.categories?.contains( - FetchedProduct.CategoryInfo( - id = categoryCreateResult2.id, - enabled = true - ) - ) - ?: false - ) - assertTrue( - productDetails2.categories?.contains( - FetchedProduct.CategoryInfo( - id = categoryCreateResult3.id, - enabled = true - ) - ) - ?: false - ) - - // Deleting product - val productDeleteRequest = ProductDeleteRequest(productId = productDetails1.id) - val productDeleteResult = apiClient.deleteProduct(productDeleteRequest) - assertEquals(1, productDeleteResult.deleteCount) - - // Checking that deleted product is not accessible anymore - try { - apiClient.getProductDetails(productDetailsRequest) - } catch (e: EcwidApiException) { - assertEquals(404, e.statusCode) - assertEquals("Product #${productCreateResult.id} not found", e.message) - } - } - - @Test - fun testSearchByIds() { - // Creating three new products - val productCreateRequest1 = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}", - sku = "testSearchByIds1" - ) - ) - val productCreateRequest2 = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}", - sku = "testSearchByIds2" - ) - ) - val productCreateRequest3 = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}", - sku = "testSearchByIds3" - ) - ) - - val productCreateResult1 = apiClient.createProduct(productCreateRequest1) - assertTrue(productCreateResult1.id > 0) - - val productCreateResult2 = apiClient.createProduct(productCreateRequest2) - assertTrue(productCreateResult2.id > 0) - - val productCreateResult3 = apiClient.createProduct(productCreateRequest3) - assertTrue(productCreateResult3.id > 0) - - // Verifying that we will get two products if search request contains two product IDs - val productsSearchRequest = ByIds( - listOf(productCreateResult1.id, productCreateResult2.id) - ) - val productsSearchResult = apiClient.searchProducts(productsSearchRequest) - assertEquals(2, productsSearchResult.items.size) - } - - @Test - fun testUpdateProductInventory() { - // Creating new product - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product " + randomAlphanumeric(8), - sku = "testUpdateProductInventory", - quantity = 10 - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - // Checking that product was successfully created with necessary quantity - val productDetailsRequest = ProductDetailsRequest(productId = productCreateResult.id) - val productDetails1 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(10, productDetails1.quantity) - - // Increasing product quantity - val productInventoryUpdateRequest1 = ProductInventoryUpdateRequest( - productId = productCreateResult.id, - inventoryAdjustment = InventoryAdjustment(5) - ) - val productInventoryUpdateResult1 = apiClient.updateProductInventory(productInventoryUpdateRequest1) - assertEquals(1, productInventoryUpdateResult1.updateCount) - - // Checking that product quantity was successfully updated - val productDetails2 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(15, productDetails2.quantity) - - // Decreasing product quantity - val productInventoryUpdateRequest2 = ProductInventoryUpdateRequest( - productId = productCreateResult.id, - inventoryAdjustment = InventoryAdjustment(-20) - ) - val productInventoryUpdateResult2 = apiClient.updateProductInventory(productInventoryUpdateRequest2) - assertEquals(1, productInventoryUpdateResult2.updateCount) - assertEquals("Product has negative stock.", productInventoryUpdateResult2.warning) - - // Checking that product quantity was successfully updated - val productDetails3 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(-5, productDetails3.quantity) - } - - @Test - @Disabled - fun testGetProductFilters() { - // Create one category - - val categoryCreateRequest = CategoryCreateRequest(newCategory = generateTestCategory()) - val categoryCreateResult = apiClient.createCategory(categoryCreateRequest) - assertTrue(categoryCreateResult.id > 0) - - // Creating some products - - val baseProductSku = "testGetProductFilters" - - val productCreateRequest1 = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product " + randomAlphanumeric(8), - sku = "$baseProductSku 1", - price = 10.0, - quantity = 5, - compareToPrice = 12.0, - categoryIds = listOf( - categoryCreateResult.id - ), - options = listOf( - ProductOption.createSelectOption( - name = "Color", - choices = listOf( - ProductOptionChoice("Red"), - ProductOptionChoice("Green"), - ) - ) - ), - attributes = listOf( - AttributeValue.createBrandAttributeValue("MyBrandName"), - AttributeValue.createUpcAttributeValue("UpcValue1") - ) - ) - ) - val productCreateResult1 = apiClient.createProduct(productCreateRequest1) - assertTrue(productCreateResult1.id > 0) - - val productCreateRequest2 = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product " + randomAlphanumeric(8), - sku = "$baseProductSku 2", - price = 5.0, - quantity = 0, - options = listOf( - ProductOption.createSelectOption( - name = "Color", - choices = listOf( - ProductOptionChoice("Yellow"), - ProductOptionChoice("Green"), - ) - ) - ), - attributes = listOf( - AttributeValue.createBrandAttributeValue("MyBrandName"), - AttributeValue.createUpcAttributeValue("UpcValue2") - ) - ) - ) - val productCreateResult2 = apiClient.createProduct(productCreateRequest2) - assertTrue(productCreateResult2.id > 0) - - // Waiting till product and categories became available for searching - - waitForIndexedCategories( - categoriesSearchRequest = CategoriesSearchRequest( - parentCategoryId = ParentCategory.Root, - ), - desiredCategoriesCount = 1 - ) - waitForIndexedProducts( - productsSearchRequest = ByFilters(keyword = baseProductSku), - desiredProductCount = 2 - ) - - // Perform faceted search - - val getProductFiltersRequest = GetProductFiltersRequest( - filterFields = listOf( - FilterFieldType.Price, - FilterFieldType.Inventory, - FilterFieldType.OnSale, - FilterFieldType.Categories, - FilterFieldType.Option("Color"), - FilterFieldType.Attribute("Brand"), - FilterFieldType.Attribute("UPC"), - ), - filterFacetLimits = mapOf( - FilterFieldType.Option("Color") to FilterFacetLimit.Limit(2) - ), - filterParentCategoryId = FilterCategoryId.Home, - keyword = baseProductSku - ) - val getProductFiltersResult = apiClient.getProductFilters(getProductFiltersRequest) - - // Validate faceted search result - - assertEquals(2, getProductFiltersResult.productCount) - - val filters = getProductFiltersResult.filters - - val priceFilter = filters.price - requireNotNull(priceFilter) - assertEquals(5.0, priceFilter.minValue, 1e-5) - assertEquals(10.0, priceFilter.maxValue, 1e-5) - - val inventoryFilterValues = filters.inventory - requireNotNull(inventoryFilterValues) - assertEquals(2, inventoryFilterValues.values.size) - assertEquals( - InventoryFilterValue(id = "instock", title = "In stock", productCount = 1), - inventoryFilterValues.values[0] - ) - assertEquals( - InventoryFilterValue(id = "outofstock", title = "Out of stock", productCount = 1), - inventoryFilterValues.values[1] - ) - - val onSaleFilterValues = filters.onsale - requireNotNull(onSaleFilterValues) - assertEquals(2, onSaleFilterValues.values.size) - assertEquals( - OnSaleFilterValue(id = "onsale", title = "On sale", productCount = 1), - onSaleFilterValues.values[0] - ) - assertEquals( - OnSaleFilterValue(id = "notonsale", title = "Regular price", productCount = 1), - onSaleFilterValues.values[1] - ) - - // Will be fixed in ECWID-75364 - // val categoriesFilterValues = filters.categories - // requireNotNull(categoriesFilterValues) - // assertEquals(1, categoriesFilterValues.values.size) - // assertEquals( - // CategoriesFilterValue( - // id = categoryCreateResult.id.toLong(), - // title = categoryCreateRequest.newCategory.name ?: "", - // productCount = 1 - // ), - // categoriesFilterValues.values[0] - // ) - - val options = filters.options - requireNotNull(options) - assertEquals(1, options.size) - assertEquals( - OptionFilterValues( - title = "Color", - values = listOf( - OptionFilterValues.OptionFilterValue(title = "Green", productCount = 2), - OptionFilterValues.OptionFilterValue(title = "Red", productCount = 1), - ) - ), - options[GetProductFiltersResult.Option("Color")] - ) - - val attributes = filters.attributes - requireNotNull(attributes) - assertEquals(2, attributes.size) - assertEquals( - AttributeFilterValues( - values = listOf( - AttributeFilterValues.AttributeFilterValue(title = "MyBrandName", productCount = 2), - ) - ), - attributes[GetProductFiltersResult.Attribute("Brand")] - ) - assertEquals( - AttributeFilterValues( - values = listOf( - AttributeFilterValues.AttributeFilterValue(title = "UpcValue1", productCount = 1), - AttributeFilterValues.AttributeFilterValue(title = "UpcValue2", productCount = 1), - ) - ), - attributes[GetProductFiltersResult.Attribute("UPC")] - ) - } - - @Test - @Disabled - fun testManipulateProductImage() { - // Creating new product - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}", - sku = "testManipulateProductImage" - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - // Upload some images from different sources - - val productImageUploadRequest1 = ProductImageUploadRequest( - productId = productCreateResult.id, - fileData = UploadFileData.ExternalUrlData(externalUrl = "https://don16obqbay2c.cloudfront.net/favicons/apple-touch-icon-180x180.png") - ) - val productImageUploadResult1 = apiClient.uploadProductImage(productImageUploadRequest1) - assertTrue(productImageUploadResult1.id > 0) - - val productImageUploadRequest2 = ProductImageUploadRequest( - productId = productCreateResult.id, - fileData = UploadFileData.LocalFileData(file = getTestPngFilePath().toFile()) - ) - val productImageUploadResult2 = apiClient.uploadProductImage(productImageUploadRequest2) - assertTrue(productImageUploadResult2.id > 0) - - val productImageUploadRequest3 = ProductImageUploadRequest( - productId = productCreateResult.id, - fileData = UploadFileData.InputStreamData(stream = FileInputStream(getTestPngFilePath().toFile())) - ) - val productImageUploadResult3 = apiClient.uploadProductImage(productImageUploadRequest3) - assertTrue(productImageUploadResult3.id > 0) - - val productImageUploadRequest4 = ProductImageUploadRequest( - productId = productCreateResult.id, - fileData = UploadFileData.ByteArrayData(bytes = Files.readAllBytes(getTestPngFilePath())) - ) - val productImageUploadResult4 = apiClient.uploadProductImage(productImageUploadRequest4) - assertTrue(productImageUploadResult4.id > 0) - - // Checking that product has main image - val productDetailsRequest = ProductDetailsRequest(productId = productCreateResult.id) - val productDetails1 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(1, productDetails1.media?.images?.size) - assertMediaProductImage( - expectedId = "0", - expectedOrderBy = 0, - expectedIsMain = true, - expectedPathEnd = "/${productImageUploadResult4.id}.png", - productImage = productDetails1.media?.images?.get(0) - ) - - // Now delete product image - - val productImageDeleteRequest = ProductImageDeleteRequest(productId = productCreateResult.id) - val productImageDeleteResult = apiClient.deleteProductImage(productImageDeleteRequest) - assertTrue(productImageDeleteResult.deleteCount > 0) - - // Check that product has now no main image now - val productDetails2 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(0, productDetails2.media?.images?.size) - } - - @Test - fun testManipulateProductGalleryImages() { - // Creating new product - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}", - sku = "testManipulateProductGalleryImages" - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - // Upload gallery images from different sources - - val productGalleryImageUploadRequest1 = ProductGalleryImageUploadRequest( - productId = productCreateResult.id, - fileName = randomFileName("test", "png"), - fileData = UploadFileData.ExternalUrlData(externalUrl = "https://don16obqbay2c.cloudfront.net/favicons/apple-touch-icon-180x180.png") - ) - val productGalleryImageUploadResult1 = apiClient.uploadProductGalleryImage(productGalleryImageUploadRequest1) - assertTrue(productGalleryImageUploadResult1.id > 0) - - val productGalleryImageUploadRequest2 = ProductGalleryImageUploadRequest( - productId = productCreateResult.id, - fileData = UploadFileData.LocalFileData(file = getTestPngFilePath().toFile()) - ) - val productGalleryImageUploadResult2 = apiClient.uploadProductGalleryImage(productGalleryImageUploadRequest2) - assertTrue(productGalleryImageUploadResult2.id > 0) - - val productGalleryImageUploadRequest3 = ProductGalleryImageUploadRequest( - productId = productCreateResult.id, - fileData = UploadFileData.InputStreamData(stream = FileInputStream(getTestPngFilePath().toFile())) - ) - val productGalleryImageUploadResult3 = apiClient.uploadProductGalleryImage(productGalleryImageUploadRequest3) - assertTrue(productGalleryImageUploadResult3.id > 0) - - val productGalleryImageUploadRequest4 = ProductGalleryImageUploadRequest( - productId = productCreateResult.id, - fileData = UploadFileData.ByteArrayData(bytes = Files.readAllBytes(getTestPngFilePath())) - ) - val productGalleryImageUploadResult4 = apiClient.uploadProductGalleryImage(productGalleryImageUploadRequest4) - assertTrue(productGalleryImageUploadResult4.id > 0) - - // Checking that product has gallery images image - - val productDetailsRequest = ProductDetailsRequest(productId = productCreateResult.id) - val productDetails1 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(4, productDetails1.media?.images?.size) - assertMediaProductImage( - expectedId = "0", - expectedOrderBy = 0, - expectedIsMain = true, - expectedPathEnd = null, - productImage = productDetails1.media?.images?.get(0) - ) - assertMediaProductImage( - expectedId = productGalleryImageUploadResult2.id.toString(), - expectedOrderBy = 1, - expectedIsMain = false, - expectedPathEnd = null, - productImage = productDetails1.media?.images?.get(1) - ) - assertMediaProductImage( - expectedId = productGalleryImageUploadResult3.id.toString(), - expectedOrderBy = 2, - expectedIsMain = false, - expectedPathEnd = null, - productImage = productDetails1.media?.images?.get(2) - ) - assertMediaProductImage( - expectedId = productGalleryImageUploadResult4.id.toString(), - expectedOrderBy = 3, - expectedIsMain = false, - expectedPathEnd = null, - productImage = productDetails1.media?.images?.get(3) - ) - - // Changing gallery images order - - val newMedia = ProductMedia( - images = productDetails1.media?.toUpdated()?.images?.map { productImage -> - productImage.copy( - orderBy = if (productImage.id == "0") { - 10 - } else { - productImage.orderBy - } - ) - } - ) - val productUpdateRequest1 = ProductUpdateRequest( - productId = productCreateResult.id, - updatedProduct = UpdatedProduct( - media = newMedia - ) - ) - val productUpdateResult1 = apiClient.updateProduct(productUpdateRequest1) - assertTrue(productUpdateResult1.updateCount > 0) - - val productDetails2 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(4, productDetails2.media?.images?.size) - assertMediaProductImage( - expectedId = "0", // First image became main - expectedOrderBy = 0, - expectedIsMain = true, // First image became main - expectedPathEnd = productDetails1.media?.images?.get(1)?.image1500pxUrl, - productImage = productDetails2.media?.images?.get(0) - ) - assertMediaProductImage( - expectedId = productGalleryImageUploadResult3.id.toString(), - expectedOrderBy = 1, - expectedIsMain = false, - expectedPathEnd = productDetails1.media?.images?.get(2)?.image1500pxUrl, - productImage = productDetails2.media?.images?.get(1) - ) - assertMediaProductImage( - expectedId = productGalleryImageUploadResult4.id.toString(), - expectedOrderBy = 2, - expectedIsMain = false, - expectedPathEnd = productDetails1.media?.images?.get(3)?.image1500pxUrl, - productImage = productDetails2.media?.images?.get(2) - ) - assertMediaProductImage( - expectedId = "4", // This is the moved gallery item, it gets the next vacant id - expectedOrderBy = 3, - expectedIsMain = false, - expectedPathEnd = productDetails1.media?.images?.get(0)?.image1500pxUrl, - productImage = productDetails2.media?.images?.get(3) - ) - - // Now delete one gallery image - val productGalleryImageDeleteRequest = ProductGalleryImageDeleteRequest( - productId = productCreateResult.id, - fileId = productGalleryImageUploadResult3.id - ) - val productGalleryImageDeleteResult = apiClient.deleteProductGalleryImage(productGalleryImageDeleteRequest) - assertTrue(productGalleryImageDeleteResult.deleteCount > 0) - - // Check that product has only three gallery images left - val productDetails3 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(3, productDetails3.media?.images?.size) - - // Now delete all other gallery images (not including main image) - val productGalleryImagesDeleteRequest = ProductGalleryImagesDeleteRequest(productId = productCreateResult.id) - val productGalleryImagesDeleteResult = apiClient.deleteProductGalleryImages(productGalleryImagesDeleteRequest) - assertEquals(2, productGalleryImagesDeleteResult.deleteCount) - - // Check that product has no gallery images left (only main image left) - val productDetails4 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(1, productDetails4.media?.images?.size) - } - - @Test - fun testManipulateProductFiles() { - // Creating new product - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}", - sku = "testManipulateProductFiles" - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - // Upload files from different sources - - val productFileUploadRequest1 = ProductFileUploadRequest( - productId = productCreateResult.id, - fileName = randomFileName("test", "png"), - description = "Description ${randomAlphanumeric(32)}", - fileData = UploadFileData.ExternalUrlData(externalUrl = "https://don16obqbay2c.cloudfront.net/favicons/apple-touch-icon-180x180.png") - ) - val productFileUploadResult1 = apiClient.uploadProductFile(productFileUploadRequest1) - assertTrue(productFileUploadResult1.id > 0) - - val productFileUploadRequest2 = ProductFileUploadRequest( - productId = productCreateResult.id, - fileName = randomFileName("test", "png"), - description = "Description ${randomAlphanumeric(32)}", - fileData = UploadFileData.LocalFileData(file = getTestPngFilePath().toFile()) - ) - val productFileUploadResult2 = apiClient.uploadProductFile(productFileUploadRequest2) - assertTrue(productFileUploadResult2.id > 0) - - val productFileUploadRequest3 = ProductFileUploadRequest( - productId = productCreateResult.id, - fileName = randomFileName("test", "png"), - description = "Description ${randomAlphanumeric(32)}", - fileData = UploadFileData.InputStreamData(stream = FileInputStream(getTestPngFilePath().toFile())) - ) - val productFileUploadResult3 = apiClient.uploadProductFile(productFileUploadRequest3) - assertTrue(productFileUploadResult3.id > 0) - - val productFileUploadRequest4 = ProductFileUploadRequest( - productId = productCreateResult.id, - fileName = randomFileName("test", "png"), - description = "Description ${randomAlphanumeric(32)}", - fileData = UploadFileData.ByteArrayData(bytes = Files.readAllBytes(getTestPngFilePath())) - ) - val productFileUploadResult4 = apiClient.uploadProductFile(productFileUploadRequest4) - assertTrue(productFileUploadResult4.id > 0) - - // Checking that product has necessary files - - val productDetailsRequest = ProductDetailsRequest(productId = productCreateResult.id) - val productDetails1 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(4, productDetails1.files?.size) - assertFile( - expectedProductId = productFileUploadResult1.id, - expectedFileName = productFileUploadRequest1.fileName, - expectedDescription = productFileUploadRequest1.description, - productFile = productDetails1.files?.get(0) - ) - assertFile( - expectedProductId = productFileUploadResult2.id, - expectedFileName = productFileUploadRequest2.fileName, - expectedDescription = productFileUploadRequest2.description, - productFile = productDetails1.files?.get(1) - ) - assertFile( - expectedProductId = productFileUploadResult3.id, - expectedFileName = productFileUploadRequest3.fileName, - expectedDescription = productFileUploadRequest3.description, - productFile = productDetails1.files?.get(2) - ) - assertFile( - expectedProductId = productFileUploadResult4.id, - expectedFileName = productFileUploadRequest4.fileName, - expectedDescription = productFileUploadRequest4.description, - productFile = productDetails1.files?.get(3) - ) - - // Update one product file description - - val productFileUpdateRequest = ProductFileUpdateRequest( - productId = productCreateResult.id, - fileId = productFileUploadResult2.id, - updatedProductFile = ProductFileUpdateRequest.UpdatedProductFile( - description = "Description ${randomAlphanumeric(32)}" - ) - ) - val productFileUpdateResult = apiClient.updateProductFile(productFileUpdateRequest) - assertTrue(productFileUpdateResult.updateCount > 0) - - // Check that product was updated - val productDetails2 = apiClient.getProductDetails(productDetailsRequest) - assertFile( - expectedProductId = productFileUploadResult2.id, - expectedFileName = productFileUploadRequest2.fileName, - expectedDescription = productFileUpdateRequest.updatedProductFile.description, - productFile = productDetails2.files?.get(1) - ) - - // Try to download product file and check its size - val productFileDownloadRequest = ProductFileDownloadRequest( - productId = productCreateResult.id, - fileId = productFileUploadResult2.id - ) - val downloadedProductFileBytes = apiClient.downloadProductFile(productFileDownloadRequest) - assertEquals(getTestPngFilePath().toFile().length(), downloadedProductFileBytes.size.toLong()) - - // Now delete one product file - val productFileDeleteRequest = ProductFileDeleteRequest( - productId = productCreateResult.id, - fileId = productFileUploadResult2.id - ) - val productFileDeleteResult = apiClient.deleteProductFile(productFileDeleteRequest) - assertTrue(productFileDeleteResult.deleteCount > 0) - - // Check that product has only three product files left - val productDetails3 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(3, productDetails3.files?.size) - - // Now delete all other product files - val productFilesDeleteRequest = ProductFilesDeleteRequest(productId = productCreateResult.id) - val productFilesDeleteResult = apiClient.deleteProductFiles(productFilesDeleteRequest) - assertEquals(3, productFilesDeleteResult.deleteCount) - - // Check that product has no product files left - val productDetails4 = apiClient.getProductDetails(productDetailsRequest) - assertEquals(0, productDetails4.files?.size) - } - - @Test - @Disabled("Will be fixed in ECWID-75364") - fun testDeletedProducts() { - // Creating new product - val productCreateRequest = ProductCreateRequest( - newProduct = generateTestProduct() - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - // Deleting product - val productDeleteRequest = ProductDeleteRequest(productId = productCreateResult.id) - val productDeleteResult = apiClient.deleteProduct(productDeleteRequest) - assertEquals(1, productDeleteResult.deleteCount) - - val instant = Date().toInstant() - val instantFrom = instant.minusSeconds(10) - val instantTo = instant.plusSeconds(10) - - // Checking that just deleted product returned from api - val deletedProductsSearchRequest = DeletedProductsSearchRequest( - deletedFrom = Date.from(instantFrom), - deletedTo = Date.from(instantTo) - ) - val deletedProducts = apiClient.searchDeletedProductsAsSequence(deletedProductsSearchRequest) - val deletedProduct = - deletedProducts.firstOrNull { deletedProduct -> deletedProduct.id == productCreateResult.id } - require(deletedProduct != null) - assertTrue(instantFrom.isBefore(deletedProduct.date.toInstant())) - assertTrue(instantTo.isAfter(deletedProduct.date.toInstant())) - } - - @Test - fun testUploadProductImageAsync() { - // Creating new product - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}", - sku = "testUploadProductImageAsync" - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - val productDetailsRequest = ProductDetailsRequest(productId = productCreateResult.id) - val productDetails = apiClient.getProductDetails(productDetailsRequest) - assertEquals(0, productDetails.media?.images?.size) - - val request = ProductImageAsyncUploadRequest( - productId = productCreateResult.id, - asyncPictureData = AsyncPictureData( - url = "https://don16obqbay2c.cloudfront.net/favicons/apple-touch-icon-180x180.png", - width = 180, - height = 180 - ) - ) - apiClient.uploadProductImageAsync(request) - - val productDetailsAfterUpload = apiClient.getProductDetails(productDetailsRequest) - assertEquals(1, productDetailsAfterUpload.media?.images?.size) - - val requestWithBlankUrl = ProductImageAsyncUploadRequest( - productId = productCreateResult.id, - asyncPictureData = AsyncPictureData( - url = " ", - width = 180, - height = 180 - ) - ) - try { - apiClient.uploadProductImageAsync(requestWithBlankUrl) - fail("Request must return error") - } catch (ignore: EcwidApiException) { - // ok - } - - val requestWithWrongUrl = ProductImageAsyncUploadRequest( - productId = productCreateResult.id, - asyncPictureData = AsyncPictureData( - url = "htt://sssss", - width = 180, - height = 180 - ) - ) - try { - apiClient.uploadProductImageAsync(requestWithWrongUrl) - fail("Request must return error") - } catch (ignore: EcwidApiException) { - // ok - } - } - - @Test - fun testUploadProductGalleryImageAsync() { - // Creating new product - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - name = "Product ${randomAlphanumeric(8)}", - sku = "testUploadProductGalleryImageAsync" - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - assertTrue(productCreateResult.id > 0) - - val productDetailsRequest = ProductDetailsRequest(productId = productCreateResult.id) - val productDetails = apiClient.getProductDetails(productDetailsRequest) - assertEquals(0, productDetails.media?.images?.size) - - val request = ProductGalleryImageAsyncUploadRequest( - productId = productCreateResult.id, - asyncPictureData = AsyncPictureData( - url = "https://don16obqbay2c.cloudfront.net/favicons/apple-touch-icon-180x180.png", - width = 180, - height = 180 - ) - ) - apiClient.uploadProductGalleryImageAsync(request) - - val productDetailsAfterUpload = apiClient.getProductDetails(productDetailsRequest) - assertEquals(1, productDetailsAfterUpload.media?.images?.size) - - val requestWithBlankUrl = ProductGalleryImageAsyncUploadRequest( - productId = productCreateResult.id, - asyncPictureData = AsyncPictureData( - url = " ", - width = 180, - height = 180 - ) - ) - try { - apiClient.uploadProductGalleryImageAsync(requestWithBlankUrl) - fail("Request must return error") - } catch (ignore: EcwidApiException) { - // ok - } - - val requestWithWrongUrl = ProductGalleryImageAsyncUploadRequest( - productId = productCreateResult.id, - asyncPictureData = AsyncPictureData( - url = "htt://sssss", - width = 180, - height = 180 - ) - ) - try { - apiClient.uploadProductGalleryImageAsync(requestWithWrongUrl) - fail("Request must return error") - } catch (ignore: EcwidApiException) { - // ok - } - } - - private fun assertProductUrlMatchesRegex(productSearchRequest: ByFilters, urlPattern: String) { - val searchProducts = apiClient.searchProducts(productSearchRequest) - assertEquals(1, searchProducts.total) - - val url = searchProducts.items[0].url ?: "" - assertTrue( - url.matches(Regex(urlPattern)), - "Url '$url' is not matching regex pattern '$urlPattern'" - ) - } - - private fun assertProductsSearch( - positiveProductId: Int, - positiveSearchRequest: ByFilters, - negativeSearchRequest: ByFilters - ) { - val positiveProductsSearchResult = apiClient.searchProducts(positiveSearchRequest) - assertEquals(1, positiveProductsSearchResult.total) - assertEquals(positiveProductId, positiveProductsSearchResult.items[0].id) - - val negativeProductsSearchResult = apiClient.searchProducts(negativeSearchRequest) - assertEquals(0, negativeProductsSearchResult.total) - } - - private fun assertProductsSearch(productSearchRequest: ByFilters, desiredSkus: List) { - val productsSearchResult = apiClient.searchProducts(productSearchRequest) - assertEquals(desiredSkus.size, productsSearchResult.items.size) - assertEquals(desiredSkus.toSet(), productsSearchResult.items.map(FetchedProduct::sku).toSet()) - } - - private fun assertMediaProductImage( - expectedId: String, - expectedOrderBy: Int, - expectedIsMain: Boolean, - expectedPathEnd: String?, - productImage: FetchedProduct.ProductImage? - ) { - assertAll( - { assertEquals(expectedId, productImage?.id, "id mismatch") }, - { assertEquals(expectedOrderBy, productImage?.orderBy, "orderBy mismatch") }, - { assertEquals(expectedIsMain, productImage?.isMain, "isMain mismatch") }, - { - if (expectedPathEnd != null) { - assertEquals( - true, - productImage?.image1500pxUrl?.endsWith(expectedPathEnd), - "image1500pxUrl mismatch" - ) - } - } - ) - } - - private fun assertFile( - expectedProductId: Int, - expectedFileName: String, - expectedDescription: String, - productFile: FetchedProduct.ProductFile? - ) { - assertAll( - { assertEquals(expectedProductId, productFile?.id, "id mismatch") }, - { assertEquals(expectedFileName, productFile?.name, "name mismatch") }, - { assertEquals(expectedDescription, productFile?.description, "description mismatch") }, - { assertTrue((productFile?.size ?: 0) > 0, "wrong size") } - ) - } -} - -private fun generateTestCategory(parentId: Int? = null): UpdatedCategory { - return UpdatedCategory( - name = "Category " + randomAlphanumeric(8), - description = "Description " + randomAlphanumeric(16), - parentId = parentId, - enabled = true - ) -} - -private fun generateTestProduct(categoryIds: List = listOf(), discountsAllowed: Boolean = true): UpdatedProduct { - val basePrice = randomPrice() - val enName = "Product " + randomAlphanumeric(8) - val enDescription = "Description " + randomAlphanumeric(16) - return UpdatedProduct( - name = enName, - nameTranslated = LocalizedValueMap( - "ru" to "Продукт " + randomAlphanumeric(8), - "en" to enName - ), - description = enDescription, - descriptionTranslated = LocalizedValueMap( - "ru" to "Описание " + randomAlphanumeric(16), - "en" to enDescription - ), - sku = "SKU " + randomAlphanumeric(8), - - enabled = randomBoolean(), - quantity = randomByte(), - unlimited = false, // To allow set quantity - warningLimit = randomByte(), - - categoryIds = categoryIds.sorted(), - defaultCategoryId = categoryIds.firstOrNull(), - showOnFrontpage = randomByte(), - - price = basePrice, - costPrice = basePrice * 0.9, - wholesalePrices = listOf( - generateWholesalePrice(basePrice, 2), - generateWholesalePrice(basePrice, 3) - ), - compareToPrice = 2 * basePrice, - - productClassId = 0, // TODO Fill with real productClassId when api client will support it - attributes = listOf( - generateBrandAttributeValue(), - generateUpcAttributeValue() -// generateGeneralAttributeValue(), // TODO Send real product attribute id when api client will support product attribute creation -// generateGeneralAttributeValue() - ), - - weight = randomWeight(), - dimensions = generateDimensions(), - volume = randomVolume(), - shipping = generateShippingSettings(), - isShippingRequired = true, // To allow set weight field - - seoTitle = "SEO Title " + randomAlphanumeric(16), - seoTitleTranslated = LocalizedValueMap( - "ru" to "RU SEO Title " + randomAlphanumeric(16), - "en" to "EN SEO Title " + randomAlphanumeric(16), - ), - seoDescription = "SEO Description " + randomAlphanumeric(16), - seoDescriptionTranslated = LocalizedValueMap( - "ru" to "RU SEO Description " + randomAlphanumeric(16), - "en" to "EN SEO Description " + randomAlphanumeric(16), - ), - - options = listOf( - generateProductSelectOption(), - generateProductSizeOption(), - generateProductRadioOption(), - generateProductCheckboxOption(), - generateProductTextFieldOption(), - generateProductTextAreaOption(), - generateProductDateOption(), - generateProductFilesOption() - ), -// tax = generateTaxInfo(), // TODO Fill with real tax ids when api client will support it - relatedProducts = generateRelatedProducts(), - - isSampleProduct = false, - - tax = TaxInfo(), - - discountsAllowed = discountsAllowed, - subtitle = "Subtitle sample", - ribbon = Ribbon( - "Ribbon", - "#FFFFF" - ), - ribbonTranslated = LocalizedValueMap( - "ru" to "Лейбл", - "en" to "Ribbon" - ), - subtitleTranslated = LocalizedValueMap( - "ru" to "Сабтайтл", - "en" to "Subtitle" - ), - subscriptionSettings = SubscriptionSettings(), - googleProductCategory = NullableUpdatedValue(632), - productCondition = ProductCondition.USED, - externalReferenceId = "EXT_ID_123", - customsHsTariffCode = randomAlphanumeric(10), - ) -} - -private fun generateProductSelectOption(): ProductOption.SelectOption { - val choices = listOf( - generateProductOptionChoice(), - generateProductOptionChoice(), - generateProductOptionChoice() - ) - val enName = "Option " + randomAlphanumeric(8) - return ProductOption.createSelectOption( - name = enName, - nameTranslated = LocalizedValueMap( - "ru" to "Опция " + randomAlphanumeric(8), - "en" to enName - ), - choices = choices, - defaultChoice = randomIndex(choices), - required = randomBoolean() - ) -} - -private fun generateProductSizeOption(): ProductOption.SizeOption { - val choices = listOf( - generateProductOptionChoice(), - generateProductOptionChoice(), - generateProductOptionChoice() - ) - val enName = "Option " + randomAlphanumeric(8) - return ProductOption.createSizeOption( - name = enName, - nameTranslated = LocalizedValueMap( - "ru" to "Опция " + randomAlphanumeric(8), - "en" to enName - ), - choices = choices, - defaultChoice = randomIndex(choices), - required = randomBoolean() - ) -} - -private fun generateProductRadioOption(): ProductOption.RadioOption { - val choices = listOf( - generateProductOptionChoice(), - generateProductOptionChoice(), - generateProductOptionChoice() - ) - val enName = "Option " + randomAlphanumeric(8) - return ProductOption.createRadioOption( - name = enName, - nameTranslated = LocalizedValueMap( - "ru" to "Опция " + randomAlphanumeric(8), - "en" to enName - ), - choices = choices, - defaultChoice = randomIndex(choices), - required = randomBoolean() - ) -} - -private fun generateProductCheckboxOption(): ProductOption.CheckboxOption { - val enName = "Option " + randomAlphanumeric(8) - return ProductOption.createCheckboxOption( - name = enName, - nameTranslated = LocalizedValueMap( - "ru" to "Опция " + randomAlphanumeric(8), - "en" to enName - ), - choices = listOf( - generateProductOptionChoice(), - generateProductOptionChoice(), - generateProductOptionChoice() - ) - ) -} - -private fun generateProductTextFieldOption(): ProductOption.TextFieldOption { - val enName = "Option " + randomAlphanumeric(8) - return ProductOption.createTextFieldOption( - name = enName, - nameTranslated = LocalizedValueMap( - "ru" to "Опция " + randomAlphanumeric(8), - "en" to enName - ), - required = randomBoolean() - ) -} - -private fun generateProductTextAreaOption(): ProductOption.TextAreaOption { - val enName = "Option " + randomAlphanumeric(8) - return ProductOption.createTextAreaOption( - name = enName, - nameTranslated = LocalizedValueMap( - "ru" to "Опция " + randomAlphanumeric(8), - "en" to enName - ), - required = randomBoolean() - ) -} - -private fun generateProductDateOption(): ProductOption.DateOption { - val enName = "Option " + randomAlphanumeric(8) - - return ProductOption.createDateOption( - name = enName, - nameTranslated = LocalizedValueMap( - "ru" to "Опция " + randomAlphanumeric(8), - "en" to enName - ), - required = randomBoolean() - ) -} - -private fun generateProductFilesOption(): ProductOption.FilesOption { - val enName = "Option " + randomAlphanumeric(8) - return ProductOption.createFilesOption( - name = enName, - nameTranslated = LocalizedValueMap( - "ru" to "Опция " + randomAlphanumeric(8), - "en" to enName - ), - required = randomBoolean() - ) -} - -private fun generateProductOptionChoice(): ProductOptionChoice { - val enText = "Option choice " + randomAlphanumeric(8) - return ProductOptionChoice( - text = enText, - textTranslated = LocalizedValueMap( - "ru" to "Выбор опции " + randomAlphanumeric(8), - "en" to enText - ), - priceModifier = randomModifier(), - priceModifierType = randomEnumValue() - ) -} - -fun generateRelatedProducts() = RelatedProducts( - productIds = listOf( -// randomId(), TODO Send real related product ids -// randomId(), -// randomId() - ), - relatedCategory = generateRelatedCategory() -) - -fun generateRelatedCategory(): RelatedCategory = RelatedCategory( - enabled = randomBoolean(), - categoryId = 0, // TODO Send any existing category id when api client will support its creation - productCount = randomByte() -) - -private fun generateShippingSettings() = ShippingSettings( - type = randomEnumValue(), - methodMarkup = randomPrice(), - flatRate = randomPrice(), - disabledMethods = listOf( - randomAlphanumeric(8), - randomAlphanumeric(8), - randomAlphanumeric(8) - ), - enabledMethods = listOf( - randomAlphanumeric(8), - randomAlphanumeric(8), - randomAlphanumeric(8) - ) -) - -private fun generateWholesalePrice(basePrice: Double, divider: Int) = WholesalePrice( - quantity = divider, - price = basePrice / divider -) - -private fun generateBrandAttributeValue(): AttributeValue { - return AttributeValue.createBrandAttributeValue("Attribute value " + randomAlphanumeric(8)) -} - -private fun generateUpcAttributeValue(): AttributeValue { - return AttributeValue.createUpcAttributeValue("Attribute value " + randomAlphanumeric(8)) -} - -private fun generateDimensions() = ProductDimensions( - length = randomDimension(), - width = randomDimension(), - height = randomDimension() -) - -private fun UpdatedProduct.cleanupForComparison(productCreateRequest: ProductCreateRequest): UpdatedProduct { - return copy( - // Password is write only field - attributes = attributes?.mapIndexed { index, attribute -> - val attributeValue = productCreateRequest.newProduct.attributes?.get(index) - attribute.cleanupForComparison(attributeValue) - }, - media = if (media?.images?.isEmpty() != false) null else media, - categoryIds = categoryIds?.sorted(), - subtitle = "Subtitle sample", - ribbon = Ribbon( - "Ribbon", - "#FFFFF" - ), - ribbonTranslated = LocalizedValueMap( - "ru" to "Лейбл", - "en" to "Ribbon" - ), - subtitleTranslated = LocalizedValueMap( - "ru" to "Сабтайтл", - "en" to "Subtitle" - ) - ) -} - -private fun AttributeValue.cleanupForComparison(attributeValue: AttributeValue?): AttributeValue { - return copy( - // Id is not used for BRAND/UPC attributes and can be used for custom attributes - id = if (attributeValue?.alias != null) attributeValue.id else null, - // Alias is write only field - alias = attributeValue?.alias - ) -} - -private fun UpdatedProduct.withUnchangedShowOnFrontend(productCreateRequest: ProductCreateRequest): UpdatedProduct { - return copy( - // TODO Probably API bug (see https://track.ecwid.com/youtrack/issue/ECWID-53048) - showOnFrontpage = productCreateRequest.newProduct.showOnFrontpage - ) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ResponseFieldsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/ResponseFieldsTest.kt deleted file mode 100644 index 99ab9d701..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/ResponseFieldsTest.kt +++ /dev/null @@ -1,59 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.dto.customer.request.CustomerCreateRequest -import com.ecwid.apiclient.v3.dto.customer.request.CustomerDetailsRequest -import com.ecwid.apiclient.v3.dto.customer.request.UpdatedCustomer -import com.ecwid.apiclient.v3.responsefields.newResponseFields -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class ResponseFieldsTest : BaseEntityTest() { - @BeforeEach - override fun beforeEach() { - super.beforeEach() - removeAllCustomers() - } - - @Test - fun testCustomerAndResponseFieldsParam() { - val request = CustomerCreateRequest( - newCustomer = UpdatedCustomer( - email = "test@mail.com", - billingPerson = UpdatedCustomer.BillingPerson( - name = "billing person", - companyName = "company name", - phone = "123456789" - ) - ) - ) - - val result = apiClient.createCustomer(request) - - // Checks the customer was successfully created. - val customerDetailsRequest = CustomerDetailsRequest(customerId = result.id) - val customerDetails = apiClient.getCustomerDetails(customerDetailsRequest) - - Assertions.assertEquals(customerDetails.id, result.id) - Assertions.assertEquals(customerDetails.email, "test@mail.com") - Assertions.assertEquals(customerDetails.billingPerson?.name, "billing person") - Assertions.assertEquals(customerDetails.billingPerson?.companyName, "company name") - Assertions.assertEquals(customerDetails.billingPerson?.phone, "123456789") - - val responseFields = newResponseFields { - field("email") - field("billingPerson") { - field("phone") - } - } - val customerDetailsRequestWithResponseField = - CustomerDetailsRequest(customerId = result.id, responseFields = responseFields) - val customerDetails2 = apiClient.getCustomerDetails(customerDetailsRequestWithResponseField) - - Assertions.assertEquals(customerDetails2.id, 0) - Assertions.assertEquals(customerDetails2.email, "test@mail.com") - Assertions.assertEquals(customerDetails2.billingPerson?.name, null) - Assertions.assertEquals(customerDetails2.billingPerson?.companyName, null) - Assertions.assertEquals(customerDetails2.billingPerson?.phone, "123456789") - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/StorageTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/StorageTest.kt deleted file mode 100644 index e71fc302d..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/StorageTest.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.storage.request.* -import com.ecwid.apiclient.v3.jsontransformer.gson.GsonTransformer -import org.junit.jupiter.api.Assertions.* -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class StorageTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - } - - @Test - fun testStorageApiSingleItemOperations() { - val createApiData = StorageApiData(123, "test") - val key = "key" - val createValue = createApiData.toJson() - val createStorageData = UpdatedStorageData(key = key, value = createValue) - val createRequest = StorageDataCreateRequest(createStorageData) - val createResult = apiClient.createStorageData(createRequest) - assertEquals(1, createResult.updateCount) - - val createdDataRequest = StorageDataRequest(key) - val createdDataResult = apiClient.getStorageData(createdDataRequest) - assertEquals(createStorageData, createdDataResult.toUpdated()) - - val createdData = createdDataResult.value?.let { StorageApiData.fromJson(it) } - assertEquals(createApiData, createdData) - - val updatedStorageData = UpdatedStorageData(key = key, value = null) - val updateRequest = StorageDataUpdateRequest(updatedStorageData) - val updateResult = apiClient.updateStorageData(updateRequest) - assertEquals(1, updateResult.updateCount) - - val updatedDataRequest = StorageDataRequest(key) - val updatedDataResult = apiClient.getStorageData(updatedDataRequest) - assertTrue(updatedDataResult.value.isNullOrEmpty()) - - val deleteRequest = StorageDataDeleteRequest(key) - val deleteResult = apiClient.deleteStorageData(deleteRequest) - assertEquals(1, deleteResult.deleteCount) - } - - @Test - fun testStorageApiMultipleItemsCreation() { - val updatedEntities = listOf( - UpdatedStorageData(key = "key1", value = StorageApiData(123, "test1").toJson()), - UpdatedStorageData(key = "key2", value = StorageApiData(456, "test2").toJson()), - ) - - updatedEntities.forEach { entity -> - val updateRequest = StorageDataUpdateRequest(entity) - val updateResult = apiClient.updateStorageData(updateRequest) - assertEquals(1, updateResult.updateCount) - } - - val storageEntitiesRequest = AllStorageDataRequest() - val storageEntitiesResult = apiClient.getAllStorageData(storageEntitiesRequest) - storageEntitiesResult.forEach { fetchedEntity -> - val updatedEntity = updatedEntities.find { it.key == fetchedEntity.key } - assertNotNull(updatedEntity) - assertEquals(updatedEntity, fetchedEntity.toUpdated()) - } - - updatedEntities.forEach { entity -> - val deleteRequest = StorageDataDeleteRequest(entity.key) - val deleteResult = apiClient.deleteStorageData(deleteRequest) - assertEquals(1, deleteResult.deleteCount) - } - } - - private data class StorageApiData( - val number: Int = 0, - val string: String = "", - ) { - fun toJson(): String { - return transformer.serialize(this, null) - } - - companion object { - private val transformer = GsonTransformer(emptyList()) - - fun fromJson(json: String): StorageApiData? { - return transformer.deserialize(json, StorageApiData::class.java) - } - } - } - -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/StoreProfileTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/StoreProfileTest.kt deleted file mode 100644 index 75977c6dd..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/StoreProfileTest.kt +++ /dev/null @@ -1,322 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.common.ProductCondition -import com.ecwid.apiclient.v3.dto.profile.enums.ProductFilterType -import com.ecwid.apiclient.v3.dto.profile.request.StoreProfileRequest -import com.ecwid.apiclient.v3.dto.profile.request.StoreProfileUpdateRequest -import com.ecwid.apiclient.v3.dto.profile.request.UpdatedStoreProfile -import com.ecwid.apiclient.v3.dto.profile.result.FetchedStoreProfile -import com.ecwid.apiclient.v3.util.PropertiesLoader -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class StoreProfileTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - } - - @Test - fun testStoreProfile() { - val testStoreId = PropertiesLoader.load().storeId - - val expectedProfile = UpdatedStoreProfile( - generalInfo = UpdatedStoreProfile.GeneralInfo( - storeUrl = "https://www.mysite.com", - starterSite = UpdatedStoreProfile.InstantSiteInfo( - ecwidSubdomain = "bobyor", - customDomain = "example.com" - ), - websitePlatform = UpdatedStoreProfile.WebsitePlatform.wordpress - ), - account = UpdatedStoreProfile.Account( - accountName = "The Bobyør", - accountNickName = "bobyør", - accountEmail = "bobyor@example.com" - ), - settings = UpdatedStoreProfile.Settings( - closed = true, - storeName = "Test store for ecwid-java-api-client", - storeDescription = "Test Store Description for ecwid-java-api-client", - googleRemarketingEnabled = true, - googleAnalyticsId = "googleAnalyticsId", - fbPixelId = "fbPixelId", - orderCommentsEnabled = true, - orderCommentsCaption = "orderCommentsCaption", - orderCommentsRequired = true, - hideOutOfStockProductsInStorefront = true, - askCompanyName = true, - favoritesEnabled = true, - defaultProductSortOrder = UpdatedStoreProfile.ProductSortOrder.NAME_ASC, - abandonedSales = UpdatedStoreProfile.AbandonedSalesSettings( - autoAbandonedSalesRecovery = true - ), - salePrice = UpdatedStoreProfile.SalePriceSettings( - displayOnProductList = true, - oldPriceLabel = "oldPriceLabel", - displayDiscount = UpdatedStoreProfile.SalePriceSettings.DisplayDiscount.PERCENT - ), - showAcceptMarketingCheckbox = true, - acceptMarketingCheckboxDefaultValue = true, - acceptMarketingCheckboxCustomText = "acceptMarketingCheckboxCustomText", - askConsentToTrackInStorefront = true, - snapPixelId = "snapPixelId", - pinterestTagId = "pinterestTagId", - googleTagId = "googleTagId", - googleEventId = "googleEventId", - showPricePerUnit = true, - googleProductCategory = 632, - productCondition = ProductCondition.USED, - tikTokPixel = UpdatedStoreProfile.TikTokPixelSettings( - advancedMatching = true - ) - ), - mailNotifications = UpdatedStoreProfile.MailNotifications( - adminNotificationEmails = listOf("admin@example.com", "admin2@example.com"), - customerNotificationFromEmail = "customerfrom@example.com" - ), - company = UpdatedStoreProfile.Company( - companyName = "companyName", - email = "email@example.com", - street = "street", - city = "city", - countryCode = "GE", - postalCode = "postalCode", - phone = "phone", - stateOrProvinceCode = "TB" - ), - formatsAndUnits = UpdatedStoreProfile.FormatsAndUnits( - currency = "currency", - currencyPrefix = "currencyPrefix", - currencySuffix = "currencySuffix", - currencyGroupSeparator = "G", - currencyDecimalSeparator = "D", - currencyTruncateZeroFractional = true, - currencyRate = 1.23, - weightUnit = UpdatedStoreProfile.WeightUnit.GRAM, - weightPrecision = 2, - weightGroupSeparator = "R", - weightDecimalSeparator = "E", - weightTruncateZeroFractional = true, - dateFormat = "yyyy/MM/dd", - timeFormat = "HH:mm:ss", - timezone = "timezone", - dimensionsUnit = UpdatedStoreProfile.DimensionUnit.MM, - volumeUnit = UpdatedStoreProfile.VolumeUnit.L, - orderNumberPrefix = "orderNumberPrefix", - orderNumberSuffix = "orderNumberSuffix" - ), - languages = UpdatedStoreProfile.Languages( - enabledLanguages = listOf("en", "ru"), - defaultLanguage = "ru" - ), - shipping = UpdatedStoreProfile.Shipping( - handlingFee = UpdatedStoreProfile.HandlingFee( - name = "fee", - value = 123.0, - description = "fee descr" - ) - ), - taxSettings = UpdatedStoreProfile.TaxSettings( - automaticTaxEnabled = true, - taxes = listOf( - UpdatedStoreProfile.TaxSettings.Taxes( - id = 100, - name = "tax-name", - enabled = true, - includeInPrice = true, - useShippingAddress = true, - taxShipping = true, - appliedByDefault = true, - rules = listOf( - UpdatedStoreProfile.TaxSettings.TaxRule( - zoneId = "zoneId", - tax = 14.0 - ) - ), - defaultTax = 12.0 - ) - ), - pricesIncludeTax = false, - taxExemptBusiness = false - ), - zones = listOf( - UpdatedStoreProfile.Zone( - id = "zoneId", - name = "Zone name", - countryCodes = listOf("GE", "UA"), - stateOrProvinceCodes = listOf("GE-AJ", "GE-TB"), - postCodes = listOf("123456", "654321") - ) - ), - businessRegistrationID = UpdatedStoreProfile.BusinessRegistrationID( - name = "businessRegistrationID", - value = "busines-value" - ), - legalPagesSettings = UpdatedStoreProfile.LegalPagesSettingsDetails( - requireTermsAgreementAtCheckout = true, - legalPages = listOf( - UpdatedStoreProfile.LegalPagesInfo( - type = UpdatedStoreProfile.LegalPagesInfo.Type.LEGAL_INFO, - enabled = true, - title = "page title", - display = UpdatedStoreProfile.LegalPagesInfo.Display.EXTERNAL_URL, - text = "page text", - externalUrl = "page url" - ) - ) - ), - productFiltersSettings = UpdatedStoreProfile.ProductFiltersSettings( - enabledInStorefront = true, - filterSections = createTestFilterSections(), - ), - orderInvoiceSettings = UpdatedStoreProfile.OrderInvoiceSettings( - displayOrderInvoices = true, - attachInvoiceToOrderEmailNotifications = UpdatedStoreProfile.OrderInvoiceSettings.AttachValue.ATTACH_TO_ALL_EMAILS, - invoiceLogoUrl = "invoice.logo.url" - ) - ) - - val updateResult = apiClient.updateStoreProfile(StoreProfileUpdateRequest(expectedProfile)) - - assertTrue(updateResult.success) - assertEquals(1, updateResult.updateCount) - - val actualProfile = apiClient.getStoreProfile(StoreProfileRequest()) - - val generalInfo = actualProfile.generalInfo - require(generalInfo != null) - - val starterSite = generalInfo.starterSite - require(starterSite != null) - - val account = actualProfile.account - require(account != null) - - val settings = actualProfile.settings - require(settings != null) - - val salePrice = settings.salePrice - require(salePrice != null) - - val availableFeatures = account.availableFeatures - require(availableFeatures != null) - - val abandonedSales = settings.abandonedSales - require(abandonedSales != null) - - val designSettings = actualProfile.designSettings - require(designSettings != null) - - val formatsAndUnits = actualProfile.formatsAndUnits - require(formatsAndUnits != null) - - assertEquals(testStoreId, generalInfo.storeId) - assertEquals("bobyor", starterSite.ecwidSubdomain) - assertEquals("example.com", starterSite.customDomain) - assertEquals("https://bobyor.company.site", starterSite.generatedUrl) - assertEquals("https://www.mysite.com", generalInfo.storeUrl) - assertEquals(FetchedStoreProfile.WebsitePlatform.wordpress, generalInfo.websitePlatform) - - assertEquals("The Bobyør", account.accountName) - assertEquals("bobyør", account.accountNickName) - assertEquals("bobyor@example.com", account.accountEmail) - assertTrue(availableFeatures.contains("API")) - assertEquals(false, account.whiteLabel) - - assertEquals(true, settings.closed) - assertEquals("Test store for ecwid-java-api-client", settings.storeName) - assertEquals("Test Store Description for ecwid-java-api-client", settings.storeDescription) - assertEquals(true, settings.googleRemarketingEnabled) - assertEquals("googleAnalyticsId", settings.googleAnalyticsId) - assertEquals("fbPixelId", settings.fbPixelId) - assertEquals(true, settings.orderCommentsEnabled) - assertEquals("orderCommentsCaption", settings.orderCommentsCaption) - assertEquals(true, settings.orderCommentsRequired) - assertEquals(true, settings.hideOutOfStockProductsInStorefront) - assertEquals(true, settings.askCompanyName) - assertEquals(true, settings.favoritesEnabled) - assertEquals(FetchedStoreProfile.ProductSortOrder.NAME_ASC, settings.defaultProductSortOrder) - - assertEquals(true, abandonedSales.autoAbandonedSalesRecovery) - - assertEquals(true, salePrice.displayOnProductList) - assertEquals("oldPriceLabel", salePrice.oldPriceLabel) - assertEquals(FetchedStoreProfile.SalePriceSettings.DisplayDiscount.PERCENT, salePrice.displayDiscount) - - assertEquals(true, settings.showAcceptMarketingCheckbox) - assertEquals(true, settings.acceptMarketingCheckboxDefaultValue) - assertEquals("acceptMarketingCheckboxCustomText", settings.acceptMarketingCheckboxCustomText) - assertEquals(true, settings.askConsentToTrackInStorefront) - assertEquals("snapPixelId", settings.snapPixelId) - assertEquals("pinterestTagId", settings.pinterestTagId) - assertEquals("googleTagId", settings.googleTagId) - assertEquals("googleEventId", settings.googleEventId) - assertEquals(true, settings.showPricePerUnit) - - // Checking field with custom name and annotation @JsonFieldName - assertEquals("MEDIUM", designSettings.productListImageSize) - - assertEquals(632, settings.googleProductCategory) - assertEquals(ProductCondition.USED, settings.productCondition) - - val tikTokPixel = settings.tikTokPixel - require(tikTokPixel != null) - assertTrue(tikTokPixel.advancedMatching) - - assertEquals(FetchedStoreProfile.VolumeUnit.L, formatsAndUnits.volumeUnit) - - assertEquals( - expectedProfile.productFiltersSettings, - actualProfile.productFiltersSettings.toUpdated() - ) - } - - private fun createTestFilterSections() = listOf( - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.IN_STOCK, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.ON_SALE, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.PRICE, - enabled = false, - ), - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.CATEGORIES, - enabled = false, - ), - UpdatedStoreProfile.ProductFilterItem( - type = ProductFilterType.SEARCH, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - name = "Option 1", - type = ProductFilterType.OPTION, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - name = "Option 2", - type = ProductFilterType.OPTION, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - name = "Attribute 2", - type = ProductFilterType.ATTRIBUTE, - enabled = true, - ), - UpdatedStoreProfile.ProductFilterItem( - name = "Attribute 1", - type = ProductFilterType.ATTRIBUTE, - enabled = true, - ), - ) - -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/entity/VariationsTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/entity/VariationsTest.kt deleted file mode 100644 index 2000960d9..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/entity/VariationsTest.kt +++ /dev/null @@ -1,360 +0,0 @@ -package com.ecwid.apiclient.v3.entity - -import com.ecwid.apiclient.v3.converter.toUpdated -import com.ecwid.apiclient.v3.dto.common.AsyncPictureData -import com.ecwid.apiclient.v3.dto.common.UploadFileData -import com.ecwid.apiclient.v3.dto.product.enums.PriceModifierType -import com.ecwid.apiclient.v3.dto.product.request.ProductCreateRequest -import com.ecwid.apiclient.v3.dto.product.request.ProductDetailsRequest -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct -import com.ecwid.apiclient.v3.dto.variation.request.* -import com.ecwid.apiclient.v3.util.* -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class VariationsTest : BaseEntityTest() { - - @BeforeEach - override fun beforeEach() { - super.beforeEach() - - // We need to start from scratch each time - removeAllCategories() - removeAllVariations() - removeAllProducts() - } - - @Test - fun `Create product, add combo and fetch product`() { - // Create one product - val productPrice = randomPrice() - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - price = productPrice, - name = "Product ${randomAlphanumeric(8)}", - sku = "testAddVariations", - options = listOf( - generateProductSelectOption("Size", listOf("S", "M", "L")) - ) - ) - ) - - val productCreateResult = apiClient.createProduct(productCreateRequest) - val newProductId = productCreateResult.id - assertTrue(newProductId > 0) - - val testVariationSku = "testVariation" - val testVariationPrice = randomPrice() - val testVariationCostPrice = testVariationPrice * 0.9 - val testVariationWeight = randomWeight() - val testVariationDimensions = generateDimensions() - val testVariationVolume = randomVolume() - val testVariationCustomsHsTariffCode = randomAlphanumeric(10) - val createProductVariationRequest = CreateProductVariationRequest( - productId = newProductId, - newVariation = UpdatedVariation( - sku = testVariationSku, - quantity = 2, - isShippingRequired = true, - price = testVariationPrice, - costPrice = testVariationCostPrice, - weight = testVariationWeight, - dimensions = testVariationDimensions, - volume = testVariationVolume, - options = listOf( - UpdatedVariation.Option( - name = "Size", - value = "L" - ) - ), - customsHsTariffCode = testVariationCustomsHsTariffCode, - ) - ) - - val createProductVariationResult = apiClient.createProductVariation(createProductVariationRequest) - assertTrue(createProductVariationResult.id > 0) - - val fetchedProduct = apiClient.getProductDetails(ProductDetailsRequest(productId = newProductId)) - val variations = fetchedProduct.combinations - require(variations != null) - val variation = variations.first() - assertEquals(testVariationPrice, variation.price) - assertEquals(testVariationCostPrice, variation.costPrice) - assertEquals(testVariationWeight, variation.weight) - assertEquals(testVariationDimensions, variation.toUpdated().dimensions) - assertEquals(testVariationVolume, variation.volume) - assertEquals(testVariationSku, variation.sku) - assertEquals(testVariationCustomsHsTariffCode, variation.customsHsTariffCode) - } - - @Test - fun `manipulate variations`() { - // Create one product - val productPrice = randomPrice() - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - price = productPrice, - name = "Product ${randomAlphanumeric(8)}", - sku = "testVariations", - quantity = 10, - options = listOf( - generateProductSelectOption("Size", listOf("S", "M", "L")) - ) - ) - ) - - val productCreateResult = apiClient.createProduct(productCreateRequest) - val newProductId = productCreateResult.id - assertTrue(newProductId > 0) - - // add 1st variation - val createProductVariationRequest = CreateProductVariationRequest( - productId = newProductId, - newVariation = UpdatedVariation( - sku = "first test Variation", - quantity = 2, - isShippingRequired = true, - price = 51.2, - costPrice = 46.6, - weight = 16.7, - dimensions = generateDimensions(), - volume = 16.0, - options = listOf( - UpdatedVariation.Option( - name = "Size", - value = "L" - ) - ), - customsHsTariffCode = "123456", - ) - ) - - val create1stVariationResult = apiClient.createProductVariation(createProductVariationRequest) - assertTrue(create1stVariationResult.id > 0) - - // add second variation - val create2ndProductVariationRequest = CreateProductVariationRequest( - productId = newProductId, - newVariation = UpdatedVariation( - sku = "second test Variation", - quantity = 9, - isShippingRequired = false, - price = 100.0, - weight = 15.0, - options = listOf( - UpdatedVariation.Option( - name = "Size", - value = "S" - ) - ) - ) - ) - val create2ndVariationResult = apiClient.createProductVariation(create2ndProductVariationRequest) - assertTrue(create2ndVariationResult.id > 0) - - // update 1st variation - val newDimensions = generateDimensions() - val update1stVariationRequest = UpdateProductVariationRequest( - productId = newProductId, - variationId = create1stVariationResult.id, - variation = UpdatedVariation( - sku = "modified first test Variation", - quantity = 15, - costPrice = 47.2, - dimensions = newDimensions, - volume = 15.25, - customsHsTariffCode = "654321", - ) - ) - val updateResult = apiClient.updateProductVariation(update1stVariationRequest) - assertEquals(1, updateResult.updateCount) - - // change inventory of 2nd variation - val change2ndVariationInventoryRequest = AdjustVariationInventoryRequest( - productId = newProductId, - variationId = create2ndVariationResult.id, - quantityDelta = -4 - ) - val adjustResult = apiClient.adjustVariationInventory(change2ndVariationInventoryRequest) - assertEquals(1, adjustResult.updateCount) - - // get all variations to check inventory and sku - val allVariationsResult = apiClient.getAllProductVariations(ProductVariationsRequest(productId = newProductId)) - assertEquals(2, allVariationsResult.size) - val (firstVar, secondVar) = allVariationsResult - assertEquals(create1stVariationResult.id, firstVar.id) - assertEquals("modified first test Variation", firstVar.sku) - assertEquals(15, firstVar.quantity) - assertEquals(47.2, firstVar.costPrice) - assertEquals(newDimensions, firstVar.toUpdated().dimensions) - assertEquals(15.25, firstVar.volume) - assertEquals("654321", firstVar.customsHsTariffCode) - assertEquals(create2ndVariationResult.id, secondVar.id) - assertEquals("second test Variation", secondVar.sku) - @Suppress("CommentWrapping") - assertEquals(5 /* = 9 - 4 */, secondVar.quantity) - - // delete 1st variation - val delete1stVariationRequest = - DeleteProductVariationRequest(productId = newProductId, variationId = create1stVariationResult.id) - val delete1stVariationResult = apiClient.deleteProductVariation(delete1stVariationRequest) - assertEquals(1, delete1stVariationResult.deleteCount) - - // ensure 1st variation is deleted, but 2nd is still there - val anotherAllVariationsResult = - apiClient.getAllProductVariations(ProductVariationsRequest(productId = newProductId)) - assertEquals(1, anotherAllVariationsResult.size) - assertEquals(create2ndVariationResult.id, anotherAllVariationsResult.first().id) - } - - @Test - fun manipulateVariationImage() { - // Create one product, basically, redo same test as above, but with another option type - val productPrice = randomPrice() - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - price = productPrice, - name = "Product ${randomAlphanumeric(8)}", - sku = "testProduct1", - options = listOf( - generateProductRadioOption("Test", listOf("1", "2", "3", "4", "5")) - ) - ) - ) - - val productCreateResult = apiClient.createProduct(productCreateRequest) - val newProductId = productCreateResult.id - assertTrue(newProductId > 0) - - val testVariationPrice = randomPrice() - val testVariationWeight = randomWeight() - val createProductVariationRequest = CreateProductVariationRequest( - productId = newProductId, - newVariation = UpdatedVariation( - sku = "testVariation1", - quantity = 2, - price = testVariationPrice, - weight = testVariationWeight, - options = listOf( - UpdatedVariation.Option( - name = "Test", - value = "5" - ) - ) - ) - ) - - val createProductVariationResult = apiClient.createProductVariation(createProductVariationRequest) - val newVariationId = createProductVariationResult.id - assertTrue(newVariationId > 0) - - val fetchedProduct = apiClient.getProductDetails(ProductDetailsRequest(productId = newProductId)) - val variations = fetchedProduct.combinations - require(variations != null) - val variation = variations.first() - assertEquals(testVariationPrice, variation.price) - assertEquals(testVariationWeight, variation.weight) - assertEquals("testVariation1", variation.sku) - - // Now create image for variation and then delete it - val createProductVariationImageRequest = ProductVariationImageUploadRequest( - productId = newProductId, - variationId = newVariationId, - fileData = UploadFileData.ExternalUrlData(externalUrl = "https://don16obqbay2c.cloudfront.net/favicons/apple-touch-icon-180x180.png") - ) - val createProductVariationImageResult = apiClient.uploadVariationImage(createProductVariationImageRequest) - assertTrue(createProductVariationImageResult.id > 0) - - val productVariationDetailsRequest = ProductVariationDetailsRequest( - productId = newProductId, - variationId = newVariationId - ) - val fetchedVariation1 = apiClient.getProductVariation(productVariationDetailsRequest) - Assertions.assertNotNull(fetchedVariation1.imageUrl) - - // Now delete category image - val deleteProductVariationImageRequest = ProductVariationImageDeleteRequest( - productId = newProductId, - variationId = newVariationId - ) - val deleteProductVariationImageResult = apiClient.deleteVariationImage(deleteProductVariationImageRequest) - assertTrue(deleteProductVariationImageResult.deleteCount > 0) - - // Check that category has now no main image now - val fetchedVariation2 = apiClient.getProductVariation(productVariationDetailsRequest) - Assertions.assertNull(fetchedVariation2.imageUrl) - } - - @Test - fun `test uploading product variation image asynchronously`() { - val productPrice = randomPrice() - val productCreateRequest = ProductCreateRequest( - newProduct = UpdatedProduct( - price = productPrice, - name = "Product ${randomAlphanumeric(8)}", - sku = "testVariationImageUploadAsync", - options = listOf(generateProductRadioOption("Test", listOf("1", "2", "3", "4", "5"))) - ) - ) - val productCreateResult = apiClient.createProduct(productCreateRequest) - val newProductId = productCreateResult.id - val testVariationPrice = randomPrice() - val testVariationWeight = randomWeight() - val createProductVariationRequest = CreateProductVariationRequest( - productId = newProductId, - newVariation = UpdatedVariation( - sku = "testVariation1", - quantity = 2, - price = testVariationPrice, - weight = testVariationWeight, - options = listOf(UpdatedVariation.Option(name = "Test", value = "5")) - ) - ) - val createProductVariationResult = apiClient.createProductVariation(createProductVariationRequest) - val newVariationId = createProductVariationResult.id - val uploadImageAsyncReq = ProductVariationImageAsyncUploadRequest( - productId = newProductId, - variationId = newVariationId, - asyncPictureData = AsyncPictureData("https://example.com/dummy.jpg", 100, 200) - ) - apiClient.uploadProductVariationImageAsync(uploadImageAsyncReq) - val fetchedProduct = apiClient.getProductDetails(ProductDetailsRequest(productId = newProductId)) - val variations = fetchedProduct.combinations - assertEquals(variations?.size, 1) - assertEquals(variations?.get(0)?.originalImageUrl, uploadImageAsyncReq.asyncPictureData.url) - } - -} - -private fun generateProductSelectOption(name: String, values: List): UpdatedProduct.ProductOption { - val choices = values.map { generateProductOptionChoice(it) } - return UpdatedProduct.ProductOption.createSelectOption( - name = name, - choices = choices, - defaultChoice = randomIndex(choices), - required = randomBoolean() - ) -} - -private fun generateProductOptionChoice(value: String) = UpdatedProduct.ProductOptionChoice( - text = value, - priceModifier = randomModifier(), - priceModifierType = randomEnumValue() -) - -private fun generateProductRadioOption(name: String, values: List): UpdatedProduct.ProductOption.RadioOption { - val choices = values.map { generateProductOptionChoice(it) } - return UpdatedProduct.ProductOption.createRadioOption( - name = name, - choices = choices - ) -} - -private fun generateDimensions() = UpdatedVariation.ProductDimensions( - length = randomDimension(), - width = randomDimension(), - height = randomDimension() -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/GsonTransformerTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/GsonTransformerTest.kt deleted file mode 100644 index 780d29497..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/jsontransformer/gson/GsonTransformerTest.kt +++ /dev/null @@ -1,275 +0,0 @@ -package com.ecwid.apiclient.v3.jsontransformer.gson - -import com.ecwid.apiclient.v3.dto.common.NullableUpdatedValue -import com.ecwid.apiclient.v3.dto.order.request.UpdatedOrder -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct -import com.ecwid.apiclient.v3.impl.ParsedResponseWithExt -import com.google.gson.JsonParser -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -internal class GsonTransformerTest { - - private val transformer = GsonTransformer(emptyList()) - - @Test - fun `test serialization with extension - top level fields`() { - val order = UpdatedOrder( - email = "original@gmail.com", - total = 12.34 - ) - - val orderExt = OrderExt( - email = "replaced@gmail.com", - simpleExtraField = "simple extra field value 1", - complexExtraField = ComplexExtraField("complex extra field value 1") - ) - - assertJsonEquals( - """ - { - "email": "replaced@gmail.com", - "total": 12.34, - "simpleExtraField": "simple extra field value 1", - "complexExtraField": { "value": "complex extra field value 1" } - } - """.trimIndent(), - transformer.serialize(order, orderExt) - ) - } - - @Test - fun `test serialization with extension - deep level fields`() { - val order = UpdatedOrder( - items = listOf( - UpdatedOrder.OrderItem( - price = 1.56, - sku = "SKU_TO_BE_REPLACED" - ) - ) - ) - - val orderExt = OrderExt( - items = listOf( - OrderItemExt( - sku = "REPLACED_SKU", - simpleExtraField = "simple extra field value 3", - complexExtraField = ComplexExtraField("complex extra field value 3") - ) - ) - ) - - assertJsonEquals( - """ - { - "items": [ - { - "price": 1.56, - "sku": "REPLACED_SKU", - "simpleExtraField": "simple extra field value 3", - "complexExtraField": { "value": "complex extra field value 3" } - } - ] - } - """.trimIndent(), - transformer.serialize(order, orderExt) - ) - } - - @Test - fun `test serialization with extension - deep level fields - no original`() { - val order = UpdatedOrder() - - val orderExt = OrderExt( - items = listOf( - OrderItemExt( - sku = "SKU1", - simpleExtraField = "simple extra field value 2", - complexExtraField = ComplexExtraField("complex extra field value 2") - ) - ) - ) - - assertJsonEquals( - """ - { - "items": [ - { - "sku": "SKU1", - "simpleExtraField": "simple extra field value 2", - "complexExtraField": { "value": "complex extra field value 2" } - } - ] - } - """.trimIndent(), - transformer.serialize(order, orderExt) - ) - } - - @Test - fun `test serialization with extension - deep level fields - original array longer than ext`() { - val order = UpdatedOrder( - items = listOf( - UpdatedOrder.OrderItem(sku = "SKU_TO_BE_REPLACED"), - UpdatedOrder.OrderItem(sku = "SKU_TO_BE_UNTOUCHED") - ) - ) - - val orderExt = OrderExt( - items = listOf( - OrderItemExt(sku = "REPLACED_SKU") - ) - ) - - assertJsonEquals( - """ - { - "items": [ - { - "sku": "REPLACED_SKU" - }, - { - "sku": "SKU_TO_BE_UNTOUCHED" - } - ] - } - """.trimIndent(), - transformer.serialize(order, orderExt) - ) - } - - @Test - fun `test serialization with extension - deep level fields - original array shorter than ext`() { - val order = UpdatedOrder( - items = listOf( - UpdatedOrder.OrderItem(sku = "SKU_TO_BE_REPLACED") - ) - ) - - val orderExt = OrderExt( - items = listOf( - OrderItemExt(sku = "REPLACED_SKU"), - OrderItemExt(sku = "SKU_TO_BE_APPENDED") - ) - ) - - assertJsonEquals( - """ - { - "items": [ - { - "sku": "REPLACED_SKU" - }, - { - "sku": "SKU_TO_BE_APPENDED" - } - ] - } - """.trimIndent(), - transformer.serialize(order, orderExt) - ) - } - - @Test - fun `test serialization with NullableUpdatedValue`() { - var product = UpdatedProduct( - name = "Test product", - googleProductCategory = null, - ) - - assertJsonEquals( - """ - { - "name": "Test product" - } - """.trimIndent(), - transformer.serialize(product, null) - ) - - product = product.copy(googleProductCategory = NullableUpdatedValue(null)) - - assertJsonEquals( - """ - { - "name": "Test product", - "googleProductCategory": null - } - """.trimIndent(), - transformer.serialize(product, null) - ) - - product = product.copy(googleProductCategory = NullableUpdatedValue(666)) - - assertJsonEquals( - """ - { - "name": "Test product", - "googleProductCategory": 666 - } - """.trimIndent(), - transformer.serialize(product, null) - ) - } - - @Test - fun `test deserialization of ParsedResponseWithExt`() { - val json = "{'testField': {'baseField': 'base', 'extField': 'ext'}}" - val deserializedValue = transformer.deserialize(json, TestParsedResponseWithExt::class.java) - assertEquals( - TestParsedResponseWithExt( - testField = ParsedResponseWithExt( - baseResult = TestParsedResponseWithExt.TestBaseResult( - baseField = "base" - ), - extResult = TestParsedResponseWithExt.TestExtResult( - extField = "ext" - ), - ) - ), - deserializedValue - ) - } - - @Test - fun `deserializeOrNull of broken ParsedResponseWithExt`() { - val json = "'testField': {'baseField': 'base', 'extField': 'ext'}}" - val deserializedValue = transformer.deserializeOrNull(json, TestParsedResponseWithExt::class.java) - assertEquals(null, deserializedValue) - } - -} - -private fun assertJsonEquals(expected: String, actual: String) { - val expectedJson = JsonParser.parseString(expected) - val actualJson = JsonParser.parseString(actual) - assertEquals(expectedJson, actualJson) -} - -private data class OrderExt( - var email: String? = null, - var simpleExtraField: String? = null, - var complexExtraField: ComplexExtraField? = null, - var items: List? = null -) - -private data class OrderItemExt( - var sku: String? = null, - var simpleExtraField: String? = null, - var complexExtraField: ComplexExtraField? = null -) - -private data class ComplexExtraField(val value: String? = null) - -private data class TestParsedResponseWithExt( - val testField: ParsedResponseWithExt -) { - - data class TestBaseResult( - val baseField: String - ) - - data class TestExtResult( - val extField: String - ) - -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsBuilderUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsBuilderUnitTest.kt deleted file mode 100644 index de9a9d15b..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsBuilderUnitTest.kt +++ /dev/null @@ -1,165 +0,0 @@ -package com.ecwid.apiclient.v3.responsefields - -import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import java.util.* - -internal class ResponseFieldsBuilderUnitTest { - private val generator = ResponseFieldsBuilder() - - @Test - fun `must throw if not data class provided`() { - assertThrows { - generator.buildResponseFields(String::class) - } - } - - @Test - fun `must generate same result for inline and not inline call`() { - val first = generator.buildResponseFields() - val second = generator.buildResponseFields() - - // new instance for ignore cache - val third = ResponseFieldsBuilder().buildResponseFields() - - assertEquals(first, second) - assertEquals(first, third) - } - - @Test - fun `must generate fields for simple data class`() { - val actual = generator.buildResponseFields() - - val expected = newResponseFields { - field("id") - field("name") - field("created") - field("visibility") - field("taxInfo") { - field("customMap") { - field("customId") - } - field("details") { - field("name") - } - field("javaDetails") { - field("name") - } - field("tax") - } - - field("enabled") - - // GetResponseFields field annotation and custom json name - field("named_category") { - field("name") - } - - field("emptyCategory") // GetResponseFields field annotation with empty fields - - // GetResponseFields class annotation - field("categories") { - field("id") - } - - field("taxes") { - field("customMap") { - field("customId") - } - field("details") { - field("name") - } - field("javaDetails") { - field("name") - } - field("tax") - } - field("options") // Sealed class skipped - field("checkboxes") { - fields("name", "type") - } - field("categoryIds") // List of primitive type - - field("generic1") { field("id") } // data class generic list - field("generic2") { field("id") } // data class generic map - - // members from superclass - field("superclass") { - fields("id", "name", "description") - } - } - - assertEquals(expected, actual) - } -} - -@Suppress("unused") -private data class TestProduct( - val id: Int, - val name: String, - val created: Date, - val visibility: Visibility, - val taxInfo: TaxInfo?, - val enabled: Boolean, - - @JsonFieldName("named_category") - @ResponseFieldsOverride(["name"]) - val namedCategory: Category?, - - @ResponseFieldsOverride([]) - val emptyCategory: Category, - - val categories: List, - val taxes: List, - val options: List?, - val checkboxes: List?, - val categoryIds: ArrayList, - - val generic1: Simple1Generic, - val generic2: Simple2Generic, - val superclass: InheritedClass -) { - sealed class ProductOption { - abstract val type: String - - data class Checkbox( - override val type: String, - val name: String - ) : ProductOption() - } - - @ResponseFieldsOverride(["id"]) - data class Category( - val id: Int, - val name: String, - val description: String - ) - - data class TaxInfo( - val tax: Double?, - val details: Map, - val javaDetails: HashMap, - @ResponseFieldsOverride(["customId"]) - val customMap: Map, - ) { - data class TaxDetails( - val name: String, - ) - } - - data class Simple1Generic(val id: T) - data class Simple2Generic(val id: T) - - enum class Visibility { - SHOW, - HIDE - } - - open class Superclass(open val id: Int) { - var description = "Description" - } - - data class InheritedClass(override val id: Int, val name: String) : Superclass(id) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsDslUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsDslUnitTest.kt deleted file mode 100644 index eafa2bff6..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsDslUnitTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.ecwid.apiclient.v3.responsefields - -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - -class ResponseFieldsDslUnitTest { - @Test - fun `test dsl with responseFields`() { - val productResponseFields = newResponseFields { - fields("id", "sku") - field("options") { - field("name") - } - } - - val actual = newResponseFields { - field("items", productResponseFields) - } - - val expected = newResponseFields { - field("items") { - fields("id", "sku") - field("options") { - field("name") - } - } - } - - assertEquals(expected, actual) - assertEquals("items(id,sku,options(name))", actual.toHttpParameter()) - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsProviderKtUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsProviderKtUnitTest.kt deleted file mode 100644 index cef1ac147..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsProviderKtUnitTest.kt +++ /dev/null @@ -1,125 +0,0 @@ -package com.ecwid.apiclient.v3.responsefields - -import com.ecwid.apiclient.v3.dto.common.ApiResultDTO -import com.ecwid.apiclient.v3.dto.common.LocalizedValueMap -import com.ecwid.apiclient.v3.dto.common.PartialResult -import com.ecwid.apiclient.v3.dto.profile.result.FetchedStoreProfile -import com.ecwid.apiclient.v3.jsontransformer.JsonFieldName -import kotlin.test.* - - -class ResponseFieldsProviderKtUnitTest { - @Test - fun `test success`() { - data class InstantSiteInfo( - val ecwidSubdomain: String? = null, - val ecwidSubdomainSuffix: String? = null - ) - - data class GeneralInfo( - val storeId: Int, - val storeUrl: String?, - val starterSite: InstantSiteInfo?, - val websitePlatform: FetchedStoreProfile.WebsitePlatform?, - ) - - data class AbandonedSalesSettings( - val autoAbandonedSalesRecovery: Boolean?, - ) - - data class Settings( - val abandonedSales: AbandonedSalesSettings?, - val storeDescription: String?, - val storeDescriptionTranslated: LocalizedValueMap?, - ) - - data class FeatureTogglesInfo( - val name: String?, - val visible: Boolean?, - val enabled: Boolean?, - ) - - data class StoreProfile( - val generalInfo: GeneralInfo?, - val settings: Settings?, - val featureToggles: List? = null, - ) : PartialResult - - assertEquals( - "featureToggles(enabled,name,visible)," + - "generalInfo(starterSite(ecwidSubdomain,ecwidSubdomainSuffix),storeId,storeUrl,websitePlatform)," + - "settings(abandonedSales(autoAbandonedSalesRecovery),storeDescription,storeDescriptionTranslated)", - responseFieldsOf().toHttpParameter() - ) - } - - @Test - fun `failure - not a data class`() { - data class GeneralInfo(val storeId: Int) - class StoreProfileNotDataClass(val generalInfo: GeneralInfo?) : PartialResult - - assertFailsWith { - responseFieldsOf() - }.also { - assertEquals(StoreProfileNotDataClass::class, it.klass) - } - } - - @Test - fun `failure - type parameters`() { - data class GeneralInfoWithParam(val storeId: T) - data class GeneralInfo(val storeId: Int) - data class StoreProfileWithParam(val generalInfo: GeneralInfo?) : PartialResult - data class StoreProfile(val generalInfo: GeneralInfoWithParam?) : PartialResult - - assertFailsWith { - responseFieldsOf>() - }.also { - assertEquals(StoreProfileWithParam::class, it.klass) - } - - assertFailsWith { - responseFieldsOf() - }.also { - assertEquals(GeneralInfoWithParam::class, it.klass) - } - } - - @Test - fun `failure - extraneous property`() { - data class GeneralInfo(val storeId: Int, val nonExistingProperty: String) - data class StoreProfile(val generalInfo: GeneralInfo?) : PartialResult - - assertFailsWith { - responseFieldsOf() - }.also { - assertEquals(GeneralInfo::nonExistingProperty, it.partialResultProperty) - } - } - - @Test - fun `failure - incompatible types`() { - data class GeneralInfo(val storeId: String) - data class StoreProfile(val generalInfo: GeneralInfo?) : PartialResult - - assertFailsWith { - responseFieldsOf() - }.also { - assertEquals(GeneralInfo::storeId, it.partialResultProperty) - assertEquals(FetchedStoreProfile.GeneralInfo::storeId, it.fullResultProperty) - } - } - - @Test - fun `failure - incompatible annotations`() { - data class GeneralInfo(@JsonFieldName("store_id") val storeId: Int) - data class StoreProfile(val generalInfo: GeneralInfo?) : PartialResult - - assertFailsWith { - responseFieldsOf() - }.also { - assertEquals(GeneralInfo::storeId, it.partialResultProperty) - assertEquals(FetchedStoreProfile.GeneralInfo::storeId, it.fullResultProperty) - } - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsUnitTest.kt b/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsUnitTest.kt deleted file mode 100644 index 2a26f5c02..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/responsefields/ResponseFieldsUnitTest.kt +++ /dev/null @@ -1,183 +0,0 @@ -package com.ecwid.apiclient.v3.responsefields - -import org.junit.jupiter.api.Assertions.* -import org.junit.jupiter.api.Test - -class ResponseFieldsUnitTest { - @Test - fun `plus operator must merge fields`() { - val idOnly = ResponseFields( - fields = mapOf( - "id" to ResponseFields.Field.All, - "options" to ResponseFields.Field( - children = mapOf( - "id" to ResponseFields.Field.All - ) - ), - ) - ) - - val nameOnly = ResponseFields( - fields = mapOf( - "name" to ResponseFields.Field.All, - "options" to ResponseFields.Field( - children = mapOf( - "name" to ResponseFields.Field.All - ) - ), - ) - ) - - val expected = ResponseFields( - fields = mapOf( - "id" to ResponseFields.Field.All, - "name" to ResponseFields.Field.All, - "options" to ResponseFields.Field( - children = mapOf( - "id" to ResponseFields.Field.All, - "name" to ResponseFields.Field.All - ) - ), - ) - ) - - assertEquals(expected, idOnly + nameOnly) - assertEquals(expected, nameOnly + idOnly) - } - - @Test - fun `plus operator with all must returns all`() { - val idOnly = ResponseFields( - fields = mapOf( - "id" to ResponseFields.Field.All, - ) - ) - - assertEquals(ResponseFields.All, idOnly + ResponseFields.All) - assertEquals(ResponseFields.All, ResponseFields.All + idOnly) - } - - @Test - fun `plus operator with duplicated fields`() { - val first = newResponseFields { - fields("id", "limit") - field("items") { - field("name") - } - } - - val expected = newResponseFields { - fields("id", "limit", "count") - field("items") { - field("name") - } - } - - assertEquals(expected, first + AS_SEQUENCE_SEARCH_RESULT_REQUIRED_FIELDS) - } - - @Test - fun `plus operator with extend field`() { - val first = newResponseFields { - fields("id", "name") - field("options") - field("taxes") { - field("id") - } - } - - val second = newResponseFields { - fields("id", "name") - field("options") { - field("id") - } - field("taxes") - } - - val expected = newResponseFields { - fields("id", "name", "options", "taxes") - } - - assertEquals(expected, first + second) - assertEquals(expected, second + first) - } - - @Test - fun `toParameter test`() { - val fields = newResponseFields { - field("email") - field("billingPerson") { - field("phone") - } - } - - assertEquals("email,billingPerson(phone)", fields.toHttpParameter()) - } - - @Test - fun `dsl test`() { - val actual = newResponseFields { - field("email") - field("billingPerson") { - field("phone") - } - } - - val expected = ResponseFields( - fields = mapOf( - "email" to ResponseFields.Field.All, - "billingPerson" to ResponseFields.Field( - children = mapOf( - "phone" to ResponseFields.Field.All - ) - ) - ) - ) - - assertEquals(expected, actual) - } - - @Test - fun `contains test`() { - val idOnly = newResponseFields { field("id") } - val nameOnly = newResponseFields { field("name") } - val idAndNameOnly = newResponseFields { fields("id", "name") } - val optionsOnly = newResponseFields { field("options") } - val optionsSpecifiedOnly = newResponseFields { - field("options") { - field("id") - } - } - - assertTrue(idOnly.contains(idOnly)) { - "$idOnly must contains $idOnly" - } - assertTrue(idAndNameOnly.contains(idOnly)) { - "$idAndNameOnly must contains $idOnly" - } - assertTrue(idAndNameOnly.contains(nameOnly)) { - "$idAndNameOnly must contains $nameOnly" - } - assertTrue(ResponseFields.All.contains(idOnly)) { - "All must contains $idOnly" - } - assertTrue(ResponseFields.All.contains(ResponseFields.All)) { - "All must contains All" - } - assertTrue(optionsOnly.contains(optionsSpecifiedOnly)) { - "$optionsOnly must contains $optionsSpecifiedOnly" - } - assertFalse(idOnly.contains(ResponseFields.All)) { - "$idOnly must not contains All" - } - assertFalse(idOnly.contains(nameOnly)) { - "$idOnly must not contains $nameOnly" - } - assertFalse(idOnly.contains(idAndNameOnly)) { - "$idOnly must not contains $idAndNameOnly" - } - assertFalse(optionsSpecifiedOnly.contains(optionsOnly)) { - "$optionsSpecifiedOnly must not contains $optionsOnly" - } - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonDuplicablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonDuplicablePropertyRules.kt deleted file mode 100644 index 10ac6eedb..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonDuplicablePropertyRules.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.ecwid.apiclient.v3.rule - -import com.ecwid.apiclient.v3.dto.customer.request.UpdatedCustomer -import com.ecwid.apiclient.v3.dto.order.request.UpdatedOrder -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct -import com.ecwid.apiclient.v3.dto.variation.request.UpdatedVariation -import com.ecwid.apiclient.v3.rule.NonDuplicablePropertyRule.PartialDuplicable -import com.ecwid.apiclient.v3.rule.NonDuplicablePropertyRule.WriteOnly -import kotlin.reflect.KProperty1 - -val nonDuplicablePropertyRules: List> = listOf( - - // We should not copy this field if OrderItemSelectedOption.type is CHOICES - PartialDuplicable(UpdatedOrder.OrderItemSelectedOption::value), - - WriteOnly(UpdatedCustomer::password), - WriteOnly(UpdatedProduct.AttributeValue::alias), - WriteOnly(UpdatedProduct.AttributeValue::name), - WriteOnly(UpdatedVariation.AttributeValue::alias), - WriteOnly(UpdatedVariation.AttributeValue::name), - WriteOnly(UpdatedProduct.RelatedProducts::productSkus), - WriteOnly(UpdatedCustomer::primaryPhone), // contact becomes impossible to delete - rest4j replaces null with current value on writes - -) - -sealed class NonDuplicablePropertyRule( - val property: KProperty1 -) { - - class WriteOnly internal constructor( - property: KProperty1 - ) : NonDuplicablePropertyRule(property) - - class PartialDuplicable internal constructor( - property: KProperty1 - ) : NonDuplicablePropertyRule(property) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt deleted file mode 100644 index 3af00e22e..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonUpdatablePropertyRules.kt +++ /dev/null @@ -1,347 +0,0 @@ -package com.ecwid.apiclient.v3.rule - -import com.ecwid.apiclient.v3.dto.cart.result.FetchedCart -import com.ecwid.apiclient.v3.dto.category.result.FetchedCategory -import com.ecwid.apiclient.v3.dto.coupon.result.FetchedCoupon -import com.ecwid.apiclient.v3.dto.customer.result.FetchedCustomer -import com.ecwid.apiclient.v3.dto.customergroup.result.FetchedCustomerGroup -import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig -import com.ecwid.apiclient.v3.dto.instantsite.redirects.result.FetchedInstantSiteRedirect -import com.ecwid.apiclient.v3.dto.order.result.FetchedOrder -import com.ecwid.apiclient.v3.dto.product.result.FetchedProduct -import com.ecwid.apiclient.v3.dto.producttype.result.FetchedProductType -import com.ecwid.apiclient.v3.dto.profile.result.FetchedOrderStatusSettings -import com.ecwid.apiclient.v3.dto.profile.result.FetchedStoreProfile -import com.ecwid.apiclient.v3.dto.variation.result.FetchedVariation -import com.ecwid.apiclient.v3.rule.NonUpdatablePropertyRule.Ignored -import com.ecwid.apiclient.v3.rule.NonUpdatablePropertyRule.ReadOnly -import kotlin.reflect.KProperty1 - -val nonUpdatablePropertyRules: List> = listOf( - - ReadOnly(FetchedProduct::id), - Ignored(FetchedProduct::url), - Ignored(FetchedProduct::created), - Ignored(FetchedProduct::createTimestamp), - Ignored(FetchedProduct::updated), - Ignored(FetchedProduct::updateTimestamp), - Ignored(FetchedProduct::inStock), - Ignored(FetchedProduct::categories), - Ignored(FetchedProduct::priceInProductList), - Ignored(FetchedProduct::defaultDisplayedPrice), - Ignored(FetchedProduct::defaultDisplayedPriceFormatted), - Ignored(FetchedProduct::compareToPriceDiscount), - Ignored(FetchedProduct::compareToPriceDiscountFormatted), - Ignored(FetchedProduct::compareToPriceDiscountPercent), - Ignored(FetchedProduct::compareToPriceDiscountPercentFormatted), - Ignored(FetchedProduct::compareToPriceFormatted), - ReadOnly(FetchedProduct::defaultDisplayedCompareToPrice), - ReadOnly(FetchedProduct::defaultDisplayedCompareToPriceFormatted), - ReadOnly(FetchedProduct::defaultDisplayedCompareToPriceDiscount), - ReadOnly(FetchedProduct::defaultDisplayedCompareToPriceDiscountFormatted), - ReadOnly(FetchedProduct::defaultDisplayedCompareToPriceDiscountPercent), - ReadOnly(FetchedProduct::defaultDisplayedCompareToPriceDiscountPercentFormatted), - Ignored(FetchedProduct::lowestPrice), - ReadOnly(FetchedProduct::defaultDisplayedLowestPrice), - ReadOnly(FetchedProduct::defaultDisplayedLowestPriceFormatted), - ReadOnly(FetchedProduct.LowestPriceSettings::defaultDisplayedLowestPrice), - ReadOnly(FetchedProduct.LowestPriceSettings::defaultDisplayedLowestPriceFormatted), - ReadOnly(FetchedProduct.LowestPriceSettings::automaticLowestPrice), - ReadOnly(FetchedProduct.LowestPriceSettings::defaultDisplayedAutomaticLowestPrice), - ReadOnly(FetchedProduct.LowestPriceSettings::defaultDisplayedAutomaticLowestPriceFormatted), - Ignored(FetchedProduct.AttributeValue::name), - Ignored(FetchedProduct.AttributeValue::type), - Ignored(FetchedProduct.AttributeValue::show), - Ignored(FetchedProduct.TaxInfo::defaultLocationIncludedTaxRate), - Ignored(FetchedProduct::originalImage), - Ignored(FetchedProduct::galleryImages), - ReadOnly(FetchedProduct::borderInfo), - Ignored(FetchedProduct.ProductImage::isMain), - Ignored(FetchedProduct.ProductImage::image160pxUrl), - Ignored(FetchedProduct.ProductImage::image400pxUrl), - Ignored(FetchedProduct.ProductImage::image800pxUrl), - Ignored(FetchedProduct.ProductImage::image1500pxUrl), - Ignored(FetchedProduct.ProductImage::imageOriginalUrl), - ReadOnly(FetchedProduct.ProductMedia::videos), - ReadOnly(FetchedProduct.GalleryImage::borderInfo), - Ignored(FetchedProduct::files), - Ignored(FetchedProduct::favorites), - Ignored(FetchedProduct::defaultCombinationId), - Ignored(FetchedProduct::combinations), - Ignored(FetchedProduct::isGiftCard), - ReadOnly(FetchedProduct::hasFreeShipping), - ReadOnly(FetchedProduct::googleProductCategoryName), - ReadOnly(FetchedProduct::rating), - ReadOnly(FetchedProduct::reviewsModerated), - ReadOnly(FetchedProduct::reviewsPublished), - - Ignored(FetchedCart::cartId), - Ignored(FetchedCart::email), - Ignored(FetchedCart::ipAddress), - Ignored(FetchedCart::createDate), - Ignored(FetchedCart::createTimestamp), - Ignored(FetchedCart::updateDate), - Ignored(FetchedCart::updateTimestamp), - Ignored(FetchedCart::refererUrl), - Ignored(FetchedCart::globalReferer), - Ignored(FetchedCart::affiliateId), - Ignored(FetchedCart::additionalInfo), - Ignored(FetchedCart::orderComments), - Ignored(FetchedCart::trackingNumber), - ReadOnly(FetchedCart::trackingUrl), - Ignored(FetchedCart::paymentMethod), - Ignored(FetchedCart::paymentModule), - Ignored(FetchedCart::paymentParams), - Ignored(FetchedCart::paymentMessage), - Ignored(FetchedCart::creditCardStatus), - Ignored(FetchedCart::externalTransactionId), - Ignored(FetchedCart::recoveredOrderId), - Ignored(FetchedCart::recoveredPublicUid), - Ignored(FetchedCart::recoveryEmailSentTimestamp), - Ignored(FetchedCart::customerId), - Ignored(FetchedCart::customerGroupId), - Ignored(FetchedCart::customerGroup), - Ignored(FetchedCart::total), - Ignored(FetchedCart::subtotal), - Ignored(FetchedCart::usdTotal), - ReadOnly(FetchedCart::giftCardCode), - ReadOnly(FetchedCart::giftCardDoubleSpending), - ReadOnly(FetchedCart::giftCardId), - ReadOnly(FetchedCart::giftCardUuid), - ReadOnly(FetchedCart::giftCardRedemption), - ReadOnly(FetchedCart::totalBeforeGiftCardRedemption), - Ignored(FetchedCart::tax), - Ignored(FetchedCart::customerTaxExempt), - Ignored(FetchedCart::customerTaxId), - Ignored(FetchedCart::customerTaxIdValid), - Ignored(FetchedCart::reversedTaxApplied), - Ignored(FetchedCart::couponDiscount), - Ignored(FetchedCart::volumeDiscount), - Ignored(FetchedCart::membershipBasedDiscount), - Ignored(FetchedCart::totalAndMembershipBasedDiscount), - Ignored(FetchedCart::discount), - Ignored(FetchedCart::discountInfo), - Ignored(FetchedCart::discountCoupon), - Ignored(FetchedCart::items), - Ignored(FetchedCart::billingPerson), - Ignored(FetchedCart::shippingPerson), - Ignored(FetchedCart::shippingOption), - Ignored(FetchedCart::handlingFee), - Ignored(FetchedCart::utmData), - Ignored(FetchedCart::acceptMarketing), - - ReadOnly(FetchedCategory::id), - Ignored(FetchedCategory::hdThumbnailUrl), - Ignored(FetchedCategory::thumbnailUrl), - Ignored(FetchedCategory::imageUrl), - Ignored(FetchedCategory::originalImageUrl), - Ignored(FetchedCategory::originalImage), - Ignored(FetchedCategory::url), - Ignored(FetchedCategory::productCount), - ReadOnly(FetchedCategory::productCountWithoutSubcategories), - Ignored(FetchedCategory::enabledProductCount), - - ReadOnly(FetchedCoupon::id), - Ignored(FetchedCoupon::creationDate), - Ignored(FetchedCoupon::updateDate), - - ReadOnly(FetchedCustomer::id), - Ignored(FetchedCustomer::registered), - Ignored(FetchedCustomer::updated), - Ignored(FetchedCustomer::customerGroupName), - Ignored(FetchedCustomer.BillingPerson::firstName), - Ignored(FetchedCustomer.BillingPerson::lastName), - Ignored(FetchedCustomer.BillingPerson::countryName), - Ignored(FetchedCustomer.BillingPerson::stateOrProvinceName), - Ignored(FetchedCustomer.ShippingAddress::countryName), - Ignored(FetchedCustomer.ShippingAddress::stateOrProvinceName), - ReadOnly(FetchedCustomer.ShippingAddress::createdDate), - ReadOnly(FetchedCustomer.ShippingAddress::addressFormatted), - ReadOnly(FetchedCustomer::stats), - ReadOnly(FetchedCustomer.CustomerContact::timestamp), - ReadOnly(FetchedCustomer::favorites), - ReadOnly(FetchedCustomer.CustomerFavorite::productId), - ReadOnly(FetchedCustomer.CustomerFavorite::addedTimestamp), - ReadOnly(FetchedCustomer.CustomerExtrafield::entityTypes), - ReadOnly(FetchedCustomer.CustomerExtrafield::orderBy), - - ReadOnly(FetchedCustomerGroup::id), - - ReadOnly(FetchedOrder::id), - ReadOnly(FetchedOrder::internalId), - ReadOnly(FetchedOrder::orderNumber), - ReadOnly(FetchedOrder::vendorOrderNumber), - ReadOnly(FetchedOrder::publicUid), - ReadOnly(FetchedOrder::orderExtraFields), - ReadOnly(FetchedOrder::giftCardCode), - ReadOnly(FetchedOrder::giftCardDoubleSpending), - ReadOnly(FetchedOrder::giftCardId), - ReadOnly(FetchedOrder::giftCardUuid), - ReadOnly(FetchedOrder::giftCardRedemption), - ReadOnly(FetchedOrder::totalBeforeGiftCardRedemption), - ReadOnly(FetchedOrder::totalWithoutTax), - ReadOnly(FetchedOrder::subtotalWithoutTax), - ReadOnly(FetchedOrder::availableTaxes), - ReadOnly(FetchedOrder::availableShippingOptions), - ReadOnly(FetchedOrder::shipments), - ReadOnly(FetchedOrder::invoices), - ReadOnly(FetchedOrder::predictedPackage), - ReadOnly(FetchedOrder::customerGroupId), - ReadOnly(FetchedOrder::ticket), - ReadOnly(FetchedOrder::paymentSubtype), - Ignored(FetchedOrder::createTimestamp), - Ignored(FetchedOrder::updateDate), - Ignored(FetchedOrder::updateTimestamp), - Ignored(FetchedOrder::extraFields), - Ignored(FetchedOrder::usdTotal), - Ignored(FetchedOrder.DiscountCouponInfo::id), - Ignored(FetchedOrder.DiscountCouponInfo::creationDate), - Ignored(FetchedOrder.DiscountCouponInfo::updateDate), - Ignored(FetchedOrder.DiscountCouponInfo::orderCount), - Ignored(FetchedOrder.DiscountCouponInfo::catalogLimit), - Ignored(FetchedOrder.DiscountCouponInfo::applicationLimit), - ReadOnly(FetchedOrder.BaseOrderItemTax::includeInPrice), - ReadOnly(FetchedOrder.HandlingFeeTax::includeInPrice), - Ignored(FetchedOrder.OrderItem::id), - ReadOnly(FetchedOrder.OrderItem::priceWithoutTax), - ReadOnly(FetchedOrder.OrderItem::files), - ReadOnly(FetchedOrder.OrderItem::attributes), - Ignored(FetchedOrder.OrderItem::imageUrl), - Ignored(FetchedOrder.OrderItem::smallThumbnailUrl), - Ignored(FetchedOrder.OrderItem::hdThumbnailUrl), - Ignored(FetchedOrder.OrderItem::productAvailable), - Ignored(FetchedOrder.OrderItem::recurringChargeSettings), - Ignored(FetchedOrder.OrderItem::subscriptionId), - Ignored(FetchedOrder.OrderItemSelectedOption::files), - Ignored(FetchedOrder.PersonInfo::firstName), - Ignored(FetchedOrder.PersonInfo::lastName), - Ignored(FetchedOrder.PersonInfo::countryName), - Ignored(FetchedOrder.PersonInfo::stateOrProvinceName), - Ignored(FetchedOrder.PersonInfo::firstName), - Ignored(FetchedOrder.PersonInfo::lastName), - Ignored(FetchedOrder.PersonInfo::countryName), - Ignored(FetchedOrder.PersonInfo::stateOrProvinceName), - ReadOnly(FetchedOrder.ShippingOption::shippingRateWithoutTax), - ReadOnly(FetchedOrder.ShippingOption::localizedLabel), - ReadOnly(FetchedOrder.ShippingOption::isShippingLimit), - ReadOnly(FetchedOrder.ShippingOption::scheduled), - ReadOnly(FetchedOrder.ShippingOption::scheduledTimePrecisionType), - ReadOnly(FetchedOrder.ShippingOption::timeSlotLengthInMinutes), - ReadOnly(FetchedOrder.ShippingOption::pickupPrecisionType), - ReadOnly(FetchedOrder.HandlingFee::valueWithoutTax), - ReadOnly(FetchedOrder.Surcharge::totalWithoutTax), - Ignored(FetchedOrder::refundedAmount), - Ignored(FetchedOrder::refunds), - ReadOnly(FetchedOrder.OrderItemTax::sourceTaxRateId), - ReadOnly(FetchedOrder.OrderItemTax::sourceTaxRateType), - ReadOnly(FetchedOrder::shippingLabelAvailableForShipment), - - ReadOnly(FetchedProductType::id), - Ignored(FetchedProductType::googleTaxonomy), - - Ignored(FetchedStoreProfile.GeneralInfo::storeId), - Ignored(FetchedStoreProfile.InstantSiteInfo::generatedUrl), - Ignored(FetchedStoreProfile.InstantSiteInfo::storeLogoUrl), - Ignored(FetchedStoreProfile.Account::availableFeatures), - Ignored(FetchedStoreProfile.Account::whiteLabel), - ReadOnly(FetchedStoreProfile.Account::brandName), - ReadOnly(FetchedStoreProfile.Account::supportEmail), - ReadOnly(FetchedStoreProfile.Account::registrationDate), - ReadOnly(FetchedStoreProfile.RegistrationAnswers::facebook), - ReadOnly(FetchedStoreProfile.RegistrationAnswers::alreadySelling), - ReadOnly(FetchedStoreProfile.RegistrationAnswers::forSomeone), - ReadOnly(FetchedStoreProfile.RegistrationAnswers::goods), - ReadOnly(FetchedStoreProfile.RegistrationAnswers::otherGoods), - ReadOnly(FetchedStoreProfile.RegistrationAnswers::platform), - ReadOnly(FetchedStoreProfile::registrationAnswers), - Ignored(FetchedStoreProfile.Settings::invoiceLogoUrl), - Ignored(FetchedStoreProfile.Settings::emailLogoUrl), - Ignored(FetchedStoreProfile.FormatsAndUnits::currencyPrecision), - Ignored(FetchedStoreProfile.Languages::facebookPreferredLocale), - Ignored(FetchedStoreProfile.Shipping::shippingOrigin), - Ignored(FetchedStoreProfile.Shipping::shippingOptions), - Ignored(FetchedStoreProfile::payment), - Ignored(FetchedStoreProfile::featureToggles), - Ignored(FetchedStoreProfile::designSettings), - Ignored(FetchedStoreProfile::fbMessengerSettings), - Ignored(FetchedStoreProfile::giftCardSettings), - ReadOnly(FetchedStoreProfile.Settings::googleProductCategoryName), - ReadOnly(FetchedStoreProfile.TikTokPixelSettings::code), - ReadOnly(FetchedStoreProfile.InstantSiteInfo::ecwidSubdomainSuffix), - ReadOnly(FetchedStoreProfile.InstantSiteInfo::slugsWithoutIdsEnabled), - ReadOnly(FetchedStoreProfile.PaymentOptionInfo::id), - ReadOnly(FetchedStoreProfile.PaymentOptionInfo::paymentProcessorTitle), - - ReadOnly(FetchedVariation::id), - Ignored(FetchedVariation::combinationNumber), - Ignored(FetchedVariation.Option::nameTranslated), - Ignored(FetchedVariation.Option::valueTranslated), - Ignored(FetchedVariation::smallThumbnailUrl), - Ignored(FetchedVariation::hdThumbnailUrl), - Ignored(FetchedVariation::thumbnailUrl), - Ignored(FetchedVariation::imageUrl), - Ignored(FetchedVariation::originalImageUrl), - Ignored(FetchedVariation::defaultDisplayedPrice), - Ignored(FetchedVariation::defaultDisplayedPriceFormatted), - ReadOnly(FetchedVariation::inStock), - Ignored(FetchedVariation::borderInfo), - Ignored(FetchedVariation::lowestPrice), - ReadOnly(FetchedVariation::defaultDisplayedLowestPrice), - ReadOnly(FetchedVariation::defaultDisplayedLowestPriceFormatted), - ReadOnly(FetchedVariation.LowestPriceSettings::defaultDisplayedLowestPrice), - ReadOnly(FetchedVariation.LowestPriceSettings::defaultDisplayedLowestPriceFormatted), - ReadOnly(FetchedVariation.LowestPriceSettings::automaticLowestPrice), - ReadOnly(FetchedVariation.LowestPriceSettings::defaultDisplayedAutomaticLowestPrice), - ReadOnly(FetchedVariation.LowestPriceSettings::defaultDisplayedAutomaticLowestPriceFormatted), - Ignored(FetchedVariation.AttributeValue::name), - Ignored(FetchedVariation.AttributeValue::type), - Ignored(FetchedVariation.AttributeValue::show), - ReadOnly(FetchedVariation.RecurringChargeSettings::subscriptionPriceWithSignUpFeeFormatted), - ReadOnly(FetchedVariation.RecurringChargeSettings::signUpFee), - ReadOnly(FetchedVariation.RecurringChargeSettings::signUpFeeFormatted), - ReadOnly(FetchedVariation.RecurringChargeSettings::subscriptionPriceWithSignUpFeeFormatted), - ReadOnly(FetchedVariation.SubscriptionSettings::oneTimePurchasePriceFormatted), - ReadOnly(FetchedVariation.SubscriptionSettings::oneTimePurchaseMarkupFormatted), - ReadOnly(FetchedVariation.SubscriptionSettings::oneTimePurchaseMarkup), - ReadOnly(FetchedVariation.SubscriptionSettings::oneTimePurchaseMarkupPercent), - ReadOnly(FetchedVariation.SubscriptionSettings::oneTimePurchaseMarkupPercentFormatted), - ReadOnly(FetchedVariation.SubscriptionSettings::displayedOneTimePurchaseMarkupPercent), - ReadOnly(FetchedVariation.SubscriptionSettings::displayedOneTimePurchaseMarkupPercentFormatted), - - ReadOnly(FetchedProduct.RecurringChargeSettings::subscriptionPriceWithSignUpFeeFormatted), - ReadOnly(FetchedProduct.RecurringChargeSettings::signUpFee), - ReadOnly(FetchedProduct.RecurringChargeSettings::signUpFeeFormatted), - ReadOnly(FetchedProduct.RecurringChargeSettings::subscriptionPriceWithSignUpFeeFormatted), - ReadOnly(FetchedProduct.SubscriptionSettings::oneTimePurchasePriceFormatted), - ReadOnly(FetchedProduct.SubscriptionSettings::oneTimePurchaseMarkupFormatted), - ReadOnly(FetchedProduct.SubscriptionSettings::oneTimePurchaseMarkup), - ReadOnly(FetchedProduct.SubscriptionSettings::oneTimePurchaseMarkupPercent), - ReadOnly(FetchedProduct.SubscriptionSettings::oneTimePurchaseMarkupPercentFormatted), - ReadOnly(FetchedProduct.SubscriptionSettings::displayedOneTimePurchaseMarkupPercent), - ReadOnly(FetchedProduct.SubscriptionSettings::displayedOneTimePurchaseMarkupPercentFormatted), - - ReadOnly(FetchedOrderStatusSettings::statusId), - ReadOnly(FetchedOrderStatusSettings::orderStatusType), - ReadOnly(FetchedOrderStatusSettings::defaultStatus), - ReadOnly(FetchedOrderStatusSettings::lastNameChangeDate), - - ReadOnly(FetchedInstantSiteRedirect::id), - - ReadOnly(FetchedCustomersConfig::entityTypes), - ReadOnly(FetchedCustomersConfig::linkedWithCheckoutField), - ReadOnly(FetchedCustomersConfig::createdDate), - ReadOnly(FetchedCustomersConfig::lastModifiedDate), -) - -sealed class NonUpdatablePropertyRule( - val property: KProperty1 -) { - - class ReadOnly internal constructor( - property: KProperty1 - ) : NonUpdatablePropertyRule(property) - - class Ignored internal constructor( - property: KProperty1 - ) : NonUpdatablePropertyRule(property) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonnullPropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonnullPropertyRules.kt deleted file mode 100644 index 5ebf15894..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NonnullPropertyRules.kt +++ /dev/null @@ -1,69 +0,0 @@ -package com.ecwid.apiclient.v3.rule - -import com.ecwid.apiclient.v3.dto.common.ApiUpdatedDTO -import com.ecwid.apiclient.v3.dto.coupon.request.UpdatedCoupon -import com.ecwid.apiclient.v3.dto.customergroup.request.UpdatedCustomerGroup -import com.ecwid.apiclient.v3.dto.product.request.UpdatedProduct -import com.ecwid.apiclient.v3.dto.profile.request.UpdatedStoreProfile -import com.ecwid.apiclient.v3.dto.storage.request.UpdatedStorageData -import com.ecwid.apiclient.v3.dto.variation.request.UpdatedVariation -import com.ecwid.apiclient.v3.rule.NonnullPropertyRule.AllowNonnull -import com.ecwid.apiclient.v3.rule.NonnullPropertyRule.IgnoreNonnull -import kotlin.reflect.KProperty1 - -val nonnullPropertyRules: List> = listOf( - AllowNonnull(ApiUpdatedDTO.ModifyKind.ReadWrite::fetchedDTOClass), - - AllowNonnull(UpdatedProduct.CustomPriceTier::value), - - AllowNonnull(UpdatedStorageData::key), - AllowNonnull(UpdatedStorageData::value), - - IgnoreNonnull(UpdatedCoupon::code), - IgnoreNonnull(UpdatedCoupon::name), - - IgnoreNonnull(UpdatedCustomerGroup::name), - - IgnoreNonnull(UpdatedProduct.ProductImage::id), - IgnoreNonnull(UpdatedProduct.ProductImage::orderBy), - IgnoreNonnull(UpdatedProduct.ProductOption.CheckboxOption::choices), - IgnoreNonnull(UpdatedProduct.ProductOption.CheckboxOption::name), - IgnoreNonnull(UpdatedProduct.ProductOption.DateOption::name), - IgnoreNonnull(UpdatedProduct.ProductOption.FilesOption::name), - IgnoreNonnull(UpdatedProduct.ProductOption.RadioOption::choices), - IgnoreNonnull(UpdatedProduct.ProductOption.RadioOption::name), - IgnoreNonnull(UpdatedProduct.ProductOption.SelectOption::choices), - IgnoreNonnull(UpdatedProduct.ProductOption.SelectOption::name), - IgnoreNonnull(UpdatedProduct.ProductOption.SizeOption::choices), - IgnoreNonnull(UpdatedProduct.ProductOption.SizeOption::name), - IgnoreNonnull(UpdatedProduct.ProductOption.TextAreaOption::name), - IgnoreNonnull(UpdatedProduct.ProductOption.TextFieldOption::name), - IgnoreNonnull(UpdatedProduct.ProductOptionChoice::text), - IgnoreNonnull(UpdatedProduct.RecurringChargeSettings::recurringInterval), - IgnoreNonnull(UpdatedProduct.RecurringChargeSettings::recurringIntervalCount), - IgnoreNonnull(UpdatedProduct.WholesalePrice::price), - IgnoreNonnull(UpdatedProduct.WholesalePrice::quantity), - - IgnoreNonnull(UpdatedVariation.WholesalePrice::price), - IgnoreNonnull(UpdatedVariation.WholesalePrice::quantity), - - AllowNonnull(UpdatedStoreProfile.ProductFilterItem::enabled), - AllowNonnull(UpdatedStoreProfile.ProductFilterItem::type), - AllowNonnull(UpdatedStoreProfile.ProductFiltersSettings::enabledInStorefront), - AllowNonnull(UpdatedStoreProfile.ProductFiltersSettings::filterSections), - AllowNonnull(UpdatedVariation.RecurringChargeSettings::recurringInterval), - AllowNonnull(UpdatedVariation.RecurringChargeSettings::recurringIntervalCount), -) - -sealed class NonnullPropertyRule( - val property: KProperty1 -) { - - class AllowNonnull internal constructor( - property: KProperty1 - ) : NonnullPropertyRule(property) - - class IgnoreNonnull internal constructor( - property: KProperty1 - ) : NonnullPropertyRule(property) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt deleted file mode 100644 index 974e0ff6b..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/NullablePropertyRules.kt +++ /dev/null @@ -1,222 +0,0 @@ -package com.ecwid.apiclient.v3.rule - -import com.ecwid.apiclient.v3.dto.batch.request.CreateBatchRequest -import com.ecwid.apiclient.v3.dto.batch.request.CreateBatchRequestWithIds -import com.ecwid.apiclient.v3.dto.batch.result.GetEscapedBatchResult -import com.ecwid.apiclient.v3.dto.batch.result.GetTypedBatchResult -import com.ecwid.apiclient.v3.dto.cart.result.CartUpdateResult -import com.ecwid.apiclient.v3.dto.cart.result.ConvertCartToOrderResult -import com.ecwid.apiclient.v3.dto.customergroup.request.CustomerGroupsSearchRequest -import com.ecwid.apiclient.v3.dto.instantsite.redirects.request.InstantSiteRedirectsGetForExactPathRequest -import com.ecwid.apiclient.v3.dto.instantsite.redirects.request.InstantSiteRedirectsSearchRequest -import com.ecwid.apiclient.v3.dto.order.result.DeletedOrder -import com.ecwid.apiclient.v3.dto.payment.PaymentAppRequest -import com.ecwid.apiclient.v3.dto.product.request.ProductInventoryUpdateRequest -import com.ecwid.apiclient.v3.dto.product.request.ProductUpdateRequest -import com.ecwid.apiclient.v3.dto.product.result.GetProductFiltersResult -import com.ecwid.apiclient.v3.dto.product.result.ProductInventoryUpdateResult -import com.ecwid.apiclient.v3.dto.productreview.request.UpdatedProductReviewStatus -import com.ecwid.apiclient.v3.dto.profile.request.StoreProfileRequest -import com.ecwid.apiclient.v3.dto.profile.result.FetchedLatestStats -import com.ecwid.apiclient.v3.dto.report.request.ReportAdviceRequest -import com.ecwid.apiclient.v3.dto.report.request.ReportRequest -import com.ecwid.apiclient.v3.dto.report.result.FetchedReportAdviceResponse -import com.ecwid.apiclient.v3.dto.report.result.FetchedReportResponse -import com.ecwid.apiclient.v3.dto.storage.result.FetchedStorageData -import com.ecwid.apiclient.v3.dto.swatches.result.FetchedSwatchColor -import com.ecwid.apiclient.v3.dto.variation.request.ProductVariationsRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable -import com.ecwid.apiclient.v3.rule.nullablepropertyrules.* -import kotlin.reflect.KProperty1 - -val otherNullablePropertyRules: List> = listOf( - - AllowNullable(ProductInventoryUpdateRequest::checkLowStockNotification), - AllowNullable(ProductUpdateRequest::checkLowStockNotification), - AllowNullable(ProductUpdateRequest::rebuildVariationsOnOptionsUpdate), - AllowNullable(ProductUpdateRequest::keepOptionDisplaySettings), - - AllowNullable(StoreProfileRequest::lang), - - AllowNullable(ProductVariationsRequest::lang), - - IgnoreNullable(GetEscapedBatchResult::responses), - IgnoreNullable(GetTypedBatchResult::responses), - - AllowNullable(GetProductFiltersResult.ProductFilters::attributes), - AllowNullable(GetProductFiltersResult.ProductFilters::categories), - AllowNullable(GetProductFiltersResult.ProductFilters::inventory), - AllowNullable(GetProductFiltersResult.ProductFilters::onsale), - AllowNullable(GetProductFiltersResult.ProductFilters::options), - AllowNullable(GetProductFiltersResult.ProductFilters::price), - - AllowNullable(FetchedLatestStats::productCount), - AllowNullable(FetchedLatestStats::categoryCount), - - IgnoreNullable(ConvertCartToOrderResult::id), - IgnoreNullable(ConvertCartToOrderResult::orderNumber), - IgnoreNullable(ConvertCartToOrderResult::vendorOrderNumber), - - IgnoreNullable(CartUpdateResult::updateCount), - - IgnoreNullable(DeletedOrder::orderId), - - AllowNullable(PaymentAppRequest.Cart::currency), - AllowNullable(PaymentAppRequest.Cart::order), - AllowNullable(PaymentAppRequest::cart), - AllowNullable(PaymentAppRequest::lang), - AllowNullable(PaymentAppRequest::merchantAppSettings), - AllowNullable(PaymentAppRequest::returnUrl), - AllowNullable(PaymentAppRequest::storeId), - AllowNullable(PaymentAppRequest::token), - - IgnoreNullable(ProductInventoryUpdateResult::warning), - - AllowNullable(FetchedStorageData::value), - - AllowNullable(ReportRequest::startedFrom), - AllowNullable(ReportRequest::endedAt), - AllowNullable(ReportRequest::timeScaleValue), - AllowNullable(ReportRequest::comparePeriod), - AllowNullable(ReportRequest::firstDayOfWeek), - AllowNullable(ReportRequest::orderByMetric), - AllowNullable(ReportRequest::orderDirection), - AllowNullable(ReportRequest::limit), - AllowNullable(ReportRequest::offset), - AllowNullable(ReportRequest::storefrontPlatform), - - AllowNullable(ReportAdviceRequest::startedFrom), - AllowNullable(ReportAdviceRequest::endedAt), - AllowNullable(ReportAdviceRequest::timeScaleValue), - AllowNullable(ReportAdviceRequest::comparePeriod), - AllowNullable(ReportAdviceRequest::firstDayOfWeek), - AllowNullable(ReportAdviceRequest::orderByMetric), - AllowNullable(ReportAdviceRequest::orderDirection), - AllowNullable(ReportAdviceRequest::limit), - AllowNullable(ReportAdviceRequest::offset), - AllowNullable(ReportAdviceRequest::storefrontPlatform), - - AllowNullable(FetchedReportResponse::timeScaleValue), - AllowNullable(FetchedReportResponse::comparePeriod), - AllowNullable(FetchedReportResponse::firstDayOfWeek), - AllowNullable(FetchedReportResponse::orderByMetric), - AllowNullable(FetchedReportResponse::orderDirection), - AllowNullable(FetchedReportResponse::limit), - AllowNullable(FetchedReportResponse::offset), - AllowNullable(FetchedReportResponse::itemCount), - AllowNullable(FetchedReportResponse::dataset), - AllowNullable(FetchedReportResponse::comparePeriodAggregatedData), - AllowNullable(FetchedReportResponse::comparePeriodDataset), - AllowNullable(FetchedReportResponse::additionalData), - - AllowNullable(FetchedReportAdviceResponse::tip), - - AllowNullable(FetchedReportResponse.FetchedDataset::startTimeStamp), - AllowNullable(FetchedReportResponse.FetchedDataset::endTimeStamp), - AllowNullable(FetchedReportResponse.FetchedDataset::percentage), - AllowNullable(FetchedReportResponse.FetchedDataset::comparePeriodStartTimeStamp), - AllowNullable(FetchedReportResponse.FetchedDataset::comparePeriodEndTimeStamp), - AllowNullable(FetchedReportResponse.FetchedDataset::additionalData), - - AllowNullable(FetchedReportResponse.FetchedCustomerData::customerId), - AllowNullable(FetchedReportResponse.FetchedCustomerData::customerEmail), - AllowNullable(FetchedReportResponse.FetchedCustomerData::customerPhone), - - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalInventoryData::sku), - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalInventoryData::imageUrl), - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalInventoryData::thumbnailUrl), - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalInventoryData::exampleOrder), - - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalProductData::productName), - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalProductData::productUrl), - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalProductData::productEditUrl), - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalProductData::productSku), - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalProductData::productImageUrl), - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalProductData::productThumbnailUrl), - - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalCouponData::couponName), - - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalAbandonedCartData::autoAbandonedSalesRecovery), - - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalShippingData::shippingMethodName), - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalShippingData::fulfilmentType), - - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalLandingData::landingUrl), - - AllowNullable(FetchedReportResponse.FetchedAdditionalData.AdditionalCategoryData::categoryName), - - AllowNullable(FetchedSwatchColor::translations), - - AllowNullable(CreateBatchRequest::groupId), - AllowNullable(CreateBatchRequestWithIds::groupId), - - AllowNullable(InstantSiteRedirectsSearchRequest::keyword), - AllowNullable(InstantSiteRedirectsSearchRequest::limit), - AllowNullable(InstantSiteRedirectsSearchRequest::offset), - - AllowNullable(InstantSiteRedirectsGetForExactPathRequest::exactPath), - - AllowNullable(UpdatedProductReviewStatus::status), - - AllowNullable(CustomerGroupsSearchRequest::keyword), - AllowNullable(CustomerGroupsSearchRequest::customerGroupIds), -) - -val nullablePropertyRules: List> = listOf( - calculateOrderDetailsResultNullablePropertyRules, - cartsSearchRequestNullablePropertyRules, - categoriesByPathRequestNullablePropertyRules, - categoriesSearchRequestNullablePropertyRules, - categoryDetailsRequestNullablePropertyRules, - couponSearchRequestNullablePropertyRules, - customAppRequestNullablePropertyRules, - customersSearchRequestNullablePropertyRules, - customersMassUpdatedRequestNullablePropertyRules, - customersIdsRequestNullablePropertyRules, - deletedCustomersSearchRequestNullablePropertyRules, - deletedOrdersSearchRequestNullablePropertyRules, - deletedProductsSearchRequestNullablePropertyRules, - fetchedCartNullablePropertyRules, - fetchedCategoryNullablePropertyRules, - fetchedCouponNullablePropertyRules, - fetchedCustomerNullablePropertyRules, - fetchedExtrafieldConfigNullablePropertyRules, - fetchedOrderStatusSettingsNullablePropertyRules, - fetchedOrderNullablePropertyRules, - fetchedProductNullablePropertyRules, - fetchedProductTypeNullablePropertyRules, - fetchedShippingOptionNullablePropertyRules, - fetchedStoreProfileNullablePropertyRules, - fetchedVariationTypeNullablePropertyRules, - getProductFiltersRequestNullablePropertyRules, - orderForCalculateNullablePropertyRules, - ordersSearchRequestRequestNullablePropertyRules, - productDetailsRequestNullablePropertyRules, - productsSearchRequestNullablePropertyRules, - subscriptionsSearchRequestNullablePropertyRules, - fetchedSubscriptionsNullablePropertyRules, - otherNullablePropertyRules, - fetchedSlugInfoNullablePropertyRules, - fetchedSlugInfoClassesNullablePropertyRules, - slugInfoRequestNullablePropertyRules, - fetchedProductReviewNullablePropertyRules, - productReviewMassUpdateRequestNullablePropertyRules, - productReviewSearchRequestNullablePropertyRules, - fetchedCustomersConfigNullablePropertyRules, - brandsSearchRequestNullablePropertyRules, - fetchedBrandNullablePropertyRules, -).flatten() - -sealed class NullablePropertyRule( - val property: KProperty1 -) { - - class AllowNullable internal constructor( - property: KProperty1 - ) : NullablePropertyRule(property) - - class IgnoreNullable internal constructor( - property: KProperty1 - ) : NullablePropertyRule(property) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/BrandsSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/BrandsSearchRequestRules.kt deleted file mode 100644 index 7bac458af..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/BrandsSearchRequestRules.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.brand.request.BrandsSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val brandsSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(BrandsSearchRequest.ByFilters::lang), - AllowNullable(BrandsSearchRequest.ByFilters::hiddenBrands), - AllowNullable(BrandsSearchRequest.ByFilters::baseUrl), - AllowNullable(BrandsSearchRequest.ByFilters::cleanUrls), - AllowNullable(BrandsSearchRequest.ByFilters::sortBy), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt deleted file mode 100644 index 056012604..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CalculateOrderDetailsResultRules.kt +++ /dev/null @@ -1,189 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.cart.result.CalculateOrderDetailsResult -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val calculateOrderDetailsResultNullablePropertyRules: List> = listOf( - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponCatalogLimit::categories), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponCatalogLimit::products), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::applicationLimit), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::catalogLimit), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::code), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::creationDate), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::discount), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::discountType), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::expirationDate), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::launchDate), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::name), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::orderCount), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::status), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::totalLimit), - IgnoreNullable(CalculateOrderDetailsResult.DiscountCouponInfo::usesLimit), - IgnoreNullable(CalculateOrderDetailsResult.DiscountInfo::base), - IgnoreNullable(CalculateOrderDetailsResult.DiscountInfo::description), - IgnoreNullable(CalculateOrderDetailsResult.DiscountInfo::orderTotal), - IgnoreNullable(CalculateOrderDetailsResult.DiscountInfo::type), - IgnoreNullable(CalculateOrderDetailsResult.DiscountInfo::value), - AllowNullable(CalculateOrderDetailsResult.DiscountInfo::appliesToProducts), - AllowNullable(CalculateOrderDetailsResult.DiscountInfo::appliesToItems), - IgnoreNullable(CalculateOrderDetailsResult.HandlingFeeInfo::description), - IgnoreNullable(CalculateOrderDetailsResult.HandlingFeeInfo::name), - AllowNullable(CalculateOrderDetailsResult.HandlingFeeInfo::taxes), - IgnoreNullable(CalculateOrderDetailsResult.HandlingFeeInfo::value), - AllowNullable(CalculateOrderDetailsResult.HandlingFeeTax::includeInPrice), - AllowNullable(CalculateOrderDetailsResult.HandlingFeeTax::name), - AllowNullable(CalculateOrderDetailsResult.HandlingFeeTax::total), - AllowNullable(CalculateOrderDetailsResult.HandlingFeeTax::value), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::categoryId), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::couponAmount), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::couponApplied), - AllowNullable(CalculateOrderDetailsResult.OrderItem::giftCard), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::digital), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::dimensions), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::discounts), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::files), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::fixedShippingRate), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::fixedShippingRateOnly), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::id), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::imageUrl), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::isShippingRequired), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::name), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::price), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::productId), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::productPrice), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::quantity), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::quantityInStock), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::selectedOptions), - AllowNullable(CalculateOrderDetailsResult.OrderItem::combinationId), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::shipping), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::shortDescription), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::sku), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::tax), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::taxes), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::trackQuantity), - IgnoreNullable(CalculateOrderDetailsResult.OrderItem::weight), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemDiscountInfo::base), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemDiscountInfo::orderTotal), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemDiscountInfo::type), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemDiscountInfo::value), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemDiscounts::discountInfo), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemDiscounts::total), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOptionFile::id), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOptionFile::name), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOptionFile::size), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOptionFile::url), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOption::files), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOption::name), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOption::selections), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOption::type), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOption::value), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemOption::valuesArray), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemProductFile::adminUrl), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemProductFile::customerUrl), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemProductFile::description), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemProductFile::expire), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemProductFile::maxDownloads), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemProductFile::name), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemProductFile::productFileId), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemProductFile::remainingDownloads), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemProductFile::size), - AllowNullable(CalculateOrderDetailsResult.OrderItemTax::taxType), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemTax::includeInPrice), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemTax::name), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemTax::taxOnDiscountedSubtotal), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemTax::taxOnShipping), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemTax::total), - IgnoreNullable(CalculateOrderDetailsResult.OrderItemTax::value), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::city), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::companyName), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::countryCode), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::countryName), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::name), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::phone), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::postalCode), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::stateOrProvinceCode), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::stateOrProvinceName), - IgnoreNullable(CalculateOrderDetailsResult.PersonInfo::street), - IgnoreNullable(CalculateOrderDetailsResult.PredictedPackage::declaredValue), - IgnoreNullable(CalculateOrderDetailsResult.PredictedPackage::height), - IgnoreNullable(CalculateOrderDetailsResult.PredictedPackage::length), - IgnoreNullable(CalculateOrderDetailsResult.PredictedPackage::weight), - IgnoreNullable(CalculateOrderDetailsResult.PredictedPackage::width), - IgnoreNullable(CalculateOrderDetailsResult.ProductDimensions::height), - IgnoreNullable(CalculateOrderDetailsResult.ProductDimensions::length), - IgnoreNullable(CalculateOrderDetailsResult.ProductDimensions::width), - IgnoreNullable(CalculateOrderDetailsResult.SelectionInfo::selectionModifier), - IgnoreNullable(CalculateOrderDetailsResult.SelectionInfo::selectionModifierType), - IgnoreNullable(CalculateOrderDetailsResult.SelectionInfo::selectionTitle), - IgnoreNullable(CalculateOrderDetailsResult.ShippingOptionInfo::estimatedTransitTime), - IgnoreNullable(CalculateOrderDetailsResult.ShippingOptionInfo::isPickup), - IgnoreNullable(CalculateOrderDetailsResult.ShippingOptionInfo::pickupInstruction), - IgnoreNullable(CalculateOrderDetailsResult.ShippingOptionInfo::shippingCarrierName), - IgnoreNullable(CalculateOrderDetailsResult.ShippingOptionInfo::shippingMethodName), - IgnoreNullable(CalculateOrderDetailsResult.ShippingOptionInfo::shippingRate), - AllowNullable(CalculateOrderDetailsResult.Surcharge::description), - AllowNullable(CalculateOrderDetailsResult.Surcharge::descriptionTranslated), - AllowNullable(CalculateOrderDetailsResult.Surcharge::id), - AllowNullable(CalculateOrderDetailsResult.Surcharge::taxable), - AllowNullable(CalculateOrderDetailsResult.Surcharge::taxes), - AllowNullable(CalculateOrderDetailsResult.Surcharge::total), - AllowNullable(CalculateOrderDetailsResult.Surcharge::totalWithoutTax), - AllowNullable(CalculateOrderDetailsResult.Surcharge::type), - AllowNullable(CalculateOrderDetailsResult.Surcharge::value), - IgnoreNullable(CalculateOrderDetailsResult.TaxInfo::appliedByDefault), - IgnoreNullable(CalculateOrderDetailsResult.TaxInfo::defaultTax), - IgnoreNullable(CalculateOrderDetailsResult.TaxInfo::enabled), - IgnoreNullable(CalculateOrderDetailsResult.TaxInfo::id), - IgnoreNullable(CalculateOrderDetailsResult.TaxInfo::includeInPrice), - IgnoreNullable(CalculateOrderDetailsResult.TaxInfo::name), - IgnoreNullable(CalculateOrderDetailsResult.TaxInfo::rules), - IgnoreNullable(CalculateOrderDetailsResult.TaxInfo::taxShipping), - IgnoreNullable(CalculateOrderDetailsResult.TaxInfo::useShippingAddress), - IgnoreNullable(CalculateOrderDetailsResult.TaxOnShipping::name), - IgnoreNullable(CalculateOrderDetailsResult.TaxOnShipping::total), - IgnoreNullable(CalculateOrderDetailsResult.TaxOnShipping::value), - IgnoreNullable(CalculateOrderDetailsResult.TaxRule::tax), - IgnoreNullable(CalculateOrderDetailsResult.TaxRule::zoneId), - IgnoreNullable(CalculateOrderDetailsResult::additionalInfo), - IgnoreNullable(CalculateOrderDetailsResult::availableShippingOptions), - IgnoreNullable(CalculateOrderDetailsResult::billingPerson), - IgnoreNullable(CalculateOrderDetailsResult::couponDiscount), - IgnoreNullable(CalculateOrderDetailsResult::createDate), - IgnoreNullable(CalculateOrderDetailsResult::createTimestamp), - IgnoreNullable(CalculateOrderDetailsResult::customerId), - AllowNullable(CalculateOrderDetailsResult::customerTaxExempt), - AllowNullable(CalculateOrderDetailsResult::customerTaxId), - AllowNullable(CalculateOrderDetailsResult::customerTaxIdValid), - AllowNullable(CalculateOrderDetailsResult::customSurcharges), - IgnoreNullable(CalculateOrderDetailsResult::discount), - IgnoreNullable(CalculateOrderDetailsResult::discountCoupon), - IgnoreNullable(CalculateOrderDetailsResult::discountInfo), - IgnoreNullable(CalculateOrderDetailsResult::email), - IgnoreNullable(CalculateOrderDetailsResult::handlingFee), - IgnoreNullable(CalculateOrderDetailsResult::hidden), - IgnoreNullable(CalculateOrderDetailsResult::ipAddress), - IgnoreNullable(CalculateOrderDetailsResult::items), - IgnoreNullable(CalculateOrderDetailsResult::membershipBasedDiscount), - IgnoreNullable(CalculateOrderDetailsResult::paymentParams), - AllowNullable(CalculateOrderDetailsResult::pricesIncludeTax), - AllowNullable(CalculateOrderDetailsResult::reversedTaxApplied), - IgnoreNullable(CalculateOrderDetailsResult::shippingOption), - IgnoreNullable(CalculateOrderDetailsResult::shippingPerson), - IgnoreNullable(CalculateOrderDetailsResult::subtotal), - AllowNullable(CalculateOrderDetailsResult::subtotalWithoutTax), - IgnoreNullable(CalculateOrderDetailsResult::tax), - IgnoreNullable(CalculateOrderDetailsResult::taxesOnShipping), - IgnoreNullable(CalculateOrderDetailsResult::total), - IgnoreNullable(CalculateOrderDetailsResult::totalAndMembershipBasedDiscount), - AllowNullable(CalculateOrderDetailsResult::totalBeforeGiftCardRedemption), - AllowNullable(CalculateOrderDetailsResult::giftCardRedemption), - AllowNullable(CalculateOrderDetailsResult::giftCardDoubleSpending), - AllowNullable(CalculateOrderDetailsResult::giftCardCode), - AllowNullable(CalculateOrderDetailsResult::giftCardId), - AllowNullable(CalculateOrderDetailsResult::giftCardUuid), - AllowNullable(CalculateOrderDetailsResult::totalWithoutTax), - IgnoreNullable(CalculateOrderDetailsResult::usdTotal), - IgnoreNullable(CalculateOrderDetailsResult::volumeDiscount) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CartsSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CartsSearchRequestRules.kt deleted file mode 100644 index f74eb1487..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CartsSearchRequestRules.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.cart.request.CartsSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val cartsSearchRequestNullablePropertyRules: List> = listOf( - IgnoreNullable(CartsSearchRequest::couponCode), - IgnoreNullable(CartsSearchRequest::createdFrom), - IgnoreNullable(CartsSearchRequest::createdTo), - IgnoreNullable(CartsSearchRequest::customer), - IgnoreNullable(CartsSearchRequest::showHidden), - IgnoreNullable(CartsSearchRequest::totalFrom), - IgnoreNullable(CartsSearchRequest::totalTo), - IgnoreNullable(CartsSearchRequest::updatedFrom), - IgnoreNullable(CartsSearchRequest::updatedTo) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoriesByPathRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoriesByPathRequestRules.kt deleted file mode 100644 index e417745b3..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoriesByPathRequestRules.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.category.request.CategoriesByPathRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val categoriesByPathRequestNullablePropertyRules: List> = listOf( - AllowNullable(CategoriesByPathRequest::lang) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoriesSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoriesSearchRequestRules.kt deleted file mode 100644 index 590e82cd9..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoriesSearchRequestRules.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.category.request.CategoriesSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val categoriesSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(CategoriesSearchRequest::baseUrl), - AllowNullable(CategoriesSearchRequest::categoryIds), - AllowNullable(CategoriesSearchRequest::parentCategoryIds), - AllowNullable(CategoriesSearchRequest::cleanUrls), - AllowNullable(CategoriesSearchRequest::slugsWithoutIds), - AllowNullable(CategoriesSearchRequest::hiddenCategories), - AllowNullable(CategoriesSearchRequest::keyword), - AllowNullable(CategoriesSearchRequest::lang), - AllowNullable(CategoriesSearchRequest::returnProductIds) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoryDetailsRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoryDetailsRequestRules.kt deleted file mode 100644 index 80757a767..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CategoryDetailsRequestRules.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.category.request.CategoryDetailsRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val categoryDetailsRequestNullablePropertyRules: List> = listOf( - AllowNullable(CategoryDetailsRequest::baseUrl), - AllowNullable(CategoryDetailsRequest::cleanUrls), - AllowNullable(CategoryDetailsRequest::slugsWithoutIds), - AllowNullable(CategoryDetailsRequest::lang) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CouponSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CouponSearchRequestRules.kt deleted file mode 100644 index 270cb1fed..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CouponSearchRequestRules.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.coupon.request.CouponSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val couponSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(CouponSearchRequest::availability), - AllowNullable(CouponSearchRequest::code), - AllowNullable(CouponSearchRequest::createdFrom), - AllowNullable(CouponSearchRequest::createdTo), - AllowNullable(CouponSearchRequest::discountType), - AllowNullable(CouponSearchRequest::updatedFrom), - AllowNullable(CouponSearchRequest::updatedTo) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomAppRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomAppRequestRules.kt deleted file mode 100644 index 0a0258d7a..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomAppRequestRules.kt +++ /dev/null @@ -1,195 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.custom.CustomAppRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val customAppRequestNullablePropertyRules: List> = listOf( - AllowNullable(CustomAppRequest.AttributeValue::id), - AllowNullable(CustomAppRequest.AttributeValue::name), - AllowNullable(CustomAppRequest.AttributeValue::show), - AllowNullable(CustomAppRequest.AttributeValue::type), - AllowNullable(CustomAppRequest.AttributeValue::value), - AllowNullable(CustomAppRequest.AttributeValue::valueTranslated), - AllowNullable(CustomAppRequest.BorderInfo::dominatingColor), - AllowNullable(CustomAppRequest.BorderInfo::homogeneity), - AllowNullable(CustomAppRequest.Cart::couponDiscount), - AllowNullable(CustomAppRequest.Cart::currency), - AllowNullable(CustomAppRequest.Cart::customerEmail), - AllowNullable(CustomAppRequest.Cart::customerGroup), - AllowNullable(CustomAppRequest.Cart::customerGroupId), - AllowNullable(CustomAppRequest.Cart::customerId), - AllowNullable(CustomAppRequest.Cart::dimensionUnit), - AllowNullable(CustomAppRequest.Cart::discount), - AllowNullable(CustomAppRequest.Cart::discountCoupon), - AllowNullable(CustomAppRequest.Cart::discountInfo), - AllowNullable(CustomAppRequest.Cart::extraFields), - AllowNullable(CustomAppRequest.Cart::fulfillmentStatus), - AllowNullable(CustomAppRequest.Cart::handlingFee), - AllowNullable(CustomAppRequest.Cart::hidden), - AllowNullable(CustomAppRequest.Cart::id), - AllowNullable(CustomAppRequest.Cart::ipAddress), - AllowNullable(CustomAppRequest.Cart::items), - AllowNullable(CustomAppRequest.Cart::membershipBasedDiscount), - AllowNullable(CustomAppRequest.Cart::orderComments), - AllowNullable(CustomAppRequest.Cart::orderNumber), - AllowNullable(CustomAppRequest.Cart::originAddress), - AllowNullable(CustomAppRequest.Cart::paymentMethod), - AllowNullable(CustomAppRequest.Cart::paymentStatus), - AllowNullable(CustomAppRequest.Cart::predictedPackages), - AllowNullable(CustomAppRequest.Cart::refererUrl), - AllowNullable(CustomAppRequest.Cart::shippingAddress), - AllowNullable(CustomAppRequest.Cart::subtotal), - AllowNullable(CustomAppRequest.Cart::totalAndMembershipBasedDiscount), - AllowNullable(CustomAppRequest.Cart::vendorOrderNumber), - AllowNullable(CustomAppRequest.Cart::volumeDiscount), - AllowNullable(CustomAppRequest.Cart::weight), - AllowNullable(CustomAppRequest.Cart::weightUnit), - AllowNullable(CustomAppRequest.Category::enabled), - AllowNullable(CustomAppRequest.Category::id), - AllowNullable(CustomAppRequest.Color::alpha), - AllowNullable(CustomAppRequest.Color::blue), - AllowNullable(CustomAppRequest.Color::green), - AllowNullable(CustomAppRequest.Color::red), - AllowNullable(CustomAppRequest.Discount::base), - AllowNullable(CustomAppRequest.Discount::description), - AllowNullable(CustomAppRequest.Discount::membershipId), - AllowNullable(CustomAppRequest.Discount::orderTotal), - AllowNullable(CustomAppRequest.Discount::type), - AllowNullable(CustomAppRequest.Discount::value), - AllowNullable(CustomAppRequest.DiscountCouponCatalogLimit::categories), - AllowNullable(CustomAppRequest.DiscountCouponCatalogLimit::products), - AllowNullable(CustomAppRequest.DiscountCouponInfo::applicationLimit), - AllowNullable(CustomAppRequest.DiscountCouponInfo::cartId), - AllowNullable(CustomAppRequest.DiscountCouponInfo::legacyCatalogLimit), - AllowNullable(CustomAppRequest.DiscountCouponInfo::catalogLimit), - AllowNullable(CustomAppRequest.DiscountCouponInfo::code), - AllowNullable(CustomAppRequest.DiscountCouponInfo::creationDate), - AllowNullable(CustomAppRequest.DiscountCouponInfo::customerId), - AllowNullable(CustomAppRequest.DiscountCouponInfo::discount), - AllowNullable(CustomAppRequest.DiscountCouponInfo::discountType), - AllowNullable(CustomAppRequest.DiscountCouponInfo::expirationDate), - AllowNullable(CustomAppRequest.DiscountCouponInfo::id), - AllowNullable(CustomAppRequest.DiscountCouponInfo::launchDate), - AllowNullable(CustomAppRequest.DiscountCouponInfo::name), - AllowNullable(CustomAppRequest.DiscountCouponInfo::newCustomerOnly), - AllowNullable(CustomAppRequest.DiscountCouponInfo::orderCount), - AllowNullable(CustomAppRequest.DiscountCouponInfo::ownerId), - AllowNullable(CustomAppRequest.DiscountCouponInfo::parentId), - AllowNullable(CustomAppRequest.DiscountCouponInfo::repeatCustomerOnly), - AllowNullable(CustomAppRequest.DiscountCouponInfo::status), - AllowNullable(CustomAppRequest.DiscountCouponInfo::totalLimit), - AllowNullable(CustomAppRequest.DiscountCouponInfo::updateDate), - AllowNullable(CustomAppRequest.DiscountCouponInfo::usesLimit), - AllowNullable(CustomAppRequest.FavoritesInfo::count), - AllowNullable(CustomAppRequest.FavoritesInfo::displayedCount), - AllowNullable(CustomAppRequest.GalleryImage::alt), - AllowNullable(CustomAppRequest.GalleryImage::borderInfo), - AllowNullable(CustomAppRequest.GalleryImage::thumbnail), - AllowNullable(CustomAppRequest.HandlingFeeInfo::description), - AllowNullable(CustomAppRequest.HandlingFeeInfo::name), - AllowNullable(CustomAppRequest.HandlingFeeInfo::value), - AllowNullable(CustomAppRequest.OrderItem::amount), - AllowNullable(CustomAppRequest.OrderItem::attributes), - AllowNullable(CustomAppRequest.OrderItem::borderInfo), - AllowNullable(CustomAppRequest.OrderItem::categories), - AllowNullable(CustomAppRequest.OrderItem::categoryId), - AllowNullable(CustomAppRequest.OrderItem::categoryIds), - AllowNullable(CustomAppRequest.OrderItem::combinations), - AllowNullable(CustomAppRequest.OrderItem::compareToPrice), - AllowNullable(CustomAppRequest.OrderItem::createTimestamp), - AllowNullable(CustomAppRequest.OrderItem::created), - AllowNullable(CustomAppRequest.OrderItem::defaultCategoryId), - AllowNullable(CustomAppRequest.OrderItem::defaultCombinationId), - AllowNullable(CustomAppRequest.OrderItem::dimensions), - AllowNullable(CustomAppRequest.OrderItem::discountsAllowed), - AllowNullable(CustomAppRequest.OrderItem::enabled), - AllowNullable(CustomAppRequest.OrderItem::favorites), - AllowNullable(CustomAppRequest.OrderItem::fixedShippingRate), - AllowNullable(CustomAppRequest.OrderItem::fixedShippingRateOnly), - AllowNullable(CustomAppRequest.OrderItem::galleryImages), - AllowNullable(CustomAppRequest.OrderItem::hdThumbnailUrl), - AllowNullable(CustomAppRequest.OrderItem::imageUrl), - AllowNullable(CustomAppRequest.OrderItem::inStock), - AllowNullable(CustomAppRequest.OrderItem::isShippingRequired), - AllowNullable(CustomAppRequest.OrderItem::name), - AllowNullable(CustomAppRequest.OrderItem::options), - AllowNullable(CustomAppRequest.OrderItem::originalImage), - AllowNullable(CustomAppRequest.OrderItem::originalImageUrl), - AllowNullable(CustomAppRequest.OrderItem::price), - AllowNullable(CustomAppRequest.OrderItem::priceInProductList), - AllowNullable(CustomAppRequest.OrderItem::productClassId), - AllowNullable(CustomAppRequest.OrderItem::productId), - AllowNullable(CustomAppRequest.OrderItem::combinationId), - AllowNullable(CustomAppRequest.OrderItem::productPrice), - AllowNullable(CustomAppRequest.OrderItem::quantity), - AllowNullable(CustomAppRequest.OrderItem::relatedProducts), - AllowNullable(CustomAppRequest.OrderItem::selectedOptions), - AllowNullable(CustomAppRequest.OrderItem::seoDescription), - AllowNullable(CustomAppRequest.OrderItem::seoTitle), - AllowNullable(CustomAppRequest.OrderItem::showOnFrontpage), - AllowNullable(CustomAppRequest.OrderItem::sku), - AllowNullable(CustomAppRequest.OrderItem::smallThumbnailUrl), - AllowNullable(CustomAppRequest.OrderItem::thumbnailUrl), - AllowNullable(CustomAppRequest.OrderItem::unlimited), - AllowNullable(CustomAppRequest.OrderItem::updateTimestamp), - AllowNullable(CustomAppRequest.OrderItem::updated), - AllowNullable(CustomAppRequest.OrderItem::url), - AllowNullable(CustomAppRequest.OrderItem::warningLimit), - AllowNullable(CustomAppRequest.OrderItem::weight), - AllowNullable(CustomAppRequest.OrderItem::wholesalePrices), - AllowNullable(CustomAppRequest.OrderItem::externalReferenceId), - AllowNullable(CustomAppRequest.OrderItemOption::files), - AllowNullable(CustomAppRequest.OrderItemOption::name), - AllowNullable(CustomAppRequest.OrderItemOption::nameTranslated), - AllowNullable(CustomAppRequest.OrderItemOption::selections), - AllowNullable(CustomAppRequest.OrderItemOption::type), - AllowNullable(CustomAppRequest.OrderItemOption::value), - AllowNullable(CustomAppRequest.OrderItemOption::valueTranslated), - AllowNullable(CustomAppRequest.OrderItemOption::valuesArray), - AllowNullable(CustomAppRequest.OrderItemOption::valuesArrayTranslated), - AllowNullable(CustomAppRequest.OriginAddress::city), - AllowNullable(CustomAppRequest.OriginAddress::countryCode), - AllowNullable(CustomAppRequest.OriginAddress::postalCode), - AllowNullable(CustomAppRequest.OriginAddress::stateOrProvinceCode), - AllowNullable(CustomAppRequest.OriginAddress::street), - AllowNullable(CustomAppRequest.ProductDimensions::height), - AllowNullable(CustomAppRequest.ProductDimensions::length), - AllowNullable(CustomAppRequest.ProductDimensions::width), - AllowNullable(CustomAppRequest.ProductOption::choices), - AllowNullable(CustomAppRequest.ProductOption::defaultChoice), - AllowNullable(CustomAppRequest.ProductOption::name), - AllowNullable(CustomAppRequest.ProductOption::required), - AllowNullable(CustomAppRequest.ProductOption::type), - AllowNullable(CustomAppRequest.ProductOptionChoice::priceModifier), - AllowNullable(CustomAppRequest.ProductOptionChoice::priceModifierType), - AllowNullable(CustomAppRequest.ProductOptionChoice::text), - AllowNullable(CustomAppRequest.RelatedCategory::categoryId), - AllowNullable(CustomAppRequest.RelatedCategory::enabled), - AllowNullable(CustomAppRequest.RelatedCategory::productCount), - AllowNullable(CustomAppRequest.RelatedProducts::productIds), - AllowNullable(CustomAppRequest.RelatedProducts::relatedCategory), - AllowNullable(CustomAppRequest.ShippingAddress::city), - AllowNullable(CustomAppRequest.ShippingAddress::countryCode), - AllowNullable(CustomAppRequest.ShippingAddress::postalCode), - AllowNullable(CustomAppRequest.ShippingAddress::stateOrProvinceCode), - AllowNullable(CustomAppRequest.ShippingAddress::stateOrProvinceName), - AllowNullable(CustomAppRequest.ShippingAddress::street), - AllowNullable(CustomAppRequest.ShippingOption::estimatedTransitTime), - AllowNullable(CustomAppRequest.ShippingOption::isPickup), - AllowNullable(CustomAppRequest.ShippingOption::pickupInstruction), - AllowNullable(CustomAppRequest.ShippingOption::shippingCarrierName), - AllowNullable(CustomAppRequest.ShippingOption::shippingMethodName), - AllowNullable(CustomAppRequest.ShippingOption::shippingRate), - AllowNullable(CustomAppRequest.ShippingPackage::declaredValue), - AllowNullable(CustomAppRequest.ShippingPackage::height), - AllowNullable(CustomAppRequest.ShippingPackage::length), - AllowNullable(CustomAppRequest.ShippingPackage::weight), - AllowNullable(CustomAppRequest.ShippingPackage::width), - AllowNullable(CustomAppRequest.WholesalePriceEntry::price), - AllowNullable(CustomAppRequest.WholesalePriceEntry::quantity), - AllowNullable(CustomAppRequest::cart), - AllowNullable(CustomAppRequest::merchantAppSettings), - AllowNullable(CustomAppRequest::storeId), - AllowNullable(CustomAppRequest::lang), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersIdsRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersIdsRequestRules.kt deleted file mode 100644 index 4780957eb..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersIdsRequestRules.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.customer.request.CustomersRequestFields -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val customersIdsRequestNullablePropertyRules: List> = listOf( - AllowNullable(CustomersRequestFields::keyword), - AllowNullable(CustomersRequestFields::maxOrderCount), - AllowNullable(CustomersRequestFields::minOrderCount), - AllowNullable(CustomersRequestFields::maxSalesValue), - AllowNullable(CustomersRequestFields::minSalesValue), - AllowNullable(CustomersRequestFields::purchasedProductIds), - AllowNullable(CustomersRequestFields::customerGroupIds), - AllowNullable(CustomersRequestFields::countryCodes), - AllowNullable(CustomersRequestFields::taxExempt), - AllowNullable(CustomersRequestFields::acceptMarketing), - AllowNullable(CustomersRequestFields::lang), - AllowNullable(CustomersRequestFields::checkOnlyCustomerId), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersMassUpdateRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersMassUpdateRequestRules.kt deleted file mode 100644 index c430ed361..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersMassUpdateRequestRules.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.customer.request.CustomersRequestFields -import com.ecwid.apiclient.v3.dto.customer.request.MassUpdateCustomer -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - - -val customersMassUpdatedRequestNullablePropertyRules: List> = listOf( - AllowNullable(CustomersRequestFields::keyword), - AllowNullable(CustomersRequestFields::maxOrderCount), - AllowNullable(CustomersRequestFields::minOrderCount), - AllowNullable(CustomersRequestFields::maxSalesValue), - AllowNullable(CustomersRequestFields::minSalesValue), - AllowNullable(CustomersRequestFields::purchasedProductIds), - AllowNullable(CustomersRequestFields::customerGroupIds), - AllowNullable(CustomersRequestFields::countryCodes), - AllowNullable(CustomersRequestFields::taxExempt), - AllowNullable(CustomersRequestFields::acceptMarketing), - AllowNullable(CustomersRequestFields::lang), - AllowNullable(CustomersRequestFields::checkOnlyCustomerId), - - AllowNullable(MassUpdateCustomer::ids), - AllowNullable(MassUpdateCustomer::delete), - AllowNullable(MassUpdateCustomer::customer), - - AllowNullable(MassUpdateCustomer.UpdatedCustomer::customerGroupId), - AllowNullable(MassUpdateCustomer.UpdatedCustomer::taxExempt), - AllowNullable(MassUpdateCustomer.UpdatedCustomer::acceptMarketing), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersSearchRequestRules.kt deleted file mode 100644 index 532e6fe8d..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/CustomersSearchRequestRules.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.customer.request.CustomersSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val customersSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(CustomersSearchRequest::createdFrom), - AllowNullable(CustomersSearchRequest::createdTo), - AllowNullable(CustomersSearchRequest::customerGroupId), - AllowNullable(CustomersSearchRequest::email), - AllowNullable(CustomersSearchRequest::keyword), - AllowNullable(CustomersSearchRequest::usePrecalculatedOrderCount), - AllowNullable(CustomersSearchRequest::maxOrderCount), - AllowNullable(CustomersSearchRequest::minOrderCount), - AllowNullable(CustomersSearchRequest::maxSalesValue), - AllowNullable(CustomersSearchRequest::minSalesValue), - AllowNullable(CustomersSearchRequest::name), - AllowNullable(CustomersSearchRequest::sortBy), - AllowNullable(CustomersSearchRequest::updatedFrom), - AllowNullable(CustomersSearchRequest::updatedTo), - AllowNullable(CustomersSearchRequest::purchasedProductIds), - AllowNullable(CustomersSearchRequest::customerGroupIds), - AllowNullable(CustomersSearchRequest::companyName), - AllowNullable(CustomersSearchRequest::countryCodes), - AllowNullable(CustomersSearchRequest::city), - AllowNullable(CustomersSearchRequest::postalCode), - AllowNullable(CustomersSearchRequest::stateOrProvinceCode), - AllowNullable(CustomersSearchRequest::phone), - AllowNullable(CustomersSearchRequest::taxExempt), - AllowNullable(CustomersSearchRequest::acceptMarketing), - AllowNullable(CustomersSearchRequest::lang), - AllowNullable(CustomersSearchRequest::checkOnlyCustomerId), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedCustomersSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedCustomersSearchRequestRules.kt deleted file mode 100644 index bf0dee49a..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedCustomersSearchRequestRules.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.customer.request.DeletedCustomersSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val deletedCustomersSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(DeletedCustomersSearchRequest::deletedFrom), - AllowNullable(DeletedCustomersSearchRequest::deletedTo) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedOrdersSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedOrdersSearchRequestRules.kt deleted file mode 100644 index 89bbd1989..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedOrdersSearchRequestRules.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.order.request.DeletedOrdersSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val deletedOrdersSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(DeletedOrdersSearchRequest::deletedFrom), - AllowNullable(DeletedOrdersSearchRequest::deletedTo) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedProductsSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedProductsSearchRequestRules.kt deleted file mode 100644 index 1f46b01da..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/DeletedProductsSearchRequestRules.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.product.request.DeletedProductsSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val deletedProductsSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(DeletedProductsSearchRequest::deletedFrom), - AllowNullable(DeletedProductsSearchRequest::deletedTo) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedBrandRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedBrandRules.kt deleted file mode 100644 index 6b15f06f1..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedBrandRules.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.brand.result.FetchedBrand -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val fetchedBrandNullablePropertyRules: List> = listOf( - AllowNullable(FetchedBrand::nameTranslated), - AllowNullable(FetchedBrand::productsFilteredByBrandUrl), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCartRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCartRules.kt deleted file mode 100644 index 04c7a72a6..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCartRules.kt +++ /dev/null @@ -1,182 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.cart.result.FetchedCart -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.* - -val fetchedCartNullablePropertyRules: List> = listOf( - IgnoreNullable(FetchedCart::acceptMarketing), - IgnoreNullable(FetchedCart::additionalInfo), - IgnoreNullable(FetchedCart::affiliateId), - IgnoreNullable(FetchedCart::billingPerson), - IgnoreNullable(FetchedCart::couponDiscount), - IgnoreNullable(FetchedCart::createDate), - IgnoreNullable(FetchedCart::createTimestamp), - IgnoreNullable(FetchedCart::creditCardStatus), - IgnoreNullable(FetchedCart::customerGroup), - IgnoreNullable(FetchedCart::customerGroupId), - IgnoreNullable(FetchedCart::customerId), - IgnoreNullable(FetchedCart::customerTaxExempt), - IgnoreNullable(FetchedCart::customerTaxId), - IgnoreNullable(FetchedCart::customerTaxIdValid), - IgnoreNullable(FetchedCart::discount), - IgnoreNullable(FetchedCart::discountCoupon), - IgnoreNullable(FetchedCart::discountInfo), - IgnoreNullable(FetchedCart::email), - IgnoreNullable(FetchedCart::externalTransactionId), - IgnoreNullable(FetchedCart::globalReferer), - IgnoreNullable(FetchedCart::handlingFee), - IgnoreNullable(FetchedCart::hidden), - IgnoreNullable(FetchedCart::ipAddress), - IgnoreNullable(FetchedCart::items), - IgnoreNullable(FetchedCart::membershipBasedDiscount), - IgnoreNullable(FetchedCart::orderComments), - IgnoreNullable(FetchedCart::paymentMessage), - IgnoreNullable(FetchedCart::paymentMethod), - IgnoreNullable(FetchedCart::paymentModule), - IgnoreNullable(FetchedCart::paymentParams), - IgnoreNullable(FetchedCart::recoveredOrderId), - IgnoreNullable(FetchedCart::recoveredPublicUid), - IgnoreNullable(FetchedCart::recoveryEmailSentTimestamp), - IgnoreNullable(FetchedCart::refererUrl), - IgnoreNullable(FetchedCart::reversedTaxApplied), - IgnoreNullable(FetchedCart::shippingOption), - IgnoreNullable(FetchedCart::shippingPerson), - IgnoreNullable(FetchedCart::subtotal), - IgnoreNullable(FetchedCart::tax), - IgnoreNullable(FetchedCart::taxesOnShipping), - IgnoreNullable(FetchedCart::total), - IgnoreNullable(FetchedCart::totalAndMembershipBasedDiscount), - IgnoreNullable(FetchedCart::trackingNumber), - AllowNullable(FetchedCart::trackingUrl), - IgnoreNullable(FetchedCart::updateDate), - IgnoreNullable(FetchedCart::updateTimestamp), - IgnoreNullable(FetchedCart::usdTotal), - AllowNullable(FetchedCart::giftCardCode), - AllowNullable(FetchedCart::giftCardDoubleSpending), - AllowNullable(FetchedCart::giftCardId), - AllowNullable(FetchedCart::giftCardUuid), - AllowNullable(FetchedCart::giftCardRedemption), - AllowNullable(FetchedCart::totalBeforeGiftCardRedemption), - IgnoreNullable(FetchedCart::utmData), - IgnoreNullable(FetchedCart::volumeDiscount), - IgnoreNullable(FetchedCart.CreditCardStatus::avsMessage), - IgnoreNullable(FetchedCart.CreditCardStatus::cvvMessage), - IgnoreNullable(FetchedCart.DiscountCouponCatalogLimit::categories), - IgnoreNullable(FetchedCart.DiscountCouponCatalogLimit::products), - IgnoreNullable(FetchedCart.DiscountCouponInfo::applicationLimit), - IgnoreNullable(FetchedCart.DiscountCouponInfo::catalogLimit), - IgnoreNullable(FetchedCart.DiscountCouponInfo::code), - IgnoreNullable(FetchedCart.DiscountCouponInfo::creationDate), - IgnoreNullable(FetchedCart.DiscountCouponInfo::discount), - IgnoreNullable(FetchedCart.DiscountCouponInfo::discountType), - IgnoreNullable(FetchedCart.DiscountCouponInfo::expirationDate), - IgnoreNullable(FetchedCart.DiscountCouponInfo::launchDate), - IgnoreNullable(FetchedCart.DiscountCouponInfo::name), - IgnoreNullable(FetchedCart.DiscountCouponInfo::orderCount), - IgnoreNullable(FetchedCart.DiscountCouponInfo::status), - IgnoreNullable(FetchedCart.DiscountCouponInfo::totalLimit), - IgnoreNullable(FetchedCart.DiscountCouponInfo::usesLimit), - IgnoreNullable(FetchedCart.DiscountInfo::base), - IgnoreNullable(FetchedCart.DiscountInfo::description), - IgnoreNullable(FetchedCart.DiscountInfo::orderTotal), - IgnoreNullable(FetchedCart.DiscountInfo::type), - IgnoreNullable(FetchedCart.DiscountInfo::value), - IgnoreNullable(FetchedCart.HandlingFeeInfo::description), - IgnoreNullable(FetchedCart.HandlingFeeInfo::name), - IgnoreNullable(FetchedCart.HandlingFeeInfo::value), - IgnoreNullable(FetchedCart.OrderItem::categoryId), - IgnoreNullable(FetchedCart.OrderItem::couponAmount), - IgnoreNullable(FetchedCart.OrderItem::couponApplied), - AllowNullable(FetchedCart.OrderItem::giftCard), - IgnoreNullable(FetchedCart.OrderItem::digital), - IgnoreNullable(FetchedCart.OrderItem::dimensions), - IgnoreNullable(FetchedCart.OrderItem::discounts), - IgnoreNullable(FetchedCart.OrderItem::files), - IgnoreNullable(FetchedCart.OrderItem::fixedShippingRate), - IgnoreNullable(FetchedCart.OrderItem::fixedShippingRateOnly), - IgnoreNullable(FetchedCart.OrderItem::id), - IgnoreNullable(FetchedCart.OrderItem::imageUrl), - IgnoreNullable(FetchedCart.OrderItem::isShippingRequired), - IgnoreNullable(FetchedCart.OrderItem::name), - IgnoreNullable(FetchedCart.OrderItem::price), - IgnoreNullable(FetchedCart.OrderItem::productId), - IgnoreNullable(FetchedCart.OrderItem::productPrice), - IgnoreNullable(FetchedCart.OrderItem::quantity), - IgnoreNullable(FetchedCart.OrderItem::quantityInStock), - IgnoreNullable(FetchedCart.OrderItem::selectedOptions), - AllowNullable(FetchedCart.OrderItem::combinationId), - IgnoreNullable(FetchedCart.OrderItem::shipping), - IgnoreNullable(FetchedCart.OrderItem::shortDescription), - IgnoreNullable(FetchedCart.OrderItem::sku), - IgnoreNullable(FetchedCart.OrderItem::tax), - IgnoreNullable(FetchedCart.OrderItem::taxes), - IgnoreNullable(FetchedCart.OrderItem::trackQuantity), - IgnoreNullable(FetchedCart.OrderItem::weight), - IgnoreNullable(FetchedCart.OrderItem::externalReferenceId), - IgnoreNullable(FetchedCart.OrderItemDiscountInfo::base), - IgnoreNullable(FetchedCart.OrderItemDiscountInfo::orderTotal), - IgnoreNullable(FetchedCart.OrderItemDiscountInfo::type), - IgnoreNullable(FetchedCart.OrderItemDiscountInfo::value), - IgnoreNullable(FetchedCart.OrderItemDiscounts::discountInfo), - IgnoreNullable(FetchedCart.OrderItemDiscounts::total), - IgnoreNullable(FetchedCart.OrderItemOptionFile::id), - IgnoreNullable(FetchedCart.OrderItemOptionFile::name), - IgnoreNullable(FetchedCart.OrderItemOptionFile::size), - IgnoreNullable(FetchedCart.OrderItemOptionFile::url), - IgnoreNullable(FetchedCart.OrderItemOption::files), - IgnoreNullable(FetchedCart.OrderItemOption::name), - IgnoreNullable(FetchedCart.OrderItemOption::selections), - IgnoreNullable(FetchedCart.OrderItemOption::type), - IgnoreNullable(FetchedCart.OrderItemOption::value), - IgnoreNullable(FetchedCart.OrderItemOption::valuesArray), - IgnoreNullable(FetchedCart.OrderItemProductFile::adminUrl), - IgnoreNullable(FetchedCart.OrderItemProductFile::customerUrl), - IgnoreNullable(FetchedCart.OrderItemProductFile::description), - IgnoreNullable(FetchedCart.OrderItemProductFile::expire), - IgnoreNullable(FetchedCart.OrderItemProductFile::maxDownloads), - IgnoreNullable(FetchedCart.OrderItemProductFile::name), - IgnoreNullable(FetchedCart.OrderItemProductFile::productFileId), - IgnoreNullable(FetchedCart.OrderItemProductFile::remainingDownloads), - IgnoreNullable(FetchedCart.OrderItemProductFile::size), - AllowNullable(FetchedCart.OrderItemTax::taxType), - IgnoreNullable(FetchedCart.OrderItemTax::includeInPrice), - IgnoreNullable(FetchedCart.OrderItemTax::name), - IgnoreNullable(FetchedCart.OrderItemTax::taxOnDiscountedSubtotal), - IgnoreNullable(FetchedCart.OrderItemTax::taxOnShipping), - IgnoreNullable(FetchedCart.OrderItemTax::total), - IgnoreNullable(FetchedCart.OrderItemTax::value), - IgnoreNullable(FetchedCart.PersonInfo::city), - IgnoreNullable(FetchedCart.PersonInfo::companyName), - IgnoreNullable(FetchedCart.PersonInfo::countryCode), - IgnoreNullable(FetchedCart.PersonInfo::countryName), - IgnoreNullable(FetchedCart.PersonInfo::firstName), - IgnoreNullable(FetchedCart.PersonInfo::lastName), - IgnoreNullable(FetchedCart.PersonInfo::name), - IgnoreNullable(FetchedCart.PersonInfo::phone), - IgnoreNullable(FetchedCart.PersonInfo::postalCode), - IgnoreNullable(FetchedCart.PersonInfo::stateOrProvinceCode), - IgnoreNullable(FetchedCart.PersonInfo::stateOrProvinceName), - IgnoreNullable(FetchedCart.PersonInfo::street), - IgnoreNullable(FetchedCart.ProductDimensions::height), - IgnoreNullable(FetchedCart.ProductDimensions::length), - IgnoreNullable(FetchedCart.ProductDimensions::width), - IgnoreNullable(FetchedCart.SelectionInfo::selectionModifier), - IgnoreNullable(FetchedCart.SelectionInfo::selectionModifierType), - IgnoreNullable(FetchedCart.SelectionInfo::selectionTitle), - AllowNullable(FetchedCart.ShippingOptionInfo::shippingMethodId), - IgnoreNullable(FetchedCart.ShippingOptionInfo::estimatedTransitTime), - IgnoreNullable(FetchedCart.ShippingOptionInfo::isPickup), - IgnoreNullable(FetchedCart.ShippingOptionInfo::pickupInstruction), - IgnoreNullable(FetchedCart.ShippingOptionInfo::shippingCarrierName), - IgnoreNullable(FetchedCart.ShippingOptionInfo::shippingMethodName), - IgnoreNullable(FetchedCart.ShippingOptionInfo::shippingRate), - IgnoreNullable(FetchedCart.TaxOnShipping::name), - IgnoreNullable(FetchedCart.TaxOnShipping::total), - IgnoreNullable(FetchedCart.TaxOnShipping::value), - IgnoreNullable(FetchedCart.UtmData::campaign), - IgnoreNullable(FetchedCart.UtmData::mcCid), - IgnoreNullable(FetchedCart.UtmData::mcEid), - IgnoreNullable(FetchedCart.UtmData::medium), - IgnoreNullable(FetchedCart.UtmData::source) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCategoryRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCategoryRules.kt deleted file mode 100644 index d8c7f17fc..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCategoryRules.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.category.result.FetchedCategory -import com.ecwid.apiclient.v3.dto.common.FetchedAlt -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val fetchedCategoryNullablePropertyRules: List> = listOf( - IgnoreNullable(FetchedCategory::description), - IgnoreNullable(FetchedCategory::descriptionTranslated), - IgnoreNullable(FetchedCategory::enabledProductCount), - IgnoreNullable(FetchedCategory::hdThumbnailUrl), - IgnoreNullable(FetchedCategory::imageUrl), - IgnoreNullable(FetchedCategory::isSampleCategory), - IgnoreNullable(FetchedCategory::nameTranslated), - IgnoreNullable(FetchedCategory::orderBy), - IgnoreNullable(FetchedCategory::originalImage), - IgnoreNullable(FetchedCategory::originalImageUrl), - IgnoreNullable(FetchedCategory::parentId), - IgnoreNullable(FetchedCategory::productCount), - IgnoreNullable(FetchedCategory::productIds), - IgnoreNullable(FetchedCategory::thumbnailUrl), - IgnoreNullable(FetchedCategory::url), - AllowNullable(FetchedCategory::productCountWithoutSubcategories), - AllowNullable(FetchedCategory::seoTitle), - AllowNullable(FetchedCategory::seoTitleTranslated), - AllowNullable(FetchedCategory::seoDescription), - AllowNullable(FetchedCategory::customSlug), - AllowNullable(FetchedCategory::seoDescriptionTranslated), - AllowNullable(FetchedCategory::alt), - AllowNullable(FetchedAlt::main), - AllowNullable(FetchedAlt::translated), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCouponRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCouponRules.kt deleted file mode 100644 index d1b80a82c..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCouponRules.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.coupon.result.FetchedCoupon -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val fetchedCouponNullablePropertyRules: List> = listOf( - IgnoreNullable(FetchedCoupon::applicationLimit), - IgnoreNullable(FetchedCoupon::catalogLimit), - IgnoreNullable(FetchedCoupon::creationDate), - IgnoreNullable(FetchedCoupon::discount), - IgnoreNullable(FetchedCoupon::discountType), - IgnoreNullable(FetchedCoupon::expirationDate), - IgnoreNullable(FetchedCoupon::launchDate), - IgnoreNullable(FetchedCoupon::orderCount), - IgnoreNullable(FetchedCoupon::repeatCustomerOnly), - IgnoreNullable(FetchedCoupon::status), - IgnoreNullable(FetchedCoupon::totalLimit), - IgnoreNullable(FetchedCoupon::updateDate), - IgnoreNullable(FetchedCoupon::usesLimit), - IgnoreNullable(FetchedCoupon.DiscountCouponCatalogLimit::categories), - IgnoreNullable(FetchedCoupon.DiscountCouponCatalogLimit::products) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomerRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomerRules.kt deleted file mode 100644 index 45bec35e6..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomerRules.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.customer.result.CustomerFilterShippingAddress -import com.ecwid.apiclient.v3.dto.customer.result.FetchedCustomer -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val fetchedCustomerNullablePropertyRules: List> = listOf( - IgnoreNullable(FetchedCustomer::acceptMarketing), - IgnoreNullable(FetchedCustomer::billingPerson), - IgnoreNullable(FetchedCustomer::customerGroupId), - IgnoreNullable(FetchedCustomer::customerGroupName), - AllowNullable(FetchedCustomer::lang), - AllowNullable(FetchedCustomer::privateAdminNotes), - IgnoreNullable(FetchedCustomer::registered), - IgnoreNullable(FetchedCustomer::shippingAddresses), - IgnoreNullable(FetchedCustomer::taxExempt), - IgnoreNullable(FetchedCustomer::taxId), - IgnoreNullable(FetchedCustomer::taxIdValid), - IgnoreNullable(FetchedCustomer::updated), - IgnoreNullable(FetchedCustomer.BillingPerson::city), - IgnoreNullable(FetchedCustomer.BillingPerson::companyName), - IgnoreNullable(FetchedCustomer.BillingPerson::countryCode), - IgnoreNullable(FetchedCustomer.BillingPerson::countryName), - IgnoreNullable(FetchedCustomer.BillingPerson::firstName), - IgnoreNullable(FetchedCustomer.BillingPerson::lastName), - IgnoreNullable(FetchedCustomer.BillingPerson::name), - IgnoreNullable(FetchedCustomer.BillingPerson::phone), - IgnoreNullable(FetchedCustomer.BillingPerson::postalCode), - IgnoreNullable(FetchedCustomer.BillingPerson::stateOrProvinceCode), - IgnoreNullable(FetchedCustomer.BillingPerson::stateOrProvinceName), - IgnoreNullable(FetchedCustomer.BillingPerson::street), - IgnoreNullable(FetchedCustomer.ShippingAddress::city), - IgnoreNullable(FetchedCustomer.ShippingAddress::companyName), - IgnoreNullable(FetchedCustomer.ShippingAddress::countryCode), - IgnoreNullable(FetchedCustomer.ShippingAddress::countryName), - IgnoreNullable(FetchedCustomer.ShippingAddress::id), - IgnoreNullable(FetchedCustomer.ShippingAddress::name), - IgnoreNullable(FetchedCustomer.ShippingAddress::phone), - IgnoreNullable(FetchedCustomer.ShippingAddress::postalCode), - IgnoreNullable(FetchedCustomer.ShippingAddress::stateOrProvinceCode), - IgnoreNullable(FetchedCustomer.ShippingAddress::stateOrProvinceName), - IgnoreNullable(FetchedCustomer.ShippingAddress::street), - AllowNullable(FetchedCustomer.ShippingAddress::note), - AllowNullable(FetchedCustomer.ShippingAddress::createdDate), - AllowNullable(FetchedCustomer.ShippingAddress::defaultAddress), - AllowNullable(FetchedCustomer.ShippingAddress::orderBy), - AllowNullable(FetchedCustomer.ShippingAddress::addressFormatted), - AllowNullable(FetchedCustomer::stats), - AllowNullable(FetchedCustomer.CustomerStats::firstOrderDate), - AllowNullable(FetchedCustomer.CustomerStats::lastOrderDate), - AllowNullable(FetchedCustomer::contacts), - AllowNullable(FetchedCustomer.CustomerContact::handle), - AllowNullable(FetchedCustomer.CustomerContact::note), - AllowNullable(FetchedCustomer.CustomerContact::timestamp), - AllowNullable(FetchedCustomer.CustomerFavorite::addedTimestamp), - AllowNullable(FetchedCustomer::extrafields), - AllowNullable(FetchedCustomer.CustomerExtrafield::key), - AllowNullable(FetchedCustomer.CustomerExtrafield::title), - AllowNullable(FetchedCustomer.CustomerExtrafield::value), - AllowNullable(FetchedCustomer.CustomerExtrafield::type), - - AllowNullable(CustomerFilterShippingAddress::street), - AllowNullable(CustomerFilterShippingAddress::city), - AllowNullable(CustomerFilterShippingAddress::countryCode), - AllowNullable(CustomerFilterShippingAddress::countryName), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomersConfigRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomersConfigRules.kt deleted file mode 100644 index 3d5af974f..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedCustomersConfigRules.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.extrafield.result.FetchedCustomersConfig -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val fetchedCustomersConfigNullablePropertyRules: List> = listOf( - AllowNullable(FetchedCustomersConfig::key), - AllowNullable(FetchedCustomersConfig::title), - AllowNullable(FetchedCustomersConfig::entityTypes), - AllowNullable(FetchedCustomersConfig::type), - AllowNullable(FetchedCustomersConfig::shownOnOrderDetails), - AllowNullable(FetchedCustomersConfig::linkedWithCheckoutField), - AllowNullable(FetchedCustomersConfig::createdDate), - AllowNullable(FetchedCustomersConfig::lastModifiedDate), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedExtrafieldConfigRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedExtrafieldConfigRules.kt deleted file mode 100644 index ee1289fda..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedExtrafieldConfigRules.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.profile.result.FetchedExtrafieldConfig -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val fetchedExtrafieldConfigNullablePropertyRules: List> = listOf( - AllowNullable(FetchedExtrafieldConfig::type), - AllowNullable(FetchedExtrafieldConfig::textPlaceholder), - AllowNullable(FetchedExtrafieldConfig::tip), - AllowNullable(FetchedExtrafieldConfig::options), - AllowNullable(FetchedExtrafieldConfig::value), - AllowNullable(FetchedExtrafieldConfig::available), - AllowNullable(FetchedExtrafieldConfig::required), - AllowNullable(FetchedExtrafieldConfig::orderDetailsDisplaySection), - AllowNullable(FetchedExtrafieldConfig::showForCountry), - AllowNullable(FetchedExtrafieldConfig::showForPaymentMethodIds), - AllowNullable(FetchedExtrafieldConfig::showForShippingMethodIds), - AllowNullable(FetchedExtrafieldConfig::showInInvoice), - AllowNullable(FetchedExtrafieldConfig::showInNotifications), - AllowNullable(FetchedExtrafieldConfig::orderBy), - AllowNullable(FetchedExtrafieldConfig::surchargeType), - AllowNullable(FetchedExtrafieldConfig::surchargeTaxable), - AllowNullable(FetchedExtrafieldConfig::showZeroSurchargeInTotal), - AllowNullable(FetchedExtrafieldConfig::surchargeShortName), - AllowNullable(FetchedExtrafieldConfig::titleTranslated), - AllowNullable(FetchedExtrafieldConfig::textPlaceholderTranslated), - AllowNullable(FetchedExtrafieldConfig::tipTranslated), - AllowNullable(FetchedExtrafieldConfig::valueTranslated), - AllowNullable(FetchedExtrafieldConfig::saveToCustomerProfile), - - AllowNullable(FetchedExtrafieldConfig.FetchedExtrafieldOptionConfig::subtitle), - AllowNullable(FetchedExtrafieldConfig.FetchedExtrafieldOptionConfig::subtitleTranslated), - AllowNullable(FetchedExtrafieldConfig.FetchedExtrafieldOptionConfig::surcharge), - AllowNullable(FetchedExtrafieldConfig.FetchedExtrafieldOptionConfig::title), - AllowNullable(FetchedExtrafieldConfig.FetchedExtrafieldOptionConfig::titleTranslated), - AllowNullable(FetchedExtrafieldConfig.FetchedExtrafieldSurchargeConfig::name), - AllowNullable(FetchedExtrafieldConfig.FetchedExtrafieldSurchargeConfig::nameTranslated), - AllowNullable(FetchedExtrafieldConfig.FetchedExtrafieldSurchargeConfig::showSurchargePercentValue), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt deleted file mode 100644 index b146cc8a5..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderRules.kt +++ /dev/null @@ -1,330 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.order.result.FetchedOrder -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val fetchedOrderNullablePropertyRules: List> = listOf( - AllowNullable(FetchedOrder.BaseOrderItemTax::name), - AllowNullable(FetchedOrder.BaseOrderItemTax::total), - AllowNullable(FetchedOrder.BaseOrderItemTax::value), - AllowNullable(FetchedOrder.BaseOrderItemTax::taxType), - AllowNullable(FetchedOrder.BaseOrderItemTax::includeInPrice), - AllowNullable(FetchedOrder.HandlingFeeTax::name), - AllowNullable(FetchedOrder.HandlingFeeTax::total), - AllowNullable(FetchedOrder.HandlingFeeTax::value), - AllowNullable(FetchedOrder.HandlingFeeTax::includeInPrice), - AllowNullable(FetchedOrder::latestShipDate), - AllowNullable(FetchedOrder::paymentSubtype), - IgnoreNullable(FetchedOrder::publicUid), - IgnoreNullable(FetchedOrder.CreditCardStatus::avsMessage), - IgnoreNullable(FetchedOrder.CreditCardStatus::cvvMessage), - IgnoreNullable(FetchedOrder.DiscountCouponCatalogLimit::categories), - IgnoreNullable(FetchedOrder.DiscountCouponCatalogLimit::products), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::applicationLimit), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::catalogLimit), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::code), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::creationDate), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::discount), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::discountType), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::expirationDate), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::id), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::launchDate), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::name), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::orderCount), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::repeatCustomerOnly), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::status), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::totalLimit), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::updateDate), - IgnoreNullable(FetchedOrder.DiscountCouponInfo::usesLimit), - IgnoreNullable(FetchedOrder.DiscountInfo::base), - IgnoreNullable(FetchedOrder.DiscountInfo::description), - IgnoreNullable(FetchedOrder.DiscountInfo::orderTotal), - IgnoreNullable(FetchedOrder.DiscountInfo::type), - IgnoreNullable(FetchedOrder.DiscountInfo::value), - AllowNullable(FetchedOrder.DiscountInfo::appliesToProducts), - AllowNullable(FetchedOrder.DiscountInfo::appliesToItems), - AllowNullable(FetchedOrder.ExtraFieldsInfo::customerInputType), - AllowNullable(FetchedOrder.ExtraFieldsInfo::id), - AllowNullable(FetchedOrder.ExtraFieldsInfo::orderBy), - AllowNullable(FetchedOrder.ExtraFieldsInfo::orderDetailsDisplaySection), - AllowNullable(FetchedOrder.ExtraFieldsInfo::title), - AllowNullable(FetchedOrder.ExtraFieldsInfo::value), - IgnoreNullable(FetchedOrder.HandlingFee::description), - IgnoreNullable(FetchedOrder.HandlingFee::name), - IgnoreNullable(FetchedOrder.HandlingFee::value), - IgnoreNullable(FetchedOrder.OrderItem::categoryId), - IgnoreNullable(FetchedOrder.OrderItem::couponAmount), - IgnoreNullable(FetchedOrder.OrderItem::couponApplied), - IgnoreNullable(FetchedOrder.OrderItem::digital), - IgnoreNullable(FetchedOrder.OrderItem::dimensions), - IgnoreNullable(FetchedOrder.OrderItem::discounts), - AllowNullable(FetchedOrder.OrderItem::discountsAllowed), - AllowNullable(FetchedOrder.OrderItem::files), - IgnoreNullable(FetchedOrder.OrderItem::fixedShippingRate), - IgnoreNullable(FetchedOrder.OrderItem::fixedShippingRateOnly), - IgnoreNullable(FetchedOrder.OrderItem::hdThumbnailUrl), - IgnoreNullable(FetchedOrder.OrderItem::id), - IgnoreNullable(FetchedOrder.OrderItem::imageUrl), - AllowNullable(FetchedOrder.OrderItem::isCustomerSetPrice), - AllowNullable(FetchedOrder.OrderItem::giftCard), - IgnoreNullable(FetchedOrder.OrderItem::isShippingRequired), - IgnoreNullable(FetchedOrder.OrderItem::name), - AllowNullable(FetchedOrder.OrderItem::nameTranslated), - IgnoreNullable(FetchedOrder.OrderItem::price), - AllowNullable(FetchedOrder.OrderItem::priceWithoutTax), - IgnoreNullable(FetchedOrder.OrderItem::productAvailable), - IgnoreNullable(FetchedOrder.OrderItem::productId), - IgnoreNullable(FetchedOrder.OrderItem::productPrice), - IgnoreNullable(FetchedOrder.OrderItem::quantity), - IgnoreNullable(FetchedOrder.OrderItem::quantityInStock), - IgnoreNullable(FetchedOrder.OrderItem::recurringChargeSettings), - AllowNullable(FetchedOrder.RecurringChargeSettings::subscriptionPriceWithSignUpFee), - AllowNullable(FetchedOrder.RecurringChargeSettings::signUpFee), - IgnoreNullable(FetchedOrder.OrderItem::selectedOptions), - AllowNullable(FetchedOrder.OrderItem::combinationId), - AllowNullable(FetchedOrder.OrderItem::selectedPrice), - IgnoreNullable(FetchedOrder.OrderItem::shipping), - IgnoreNullable(FetchedOrder.OrderItem::shortDescription), - AllowNullable(FetchedOrder.OrderItem::shortDescriptionTranslated), - IgnoreNullable(FetchedOrder.OrderItem::sku), - IgnoreNullable(FetchedOrder.OrderItem::smallThumbnailUrl), - IgnoreNullable(FetchedOrder.OrderItem::subscriptionId), - IgnoreNullable(FetchedOrder.OrderItem::tax), - AllowNullable(FetchedOrder.OrderItem::taxable), - IgnoreNullable(FetchedOrder.OrderItem::taxes), - IgnoreNullable(FetchedOrder.OrderItem::trackQuantity), - IgnoreNullable(FetchedOrder.OrderItem::weight), - IgnoreNullable(FetchedOrder.OrderItem::externalReferenceId), - AllowNullable(FetchedOrder.OrderItem::isPreorder), - AllowNullable(FetchedOrder.OrderItem::attributes), - IgnoreNullable(FetchedOrder.OrderItemDiscounts::discountInfo), - IgnoreNullable(FetchedOrder.OrderItemDiscounts::total), - AllowNullable(FetchedOrder.OrderItemOptionFile::id), - AllowNullable(FetchedOrder.OrderItemOptionFile::name), - AllowNullable(FetchedOrder.OrderItemOptionFile::size), - AllowNullable(FetchedOrder.OrderItemOptionFile::url), - AllowNullable(FetchedOrder.OrderItemProductFile::adminUrl), - AllowNullable(FetchedOrder.OrderItemProductFile::customerUrl), - AllowNullable(FetchedOrder.OrderItemProductFile::description), - AllowNullable(FetchedOrder.OrderItemProductFile::expire), - AllowNullable(FetchedOrder.OrderItemProductFile::maxDownloads), - AllowNullable(FetchedOrder.OrderItemProductFile::name), - AllowNullable(FetchedOrder.OrderItemProductFile::productFileId), - AllowNullable(FetchedOrder.OrderItemProductFile::remainingDownloads), - AllowNullable(FetchedOrder.OrderItemProductFile::size), - IgnoreNullable(FetchedOrder.OrderItemSelectedOption::files), - IgnoreNullable(FetchedOrder.OrderItemSelectedOption::name), - AllowNullable(FetchedOrder.OrderItemSelectedOption::nameTranslated), - IgnoreNullable(FetchedOrder.OrderItemSelectedOption::selections), - IgnoreNullable(FetchedOrder.OrderItemSelectedOption::type), - IgnoreNullable(FetchedOrder.OrderItemSelectedOption::value), - AllowNullable(FetchedOrder.OrderItemSelectedOption::valueTranslated), - IgnoreNullable(FetchedOrder.OrderItemSelectedOption::valuesArray), - AllowNullable(FetchedOrder.OrderItemSelectedOption::valuesArrayTranslated), - IgnoreNullable(FetchedOrder.OrderItemSelectionInfo::selectionModifier), - IgnoreNullable(FetchedOrder.OrderItemSelectionInfo::selectionModifierType), - IgnoreNullable(FetchedOrder.OrderItemSelectionInfo::selectionTitle), - IgnoreNullable(FetchedOrder.OrderItemTax::includeInPrice), - IgnoreNullable(FetchedOrder.OrderItemTax::name), - IgnoreNullable(FetchedOrder.OrderItemTax::taxOnDiscountedSubtotal), - IgnoreNullable(FetchedOrder.OrderItemTax::taxOnShipping), - IgnoreNullable(FetchedOrder.OrderItemTax::total), - IgnoreNullable(FetchedOrder.OrderItemTax::value), - IgnoreNullable(FetchedOrder.OrderItemTax::sourceTaxRateId), - IgnoreNullable(FetchedOrder.OrderItemTax::sourceTaxRateType), - AllowNullable(FetchedOrder.OrderItemTax::taxType), - AllowNullable(FetchedOrder.Parcel::dimensionUnit), - AllowNullable(FetchedOrder.Parcel::height), - AllowNullable(FetchedOrder.Parcel::length), - AllowNullable(FetchedOrder.Parcel::template), - AllowNullable(FetchedOrder.Parcel::weight), - AllowNullable(FetchedOrder.Parcel::weightUnit), - AllowNullable(FetchedOrder.Parcel::width), - IgnoreNullable(FetchedOrder.PersonInfo::city), - IgnoreNullable(FetchedOrder.PersonInfo::companyName), - IgnoreNullable(FetchedOrder.PersonInfo::countryCode), - IgnoreNullable(FetchedOrder.PersonInfo::countryName), - IgnoreNullable(FetchedOrder.PersonInfo::firstName), - IgnoreNullable(FetchedOrder.PersonInfo::lastName), - IgnoreNullable(FetchedOrder.PersonInfo::name), - IgnoreNullable(FetchedOrder.PersonInfo::phone), - IgnoreNullable(FetchedOrder.PersonInfo::postalCode), - IgnoreNullable(FetchedOrder.PersonInfo::stateOrProvinceCode), - IgnoreNullable(FetchedOrder.PersonInfo::stateOrProvinceName), - IgnoreNullable(FetchedOrder.PersonInfo::street), - IgnoreNullable(FetchedOrder.ProductDimensions::height), - IgnoreNullable(FetchedOrder.ProductDimensions::length), - IgnoreNullable(FetchedOrder.ProductDimensions::width), - IgnoreNullable(FetchedOrder.RefundInfo::amount), - IgnoreNullable(FetchedOrder.RefundInfo::date), - IgnoreNullable(FetchedOrder.RefundInfo::reason), - IgnoreNullable(FetchedOrder.RefundInfo::source), - AllowNullable(FetchedOrder.SelectedPrice::value), - AllowNullable(FetchedOrder.Shipment::created), - AllowNullable(FetchedOrder.Shipment::id), - AllowNullable(FetchedOrder.Shipment::label), - AllowNullable(FetchedOrder.Shipment::parcel), - AllowNullable(FetchedOrder.Shipment::shipFrom), - AllowNullable(FetchedOrder.Shipment::shipTo), - AllowNullable(FetchedOrder.Shipment::shippingService), - AllowNullable(FetchedOrder.Shipment::tracking), - AllowNullable(FetchedOrder.ShippingLabelInfo::billingTransactionId), - AllowNullable(FetchedOrder.ShippingLabelInfo::commercialInvoiceUrl), - AllowNullable(FetchedOrder.ShippingLabelInfo::labelFileType), - AllowNullable(FetchedOrder.ShippingLabelInfo::labelUrl), - AllowNullable(FetchedOrder.ShippingOption::shippingMethodId), - IgnoreNullable(FetchedOrder.ShippingOption::estimatedTransitTime), - IgnoreNullable(FetchedOrder.ShippingOption::fulfillmentType), - IgnoreNullable(FetchedOrder.ShippingOption::isPickup), - AllowNullable(FetchedOrder.ShippingOption::locationId), - IgnoreNullable(FetchedOrder.ShippingOption::pickupInstruction), - IgnoreNullable(FetchedOrder.ShippingOption::shippingCarrierName), - IgnoreNullable(FetchedOrder.ShippingOption::shippingMethodName), - IgnoreNullable(FetchedOrder.ShippingOption::shippingRate), - AllowNullable(FetchedOrder.ShippingOption::isShippingLimit), - AllowNullable(FetchedOrder.ShippingOption::localizedLabel), - AllowNullable(FetchedOrder.ShippingOption::scheduled), - AllowNullable(FetchedOrder.ShippingOption::scheduledTimePrecisionType), - AllowNullable(FetchedOrder.ShippingOption::timeSlotLengthInMinutes), - AllowNullable(FetchedOrder.ShippingOption::pickupPrecisionType), - AllowNullable(FetchedOrder.ShippingServiceInfo::carrier), - AllowNullable(FetchedOrder.ShippingServiceInfo::carrierName), - AllowNullable(FetchedOrder.ShippingServiceInfo::carrierServiceCode), - AllowNullable(FetchedOrder.ShippingServiceInfo::carrierServiceName), - AllowNullable(FetchedOrder.Surcharge::descriptionTranslated), - AllowNullable(FetchedOrder.TaxRule::tax), - AllowNullable(FetchedOrder.TaxRule::zoneId), - AllowNullable(FetchedOrder.Taxes::appliedByDefault), - AllowNullable(FetchedOrder.Taxes::defaultTax), - AllowNullable(FetchedOrder.Taxes::enabled), - AllowNullable(FetchedOrder.Taxes::id), - AllowNullable(FetchedOrder.Taxes::includeInPrice), - AllowNullable(FetchedOrder.Taxes::name), - AllowNullable(FetchedOrder.Taxes::rules), - AllowNullable(FetchedOrder.Taxes::taxShipping), - AllowNullable(FetchedOrder.Taxes::useShippingAddress), - AllowNullable(FetchedOrder.TrackingInfo::estimatedDays), - AllowNullable(FetchedOrder.TrackingInfo::trackingNumber), - AllowNullable(FetchedOrder.TrackingInfo::trackingUrl), - IgnoreNullable(FetchedOrder.UtmData::campaign), - IgnoreNullable(FetchedOrder.UtmData::mcCid), - IgnoreNullable(FetchedOrder.UtmData::mcEid), - IgnoreNullable(FetchedOrder.UtmData::medium), - IgnoreNullable(FetchedOrder.UtmData::source), - AllowNullable(FetchedOrder::acceptMarketing), - AllowNullable(FetchedOrder::additionalInfo), - AllowNullable(FetchedOrder::affiliateId), - AllowNullable(FetchedOrder::availableShippingOptions), - AllowNullable(FetchedOrder::availableTaxes), - AllowNullable(FetchedOrder::billingPerson), - AllowNullable(FetchedOrder::couponDiscount), - AllowNullable(FetchedOrder::createDate), - AllowNullable(FetchedOrder::createTimestamp), - AllowNullable(FetchedOrder::creditCardStatus), - AllowNullable(FetchedOrder::customDiscount), - AllowNullable(FetchedOrder::customerGroup), - AllowNullable(FetchedOrder::customerGroupId), - AllowNullable(FetchedOrder::customerId), - AllowNullable(FetchedOrder::customerTaxExempt), - AllowNullable(FetchedOrder::customerTaxId), - AllowNullable(FetchedOrder::customerTaxIdValid), - AllowNullable(FetchedOrder::disableAllCustomerNotifications), - AllowNullable(FetchedOrder::discount), - AllowNullable(FetchedOrder::discountCoupon), - AllowNullable(FetchedOrder::discountInfo), - AllowNullable(FetchedOrder::ticket), - AllowNullable(FetchedOrder::ebayId), - AllowNullable(FetchedOrder::email), - AllowNullable(FetchedOrder::externalFulfillment), - AllowNullable(FetchedOrder::externalOrderId), - AllowNullable(FetchedOrder::externalTransactionId), - AllowNullable(FetchedOrder::externalTransactionUrl), - AllowNullable(FetchedOrder::extraFields), - AllowNullable(FetchedOrder::fulfillmentStatus), - AllowNullable(FetchedOrder::giftCardCode), - AllowNullable(FetchedOrder::giftCardDoubleSpending), - AllowNullable(FetchedOrder::giftCardId), - AllowNullable(FetchedOrder::giftCardUuid), - AllowNullable(FetchedOrder::giftCardRedemption), - AllowNullable(FetchedOrder::globalReferer), - AllowNullable(FetchedOrder::handlingFee), - AllowNullable(FetchedOrder::hidden), - AllowNullable(FetchedOrder::id), - AllowNullable(FetchedOrder::internalId), - AllowNullable(FetchedOrder::ipAddress), - AllowNullable(FetchedOrder::items), - AllowNullable(FetchedOrder::latestDeliveryDate), - AllowNullable(FetchedOrder::membershipBasedDiscount), - AllowNullable(FetchedOrder::orderComments), - AllowNullable(FetchedOrder::orderExtraFields), - AllowNullable(FetchedOrder::paymentMessage), - AllowNullable(FetchedOrder::paymentMethod), - AllowNullable(FetchedOrder::paymentModule), - AllowNullable(FetchedOrder::paymentParams), - AllowNullable(FetchedOrder::paymentStatus), - AllowNullable(FetchedOrder::pickupTime), - AllowNullable(FetchedOrder::pricesIncludeTax), - AllowNullable(FetchedOrder::privateAdminNotes), - AllowNullable(FetchedOrder::referenceTransactionId), - AllowNullable(FetchedOrder::refererId), - AllowNullable(FetchedOrder::refererUrl), - AllowNullable(FetchedOrder::refundedAmount), - AllowNullable(FetchedOrder::refunds), - AllowNullable(FetchedOrder::reversedTaxApplied), - AllowNullable(FetchedOrder::shipments), - AllowNullable(FetchedOrder::shippingOption), - AllowNullable(FetchedOrder::shippingPerson), - AllowNullable(FetchedOrder::subtotal), - AllowNullable(FetchedOrder::subtotalWithoutTax), - AllowNullable(FetchedOrder::tax), - AllowNullable(FetchedOrder::total), - AllowNullable(FetchedOrder::totalAndMembershipBasedDiscount), - AllowNullable(FetchedOrder::totalBeforeGiftCardRedemption), - AllowNullable(FetchedOrder::totalWithoutTax), - AllowNullable(FetchedOrder::trackingNumber), - AllowNullable(FetchedOrder::trackingUrl), - AllowNullable(FetchedOrder::updateDate), - AllowNullable(FetchedOrder::updateTimestamp), - AllowNullable(FetchedOrder::usdTotal), - AllowNullable(FetchedOrder::utmData), - AllowNullable(FetchedOrder::vendorOrderNumber), - AllowNullable(FetchedOrder::volumeDiscount), - AllowNullable(FetchedOrder.PredictedPackage::declaredValue), - AllowNullable(FetchedOrder.PredictedPackage::height), - AllowNullable(FetchedOrder.PredictedPackage::length), - AllowNullable(FetchedOrder.PredictedPackage::weight), - AllowNullable(FetchedOrder.PredictedPackage::width), - AllowNullable(FetchedOrder.TaxInvoice::created), - AllowNullable(FetchedOrder.TaxInvoice::id), - AllowNullable(FetchedOrder.TaxInvoice::internalId), - AllowNullable(FetchedOrder.TaxInvoice::link), - AllowNullable(FetchedOrder.TaxInvoice::type), - AllowNullable(FetchedOrder::invoices), - AllowNullable(FetchedOrder::predictedPackage), - AllowNullable(FetchedOrder::externalOrderData), - AllowNullable(FetchedOrder.ExternalOrderData::externalOrderId), - AllowNullable(FetchedOrder.ExternalOrderData::externalFulfillment), - AllowNullable(FetchedOrder.ExternalOrderData::refererId), - AllowNullable(FetchedOrder.ExternalOrderData::platformSpecificFields), - AllowNullable(FetchedOrder.ExternalOrderData::refererChannel), - AllowNullable(FetchedOrder.OrderItemAttributeValue::id), - AllowNullable(FetchedOrder.OrderItemAttributeValue::name), - AllowNullable(FetchedOrder.OrderItemAttributeValue::nameTranslated), - AllowNullable(FetchedOrder.OrderItemAttributeValue::value), - AllowNullable(FetchedOrder.OrderItemAttributeValue::valueTranslated), - AllowNullable(FetchedOrder::paymentReference), - AllowNullable(FetchedOrder::loyalty), - AllowNullable(FetchedOrder.Loyalty::earned), - AllowNullable(FetchedOrder.Loyalty::balance), - AllowNullable(FetchedOrder.Loyalty::redemption), - AllowNullable(FetchedOrder.LoyaltyRedemption::id), - AllowNullable(FetchedOrder.LoyaltyRedemption::amount), - AllowNullable(FetchedOrder.LoyaltyRedemption::cancelled), - AllowNullable(FetchedOrder::customerFiscalCode), - AllowNullable(FetchedOrder::electronicInvoicePecEmail), - AllowNullable(FetchedOrder::electronicInvoiceSdiCode), - AllowNullable(FetchedOrder::commercialRelationshipScheme), - AllowNullable(FetchedOrder::lang), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderStatusSettingsRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderStatusSettingsRules.kt deleted file mode 100644 index 71af65afa..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedOrderStatusSettingsRules.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.profile.result.FetchedOrderStatusSettings -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val fetchedOrderStatusSettingsNullablePropertyRules: List> = listOf( - AllowNullable(FetchedOrderStatusSettings::defaultStatus), - AllowNullable(FetchedOrderStatusSettings::name), - AllowNullable(FetchedOrderStatusSettings::nameTranslations), - AllowNullable(FetchedOrderStatusSettings::lastNameChangeDate), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductReviewRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductReviewRules.kt deleted file mode 100644 index f49b48cdc..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductReviewRules.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.productreview.result.FetchedProductReview -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val fetchedProductReviewNullablePropertyRules: List> = listOf( - AllowNullable(FetchedProductReview::createDate), - AllowNullable(FetchedProductReview::createTimestamp), - AllowNullable(FetchedProductReview::customerId), - AllowNullable(FetchedProductReview::id), - AllowNullable(FetchedProductReview::orderId), - AllowNullable(FetchedProductReview::orderItemId), - AllowNullable(FetchedProductReview::orderNumber), - AllowNullable(FetchedProductReview::productId), - AllowNullable(FetchedProductReview::productName), - AllowNullable(FetchedProductReview::productOptions), - AllowNullable(FetchedProductReview::rating), - AllowNullable(FetchedProductReview::review), - AllowNullable(FetchedProductReview::reviewerInfo), - AllowNullable(FetchedProductReview::status), - AllowNullable(FetchedProductReview::updateDate), - AllowNullable(FetchedProductReview::updateTimestamp), - AllowNullable(FetchedProductReview.FetchedProductReviewerInfo::city), - AllowNullable(FetchedProductReview.FetchedProductReviewerInfo::country), - AllowNullable(FetchedProductReview.FetchedProductReviewerInfo::email), - AllowNullable(FetchedProductReview.FetchedProductReviewerInfo::name), - AllowNullable(FetchedProductReview.FetchedProductReviewerInfo::ordersCount), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt deleted file mode 100644 index 1113d8f84..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductRules.kt +++ /dev/null @@ -1,172 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.common.FetchedAlt -import com.ecwid.apiclient.v3.dto.product.result.FetchedProduct -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val fetchedProductNullablePropertyRules: List> = listOf( - IgnoreNullable(FetchedProduct::attributes), - AllowNullable(FetchedProduct::borderInfo), - IgnoreNullable(FetchedProduct::categories), - IgnoreNullable(FetchedProduct::categoryIds), - IgnoreNullable(FetchedProduct::combinations), - IgnoreNullable(FetchedProduct::compareToPrice), - IgnoreNullable(FetchedProduct::compareToPriceDiscount), - IgnoreNullable(FetchedProduct::compareToPriceDiscountFormatted), - IgnoreNullable(FetchedProduct::compareToPriceDiscountPercent), - IgnoreNullable(FetchedProduct::compareToPriceDiscountPercentFormatted), - IgnoreNullable(FetchedProduct::compareToPriceFormatted), - AllowNullable(FetchedProduct::defaultDisplayedCompareToPrice), - AllowNullable(FetchedProduct::defaultDisplayedCompareToPriceFormatted), - AllowNullable(FetchedProduct::defaultDisplayedCompareToPriceDiscount), - AllowNullable(FetchedProduct::defaultDisplayedCompareToPriceDiscountFormatted), - AllowNullable(FetchedProduct::defaultDisplayedCompareToPriceDiscountPercent), - AllowNullable(FetchedProduct::defaultDisplayedCompareToPriceDiscountPercentFormatted), - AllowNullable(FetchedProduct::lowestPrice), - AllowNullable(FetchedProduct::defaultDisplayedLowestPrice), - AllowNullable(FetchedProduct::defaultDisplayedLowestPriceFormatted), - AllowNullable(FetchedProduct.LowestPriceSettings::manualLowestPrice), - AllowNullable(FetchedProduct.LowestPriceSettings::defaultDisplayedLowestPrice), - AllowNullable(FetchedProduct.LowestPriceSettings::defaultDisplayedLowestPriceFormatted), - AllowNullable(FetchedProduct.LowestPriceSettings::automaticLowestPrice), - AllowNullable(FetchedProduct.LowestPriceSettings::defaultDisplayedAutomaticLowestPrice), - AllowNullable(FetchedProduct.LowestPriceSettings::defaultDisplayedAutomaticLowestPriceFormatted), - - AllowNullable(FetchedProduct::customsHsTariffCode), - IgnoreNullable(FetchedProduct::defaultCategoryId), - IgnoreNullable(FetchedProduct::defaultCombinationId), - IgnoreNullable(FetchedProduct::defaultDisplayedPrice), - IgnoreNullable(FetchedProduct::defaultDisplayedPriceFormatted), - IgnoreNullable(FetchedProduct::description), - IgnoreNullable(FetchedProduct::descriptionTranslated), - IgnoreNullable(FetchedProduct::dimensions), - AllowNullable(FetchedProduct::discountsAllowed), - IgnoreNullable(FetchedProduct::enabled), - IgnoreNullable(FetchedProduct::favorites), - IgnoreNullable(FetchedProduct::files), - IgnoreNullable(FetchedProduct::galleryImages), - IgnoreNullable(FetchedProduct::inStock), - IgnoreNullable(FetchedProduct::isGiftCard), - IgnoreNullable(FetchedProduct::isSampleProduct), - IgnoreNullable(FetchedProduct::isShippingRequired), - AllowNullable(FetchedProduct::hasFreeShipping), - IgnoreNullable(FetchedProduct::media), - IgnoreNullable(FetchedProduct::nameTranslated), - IgnoreNullable(FetchedProduct::nameYourPriceEnabled), - IgnoreNullable(FetchedProduct::customPriceTiers), - IgnoreNullable(FetchedProduct::priceDefaultTier), - IgnoreNullable(FetchedProduct::shippingPreparationTime), - AllowNullable(FetchedProduct.ShippingPreparationTime::pickupPreparationTimeForInStockItemInMinutes), - AllowNullable(FetchedProduct.ShippingPreparationTime::shippingPreparationTimeForInStockItemDays), - AllowNullable(FetchedProduct.ShippingPreparationTime::shippingPreparationTimeForOutOfStockItemDays), - AllowNullable(FetchedProduct.ShippingPreparationTime::localDeliveryPreparationTimeForInStockItemInMinutes), - IgnoreNullable(FetchedProduct::showDeliveryTimeInStorefront), - IgnoreNullable(FetchedProduct::options), - IgnoreNullable(FetchedProduct::originalImage), - IgnoreNullable(FetchedProduct::price), - IgnoreNullable(FetchedProduct::priceInProductList), - IgnoreNullable(FetchedProduct::productClassId), - IgnoreNullable(FetchedProduct::quantity), - IgnoreNullable(FetchedProduct::outOfStockVisibilityBehaviour), - AllowNullable(FetchedProduct::rating), - IgnoreNullable(FetchedProduct::relatedProducts), - AllowNullable(FetchedProduct::reviewsCollectingAllowed), - AllowNullable(FetchedProduct::reviewsModerated), - AllowNullable(FetchedProduct::reviewsPublished), - IgnoreNullable(FetchedProduct::ribbon), - IgnoreNullable(FetchedProduct::ribbonTranslated), - IgnoreNullable(FetchedProduct::seoDescription), - AllowNullable(FetchedProduct::seoDescriptionTranslated), - IgnoreNullable(FetchedProduct::seoTitle), - AllowNullable(FetchedProduct::seoTitleTranslated), - IgnoreNullable(FetchedProduct::shipping), - IgnoreNullable(FetchedProduct::showOnFrontpage), - IgnoreNullable(FetchedProduct::subscriptionSettings), - IgnoreNullable(FetchedProduct::subtitle), - IgnoreNullable(FetchedProduct::subtitleTranslated), - IgnoreNullable(FetchedProduct::tax), - IgnoreNullable(FetchedProduct::unlimited), - IgnoreNullable(FetchedProduct::url), - AllowNullable(FetchedProduct::customSlug), - IgnoreNullable(FetchedProduct::warningLimit), - IgnoreNullable(FetchedProduct::weight), - IgnoreNullable(FetchedProduct::wholesalePrices), - IgnoreNullable(FetchedProduct.AttributeValue::id), - IgnoreNullable(FetchedProduct.AttributeValue::name), - IgnoreNullable(FetchedProduct.AttributeValue::show), - IgnoreNullable(FetchedProduct.AttributeValue::type), - IgnoreNullable(FetchedProduct.AttributeValue::value), - IgnoreNullable(FetchedProduct.AttributeValue::valueTranslated), - IgnoreNullable(FetchedProduct.FavoritesStats::count), - IgnoreNullable(FetchedProduct.FavoritesStats::displayedCount), - IgnoreNullable(FetchedProduct.GalleryImage::alt), - IgnoreNullable(FetchedProduct.GalleryImage::thumbnail), - AllowNullable(FetchedProduct.GalleryImage::borderInfo), - IgnoreNullable(FetchedProduct.ProductDimensions::height), - IgnoreNullable(FetchedProduct.ProductDimensions::length), - IgnoreNullable(FetchedProduct.ProductDimensions::width), - IgnoreNullable(FetchedProduct.ProductImage::image1500pxUrl), - IgnoreNullable(FetchedProduct.ProductImage::image160pxUrl), - IgnoreNullable(FetchedProduct.ProductImage::image400pxUrl), - IgnoreNullable(FetchedProduct.ProductImage::image800pxUrl), - IgnoreNullable(FetchedProduct.ProductImage::imageOriginalUrl), - AllowNullable(FetchedProduct.ProductImage::alt), - AllowNullable(FetchedAlt::main), - AllowNullable(FetchedAlt::translated), - AllowNullable(FetchedProduct.ProductVideo::videoCoverId), - AllowNullable(FetchedProduct.ProductVideo::image160pxUrl), - AllowNullable(FetchedProduct.ProductVideo::image400pxUrl), - AllowNullable(FetchedProduct.ProductVideo::image800pxUrl), - AllowNullable(FetchedProduct.ProductVideo::image1500pxUrl), - AllowNullable(FetchedProduct.ProductVideo::imageOriginalUrl), - AllowNullable(FetchedProduct.ProductVideo::providerName), - AllowNullable(FetchedProduct.ProductVideo::title), - IgnoreNullable(FetchedProduct.ProductOption::type), - IgnoreNullable(FetchedProduct.ProductOption.CheckboxOption::nameTranslated), - IgnoreNullable(FetchedProduct.ProductOption.DateOption::nameTranslated), - IgnoreNullable(FetchedProduct.ProductOption.FilesOption::nameTranslated), - IgnoreNullable(FetchedProduct.ProductOption.RadioOption::nameTranslated), - IgnoreNullable(FetchedProduct.ProductOption.SelectOption::nameTranslated), - IgnoreNullable(FetchedProduct.ProductOption.SizeOption::nameTranslated), - IgnoreNullable(FetchedProduct.ProductOption.TextAreaOption::nameTranslated), - IgnoreNullable(FetchedProduct.ProductOption.TextFieldOption::nameTranslated), - IgnoreNullable(FetchedProduct.ProductOptionChoice::textTranslated), - IgnoreNullable(FetchedProduct.RelatedCategory::categoryId), - IgnoreNullable(FetchedProduct.RelatedCategory::enabled), - IgnoreNullable(FetchedProduct.RelatedCategory::productCount), - IgnoreNullable(FetchedProduct.RelatedProducts::productIds), - IgnoreNullable(FetchedProduct.RelatedProducts::relatedCategory), - IgnoreNullable(FetchedProduct.Ribbon::color), - IgnoreNullable(FetchedProduct.Ribbon::text), - IgnoreNullable(FetchedProduct.ShippingSettings::disabledMethods), - IgnoreNullable(FetchedProduct.ShippingSettings::enabledMethods), - IgnoreNullable(FetchedProduct.ShippingSettings::flatRate), - IgnoreNullable(FetchedProduct.ShippingSettings::methodMarkup), - IgnoreNullable(FetchedProduct.ShippingSettings::type), - AllowNullable(FetchedProduct::googleProductCategory), - AllowNullable(FetchedProduct::googleProductCategoryName), - AllowNullable(FetchedProduct::externalReferenceId), - IgnoreNullable(FetchedProduct.RecurringChargeSettings::signUpFee), - IgnoreNullable(FetchedProduct.RecurringChargeSettings::signUpFeeFormatted), - AllowNullable(FetchedProduct.RecurringChargeSettings::subscriptionPriceWithSignUpFee), - IgnoreNullable(FetchedProduct.RecurringChargeSettings::subscriptionPriceWithSignUpFeeFormatted), - IgnoreNullable(FetchedProduct.SubscriptionSettings::oneTimePurchaseMarkup), - IgnoreNullable(FetchedProduct.SubscriptionSettings::oneTimePurchaseMarkupFormatted), - IgnoreNullable(FetchedProduct.SubscriptionSettings::oneTimePurchaseMarkupPercent), - IgnoreNullable(FetchedProduct.SubscriptionSettings::oneTimePurchaseMarkupPercentFormatted), - IgnoreNullable(FetchedProduct.SubscriptionSettings::displayedOneTimePurchaseMarkupPercent), - IgnoreNullable(FetchedProduct.SubscriptionSettings::displayedOneTimePurchaseMarkupPercentFormatted), - AllowNullable(FetchedProduct.SubscriptionSettings::oneTimePurchasePrice), - IgnoreNullable(FetchedProduct.SubscriptionSettings::oneTimePurchasePriceFormatted), - AllowNullable(FetchedProduct.ShippingPreparationTime::pickupPreparationTimeForInStockItemInMinutes), - AllowNullable(FetchedProduct.ShippingPreparationTime::shippingPreparationTimeForInStockItemDays), - AllowNullable(FetchedProduct.ShippingPreparationTime::shippingPreparationTimeForOutOfStockItemDays), - AllowNullable(FetchedProduct.ShippingPreparationTime::localDeliveryPreparationTimeForInStockItemInMinutes), - AllowNullable(FetchedProduct.ProductOption.ChoiceBased::defaultChoice), - AllowNullable(FetchedProduct.ProductOption.CheckboxOption::defaultChoice), - AllowNullable(FetchedProduct::minPurchaseQuantity), - AllowNullable(FetchedProduct::maxPurchaseQuantity), - AllowNullable(FetchedProduct::locationInventory), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductTypeRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductTypeRules.kt deleted file mode 100644 index 772a96105..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedProductTypeRules.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.producttype.result.FetchedProductType -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val fetchedProductTypeNullablePropertyRules: List> = listOf( - IgnoreNullable(FetchedProductType::attributes), - IgnoreNullable(FetchedProductType::googleTaxonomy), - IgnoreNullable(FetchedProductType::name), - IgnoreNullable(FetchedProductType.Attribute::name), - IgnoreNullable(FetchedProductType.Attribute::show), - IgnoreNullable(FetchedProductType.Attribute::type) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedShippingoptionNullablePropertyRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedShippingoptionNullablePropertyRules.kt deleted file mode 100644 index 131eb2e91..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedShippingoptionNullablePropertyRules.kt +++ /dev/null @@ -1,86 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.profile.result.FetchedShippingOption -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val fetchedShippingOptionNullablePropertyRules: List> = listOf( - AllowNullable(FetchedShippingOption::id), - AllowNullable(FetchedShippingOption::appClientId), - AllowNullable(FetchedShippingOption::title), - AllowNullable(FetchedShippingOption::titleTranslated), - AllowNullable(FetchedShippingOption::description), - AllowNullable(FetchedShippingOption::descriptionTranslated), - AllowNullable(FetchedShippingOption::enabled), - AllowNullable(FetchedShippingOption::orderBy), - AllowNullable(FetchedShippingOption::fulfilmentType), - AllowNullable(FetchedShippingOption::minimumOrderSubtotal), - AllowNullable(FetchedShippingOption::deliveryTimeDays), - AllowNullable(FetchedShippingOption::destinationZone), - AllowNullable(FetchedShippingOption::ratesCalculationType), - AllowNullable(FetchedShippingOption::locationId), - AllowNullable(FetchedShippingOption::flatRate), - AllowNullable(FetchedShippingOption::ratesTable), - AllowNullable(FetchedShippingOption::pickupInstruction), - AllowNullable(FetchedShippingOption::pickupInstructionTranslated), - AllowNullable(FetchedShippingOption::pickupBusinessHours), - AllowNullable(FetchedShippingOption::pickupPreparationTimeHours), - AllowNullable(FetchedShippingOption::pickupPrecisionType), - AllowNullable(FetchedShippingOption::type), - AllowNullable(FetchedShippingOption::carrier), - AllowNullable(FetchedShippingOption::carrierSettings), - AllowNullable(FetchedShippingOption::carrierMethods), - AllowNullable(FetchedShippingOption::businessHours), - AllowNullable(FetchedShippingOption::businessHoursLimitationType), - AllowNullable(FetchedShippingOption::allowSameDayDelivery), - AllowNullable(FetchedShippingOption::availabilityPeriod), - AllowNullable(FetchedShippingOption::customAvailabilityPeriodInDays), - AllowNullable(FetchedShippingOption::scheduled), - AllowNullable(FetchedShippingOption::scheduledTimePrecisionType), - AllowNullable(FetchedShippingOption::scheduledPickup), - AllowNullable(FetchedShippingOption::shippingCostMarkup), - AllowNullable(FetchedShippingOption::timeSlotLengthInMinutes), - AllowNullable(FetchedShippingOption::cutoffTimeForSameDayDelivery), - AllowNullable(FetchedShippingOption::fulfillmentTimeInMinutes), - AllowNullable(FetchedShippingOption::blackoutDates), - AllowNullable(FetchedShippingOption::estimatedShippingTimeAtCheckoutSettings), - AllowNullable(FetchedShippingOption.Zone::id), - AllowNullable(FetchedShippingOption.Zone::name), - AllowNullable(FetchedShippingOption.Zone::countryCodes), - AllowNullable(FetchedShippingOption.Zone::stateOrProvinceCodes), - AllowNullable(FetchedShippingOption.Zone::postCodes), - AllowNullable(FetchedShippingOption.FlatRate::rate), - AllowNullable(FetchedShippingOption.FlatRate::rateType), - AllowNullable(FetchedShippingOption.TableRates::rates), - AllowNullable(FetchedShippingOption.TableRates::tableBasedOn), - AllowNullable(FetchedShippingOption.Rates::rate), - AllowNullable(FetchedShippingOption.Rates::conditions), - AllowNullable(FetchedShippingOption.Rate::perItem), - AllowNullable(FetchedShippingOption.Rate::perOrder), - AllowNullable(FetchedShippingOption.Rate::perWeight), - AllowNullable(FetchedShippingOption.Rate::percent), - AllowNullable(FetchedShippingOption.BlackoutPeriodItem::fromDate), - AllowNullable(FetchedShippingOption.BlackoutPeriodItem::toDate), - AllowNullable(FetchedShippingOption.BlackoutPeriodItem::repeatedAnnually), - AllowNullable(FetchedShippingOption.Conditions::discountedSubtotalFrom), - AllowNullable(FetchedShippingOption.Conditions::discountedSubtotalTo), - AllowNullable(FetchedShippingOption.Conditions::subtotalFrom), - AllowNullable(FetchedShippingOption.Conditions::subtotalTo), - AllowNullable(FetchedShippingOption.Conditions::weightFrom), - AllowNullable(FetchedShippingOption.Conditions::weightTo), - AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::estimatedDeliveryDateAtCheckoutEnabled), - AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::estimatedTransitTimeInDays), - AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::fulfillmentTimeInDays), - AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::shippingBusinessDays), - AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::deliveryDays), - AllowNullable(FetchedShippingOption.EstimatedShippingTimeAtCheckoutSettings::cutoffTimeForSameDayPacking), - AllowNullable(FetchedShippingOption.CarrierMethod::id), - AllowNullable(FetchedShippingOption.CarrierMethod::enabled), - AllowNullable(FetchedShippingOption.CarrierMethod::name), - AllowNullable(FetchedShippingOption.CarrierMethod::orderBy), - AllowNullable(FetchedShippingOption.CarrierSettings::defaultCarrierAccountEnabled), - AllowNullable(FetchedShippingOption.CarrierSettings::defaultPostageDimensions), - AllowNullable(FetchedShippingOption.DefaultPostageDimensions::height), - AllowNullable(FetchedShippingOption.DefaultPostageDimensions::length), - AllowNullable(FetchedShippingOption.DefaultPostageDimensions::width), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedSlugInfoRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedSlugInfoRules.kt deleted file mode 100644 index fc730a2ec..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedSlugInfoRules.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.sluginfo.FetchedSlugInfo -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val fetchedSlugInfoNullablePropertyRules: List> = listOf( - AllowNullable(FetchedSlugInfo::canonicalSlug), - AllowNullable(FetchedSlugInfo::type), - AllowNullable(FetchedSlugInfo::staticContent), - AllowNullable(FetchedSlugInfo::storeEntityData), -) - -val fetchedSlugInfoClassesNullablePropertyRules: List> = listOf( - AllowNullable(FetchedSlugInfo.EntityData::id), - AllowNullable(FetchedSlugInfo.StaticContent::canonicalUrl), - AllowNullable(FetchedSlugInfo.StaticContent::cssFiles), - AllowNullable(FetchedSlugInfo.StaticContent::jsCode), - AllowNullable(FetchedSlugInfo.StaticContent::hrefLangHtml), - AllowNullable(FetchedSlugInfo.StaticContent::htmlCode), - AllowNullable(FetchedSlugInfo.StaticContent::jsonLDHtml), - AllowNullable(FetchedSlugInfo.StaticContent::lastUpdated), - AllowNullable(FetchedSlugInfo.StaticContent::metaDescriptionHtml), - AllowNullable(FetchedSlugInfo.StaticContent::ogTagsHtml), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedStoreProfileRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedStoreProfileRules.kt deleted file mode 100644 index b7b5987e5..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedStoreProfileRules.kt +++ /dev/null @@ -1,335 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.profile.result.FetchedStoreProfile -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val fetchedStoreProfileNullablePropertyRules: List> = listOf( - IgnoreNullable(FetchedStoreProfile::account), - IgnoreNullable(FetchedStoreProfile::businessRegistrationID), - IgnoreNullable(FetchedStoreProfile::company), - IgnoreNullable(FetchedStoreProfile::designSettings), - IgnoreNullable(FetchedStoreProfile::fbMessengerSettings), - IgnoreNullable(FetchedStoreProfile::featureToggles), - IgnoreNullable(FetchedStoreProfile::formatsAndUnits), - IgnoreNullable(FetchedStoreProfile::generalInfo), - IgnoreNullable(FetchedStoreProfile::giftCardSettings), - IgnoreNullable(FetchedStoreProfile::languages), - IgnoreNullable(FetchedStoreProfile::legalPagesSettings), - IgnoreNullable(FetchedStoreProfile::mailNotifications), - IgnoreNullable(FetchedStoreProfile::orderInvoiceSettings), - IgnoreNullable(FetchedStoreProfile::payment), - IgnoreNullable(FetchedStoreProfile::productFiltersSettings), - IgnoreNullable(FetchedStoreProfile::settings), - IgnoreNullable(FetchedStoreProfile::shipping), - IgnoreNullable(FetchedStoreProfile::taxSettings), - IgnoreNullable(FetchedStoreProfile::zones), - IgnoreNullable(FetchedStoreProfile.AbandonedSalesSettings::autoAbandonedSalesRecovery), - IgnoreNullable(FetchedStoreProfile.Account::accountEmail), - IgnoreNullable(FetchedStoreProfile.Account::accountName), - IgnoreNullable(FetchedStoreProfile.Account::accountNickName), - IgnoreNullable(FetchedStoreProfile.Account::availableFeatures), - IgnoreNullable(FetchedStoreProfile.Account::whiteLabel), - AllowNullable(FetchedStoreProfile.Account::brandName), - AllowNullable(FetchedStoreProfile.Account::supportEmail), - IgnoreNullable(FetchedStoreProfile.ApplePay::gateway), - IgnoreNullable(FetchedStoreProfile.ApplePay::verificationFileUrl), - IgnoreNullable(FetchedStoreProfile.BusinessRegistrationID::name), - IgnoreNullable(FetchedStoreProfile.BusinessRegistrationID::value), - IgnoreNullable(FetchedStoreProfile.Company::city), - IgnoreNullable(FetchedStoreProfile.Company::companyName), - IgnoreNullable(FetchedStoreProfile.Company::countryCode), - IgnoreNullable(FetchedStoreProfile.Company::email), - IgnoreNullable(FetchedStoreProfile.Company::phone), - IgnoreNullable(FetchedStoreProfile.Company::postalCode), - IgnoreNullable(FetchedStoreProfile.Company::stateOrProvinceCode), - IgnoreNullable(FetchedStoreProfile.Company::street), - AllowNullable(FetchedStoreProfile.DesignSettings::breadcrumbsHaveHomeItem), - AllowNullable(FetchedStoreProfile.DesignSettings::breadcrumbsHomeUrl), - AllowNullable(FetchedStoreProfile.DesignSettings::breadcrumbsSeparator), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetFixed), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetFixedPosition), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetFixedShape), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetHorizontalIndent), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetIcon), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetIsResponsive), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetLayout), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetShowBuyAnimation), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetShowEmptyCart), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetStoreCustomIconUrl), - AllowNullable(FetchedStoreProfile.DesignSettings::cartWidgetVerticalIndent), - AllowNullable(FetchedStoreProfile.DesignSettings::checkoutProductsCollapsedOnDesktop), - AllowNullable(FetchedStoreProfile.DesignSettings::checkoutProductsCollapsedOnMobile), - AllowNullable(FetchedStoreProfile.DesignSettings::checkoutShowAddressLine2), - AllowNullable(FetchedStoreProfile.DesignSettings::checkoutShowStateInput), - AllowNullable(FetchedStoreProfile.DesignSettings::enableCatalogOnOnePage), - AllowNullable(FetchedStoreProfile.DesignSettings::enableCatalogSeamlessProductListView), - AllowNullable(FetchedStoreProfile.DesignSettings::enablePageTransitions), - AllowNullable(FetchedStoreProfile.DesignSettings::enableSimpleCategoryList), - AllowNullable(FetchedStoreProfile.DesignSettings::feedbackMessagePosition), - AllowNullable(FetchedStoreProfile.DesignSettings::legalPagesShowPageLinks), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsAdditionalImagesHasShadow), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsAdditionalImagesPreviewOnClick), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsCutProductDescriptionInSidebar), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsGalleryLayout), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsHidePriceModifiers), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsImageCarousel), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsLayout), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionBreadcrumbs), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionBuyButton), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionDeliveryTime), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionProductDescription), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionProductName), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionProductOptions), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionProductPrice), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionProductLoyalty), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionProductSku), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionReviewSection), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionSaveForLater), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionShareButtons), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionSubtitle), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsPositionWholesalePrices), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowAttributes), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowBreadcrumbs), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowBreadcrumbsPosition), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowBuyButton), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowDeliveryTime), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowFacebookShareButton), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowInStockLabel), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowNavigationArrows), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowNumberOfItemsInStock), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowPinterestShareButton), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowPricePerUnit), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowProductDescription), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowProductName), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowProductNameAlwaysFirstOnMobile), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowProductOptions), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowProductPhotoZoom), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowProductPrice), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowProductLoyalty), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowProductSku), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowQty), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowRatingSection), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowReviewsSection), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowReviewsSectionInOneCardView), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowSalePrice), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowSaveForLater), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowShareButtons), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowSubtitle), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowTax), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowTwitterShareButton), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowVkShareButton), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowWeight), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowWholesalePrices), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsShowZoomedImageInGallery), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsThumbnailsAspectRatio), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsTwoColumnsWithLeftSidebarShowProductDescriptionOnSidebar), - AllowNullable(FetchedStoreProfile.DesignSettings::productDetailsTwoColumnsWithRightSidebarShowProductDescriptionOnSidebar), - AllowNullable(FetchedStoreProfile.DesignSettings::productFiltersOpenedByDefaultOnCatalogPages), - AllowNullable(FetchedStoreProfile.DesignSettings::productFiltersOpenedByDefaultOnCategoryPage), - AllowNullable(FetchedStoreProfile.DesignSettings::productFiltersPositionCategoryPage), - AllowNullable(FetchedStoreProfile.DesignSettings::productFiltersPositionOnCatalogPages), - AllowNullable(FetchedStoreProfile.DesignSettings::productFiltersPositionSearchPage), - AllowNullable(FetchedStoreProfile.DesignSettings::productFiltersVisibleOnCatalogPages), - AllowNullable(FetchedStoreProfile.DesignSettings::productListBuyNowBehaviour), - AllowNullable(FetchedStoreProfile.DesignSettings::productListCardLayout), - AllowNullable(FetchedStoreProfile.DesignSettings::productListCategoryCellSpacing), - AllowNullable(FetchedStoreProfile.DesignSettings::productListCategoryImageLayout), - AllowNullable(FetchedStoreProfile.DesignSettings::productListCategoryImagePosition), - AllowNullable(FetchedStoreProfile.DesignSettings::productListCategoryImageSize), - AllowNullable(FetchedStoreProfile.DesignSettings::productListCategoryNameBehaviour), - AllowNullable(FetchedStoreProfile.DesignSettings::productListCellSpacing), - AllowNullable(FetchedStoreProfile.DesignSettings::productListImageHasShadow), - AllowNullable(FetchedStoreProfile.DesignSettings::productListImageLayout), - AllowNullable(FetchedStoreProfile.DesignSettings::productListImagePosition), - AllowNullable(FetchedStoreProfile.DesignSettings::productListImageSize), - AllowNullable(FetchedStoreProfile.DesignSettings::productListNameBehaviour), - AllowNullable(FetchedStoreProfile.DesignSettings::productListPriceBehaviour), - AllowNullable(FetchedStoreProfile.DesignSettings::productListRatingSectionBehavior), - AllowNullable(FetchedStoreProfile.DesignSettings::productListSKUBehaviour), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowAdditionalImage), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowBreadcrumbs), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowCardFrame), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowFooterMenu), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowOnSaleLabel), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowPayWhatYouWantLabel), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowProductImages), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowRatingInOneStar), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowRatingNumberInFiveStarsView), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowReviewsCountInFiveStarsView), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowSignInLink), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowSoldOutLabel), - AllowNullable(FetchedStoreProfile.DesignSettings::productListShowSortViewAsOptions), - AllowNullable(FetchedStoreProfile.DesignSettings::productListSubtitlesBehavior), - AllowNullable(FetchedStoreProfile.DesignSettings::shoppingCartProductsCollapsedOnDesktop), - AllowNullable(FetchedStoreProfile.DesignSettings::shoppingCartProductsCollapsedOnMobile), - AllowNullable(FetchedStoreProfile.DesignSettings::shoppingCartShowQtyInputs), - AllowNullable(FetchedStoreProfile.DesignSettings::shoppingCartShowSku), - AllowNullable(FetchedStoreProfile.DesignSettings::shoppingCartShowWeight), - AllowNullable(FetchedStoreProfile.DesignSettings::showCartWidget), - AllowNullable(FetchedStoreProfile.DesignSettings::showRootCategories), - AllowNullable(FetchedStoreProfile.DesignSettings::showSigninLinkWithUnifiedAccountPage), - IgnoreNullable(FetchedStoreProfile.FBMessengerSettings::enabled), - IgnoreNullable(FetchedStoreProfile.FBMessengerSettings::fbMessengerMessageUsButtonColor), - IgnoreNullable(FetchedStoreProfile.FBMessengerSettings::fbMessengerPageId), - IgnoreNullable(FetchedStoreProfile.FBMessengerSettings::fbMessengerThemeColor), - IgnoreNullable(FetchedStoreProfile.FeatureTogglesInfo::enabled), - IgnoreNullable(FetchedStoreProfile.FeatureTogglesInfo::name), - IgnoreNullable(FetchedStoreProfile.FeatureTogglesInfo::visible), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currency), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currencyDecimalSeparator), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currencyGroupSeparator), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currencyPrecision), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currencyPrefix), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currencyRate), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currencySuffix), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::currencyTruncateZeroFractional), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::dateFormat), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::dimensionsUnit), - AllowNullable(FetchedStoreProfile.FormatsAndUnits::orderNumberMinDigitsAmount), - AllowNullable(FetchedStoreProfile.FormatsAndUnits::orderNumberNextNumber), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::orderNumberPrefix), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::orderNumberSuffix), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::timeFormat), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::timezone), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::weightDecimalSeparator), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::weightGroupSeparator), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::weightPrecision), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::weightTruncateZeroFractional), - IgnoreNullable(FetchedStoreProfile.FormatsAndUnits::weightUnit), - IgnoreNullable(FetchedStoreProfile.GeneralInfo::starterSite), - IgnoreNullable(FetchedStoreProfile.GeneralInfo::storeUrl), - IgnoreNullable(FetchedStoreProfile.GeneralInfo::websitePlatform), - IgnoreNullable(FetchedStoreProfile.GiftCardProducts::id), - IgnoreNullable(FetchedStoreProfile.GiftCardProducts::name), - IgnoreNullable(FetchedStoreProfile.GiftCardProducts::url), - IgnoreNullable(FetchedStoreProfile.GiftCardSettings::displayLocation), - IgnoreNullable(FetchedStoreProfile.GiftCardSettings::products), - IgnoreNullable(FetchedStoreProfile.HandlingFee::description), - IgnoreNullable(FetchedStoreProfile.HandlingFee::name), - IgnoreNullable(FetchedStoreProfile.HandlingFee::value), - IgnoreNullable(FetchedStoreProfile.InstantSiteInfo::customDomain), - IgnoreNullable(FetchedStoreProfile.InstantSiteInfo::ecwidSubdomain), - IgnoreNullable(FetchedStoreProfile.InstantSiteInfo::generatedUrl), - IgnoreNullable(FetchedStoreProfile.InstantSiteInfo::storeLogoUrl), - IgnoreNullable(FetchedStoreProfile.InstructionsForCustomerInfo::instructions), - IgnoreNullable(FetchedStoreProfile.InstructionsForCustomerInfo::instructionsTitle), - IgnoreNullable(FetchedStoreProfile.Languages::defaultLanguage), - IgnoreNullable(FetchedStoreProfile.Languages::enabledLanguages), - IgnoreNullable(FetchedStoreProfile.Languages::facebookPreferredLocale), - IgnoreNullable(FetchedStoreProfile.LegalPagesInfo::display), - IgnoreNullable(FetchedStoreProfile.LegalPagesInfo::enabled), - IgnoreNullable(FetchedStoreProfile.LegalPagesInfo::externalUrl), - IgnoreNullable(FetchedStoreProfile.LegalPagesInfo::text), - IgnoreNullable(FetchedStoreProfile.LegalPagesInfo::title), - IgnoreNullable(FetchedStoreProfile.LegalPagesInfo::type), - IgnoreNullable(FetchedStoreProfile.LegalPagesSettingsDetails::legalPages), - IgnoreNullable(FetchedStoreProfile.LegalPagesSettingsDetails::requireTermsAgreementAtCheckout), - IgnoreNullable(FetchedStoreProfile.MailNotifications::adminNotificationEmails), - IgnoreNullable(FetchedStoreProfile.MailNotifications::customerNotificationFromEmail), - IgnoreNullable(FetchedStoreProfile.OrderInvoiceSettings::attachInvoiceToOrderEmailNotifications), - IgnoreNullable(FetchedStoreProfile.OrderInvoiceSettings::displayOrderInvoices), - IgnoreNullable(FetchedStoreProfile.OrderInvoiceSettings::invoiceLogoUrl), - IgnoreNullable(FetchedStoreProfile.PaymentInfo::applePay), - IgnoreNullable(FetchedStoreProfile.PaymentInfo::paymentOptions), - AllowNullable(FetchedStoreProfile.PaymentInfo::countryCode), - AllowNullable(FetchedStoreProfile.PaymentOptionInfo::appClientId), - AllowNullable(FetchedStoreProfile.PaymentOptionInfo::appNamespace), - IgnoreNullable(FetchedStoreProfile.PaymentOptionInfo::checkoutDescription), - IgnoreNullable(FetchedStoreProfile.PaymentOptionInfo::checkoutTitle), - IgnoreNullable(FetchedStoreProfile.PaymentOptionInfo::enabled), - IgnoreNullable(FetchedStoreProfile.PaymentOptionInfo::configured), - IgnoreNullable(FetchedStoreProfile.PaymentOptionInfo::id), - IgnoreNullable(FetchedStoreProfile.PaymentOptionInfo::instructionsForCustomer), - IgnoreNullable(FetchedStoreProfile.PaymentOptionInfo::orderBy), - IgnoreNullable(FetchedStoreProfile.PaymentOptionInfo::paymentProcessorId), - IgnoreNullable(FetchedStoreProfile.PaymentOptionInfo::paymentProcessorTitle), - AllowNullable(FetchedStoreProfile.PaymentOptionInfo::shippingSettings), - AllowNullable(FetchedStoreProfile.PaymentOptionInfo::methods), - AllowNullable(FetchedStoreProfile.PaymentOptionInfo::supportsSubtypes), - AllowNullable(FetchedStoreProfile.PaymentMethod::cards), - AllowNullable(FetchedStoreProfile.PaymentMethod::subtype), - AllowNullable(FetchedStoreProfile.PaymentMethod::subtypeMethodName), - AllowNullable(FetchedStoreProfile.ProductFilterItem::name), - IgnoreNullable(FetchedStoreProfile::registrationAnswers), - IgnoreNullable(FetchedStoreProfile.RegistrationAnswers::alreadySelling), - IgnoreNullable(FetchedStoreProfile.RegistrationAnswers::facebook), - IgnoreNullable(FetchedStoreProfile.RegistrationAnswers::forSomeone), - IgnoreNullable(FetchedStoreProfile.RegistrationAnswers::goods), - IgnoreNullable(FetchedStoreProfile.RegistrationAnswers::otherGoods), - IgnoreNullable(FetchedStoreProfile.RegistrationAnswers::platform), - IgnoreNullable(FetchedStoreProfile.RegistrationAnswers::website), - IgnoreNullable(FetchedStoreProfile.SalePriceSettings::displayDiscount), - IgnoreNullable(FetchedStoreProfile.SalePriceSettings::displayOnProductList), - IgnoreNullable(FetchedStoreProfile.SalePriceSettings::oldPriceLabel), - IgnoreNullable(FetchedStoreProfile.SalePriceSettings::displayLowestPrice), - IgnoreNullable(FetchedStoreProfile.Settings::abandonedSales), - IgnoreNullable(FetchedStoreProfile.Settings::acceptMarketingCheckboxCustomText), - IgnoreNullable(FetchedStoreProfile.Settings::acceptMarketingCheckboxDefaultValue), - IgnoreNullable(FetchedStoreProfile.Settings::askCompanyName), - IgnoreNullable(FetchedStoreProfile.Settings::askConsentToTrackInStorefront), - IgnoreNullable(FetchedStoreProfile.Settings::closed), - IgnoreNullable(FetchedStoreProfile.Settings::defaultProductSortOrder), - IgnoreNullable(FetchedStoreProfile.Settings::emailLogoUrl), - IgnoreNullable(FetchedStoreProfile.Settings::favoritesEnabled), - IgnoreNullable(FetchedStoreProfile.Settings::fbPixelId), - IgnoreNullable(FetchedStoreProfile.Settings::googleAnalyticsId), - IgnoreNullable(FetchedStoreProfile.Settings::googleEventId), - IgnoreNullable(FetchedStoreProfile.Settings::googleRemarketingEnabled), - IgnoreNullable(FetchedStoreProfile.Settings::googleTagId), - IgnoreNullable(FetchedStoreProfile.Settings::hideOutOfStockProductsInStorefront), - IgnoreNullable(FetchedStoreProfile.Settings::invoiceLogoUrl), - IgnoreNullable(FetchedStoreProfile.Settings::orderCommentsCaption), - IgnoreNullable(FetchedStoreProfile.Settings::orderCommentsEnabled), - IgnoreNullable(FetchedStoreProfile.Settings::orderCommentsRequired), - IgnoreNullable(FetchedStoreProfile.Settings::pinterestTagId), - AllowNullable(FetchedStoreProfile.Settings::productReviewsFeatureEnabled), - IgnoreNullable(FetchedStoreProfile.Settings::salePrice), - IgnoreNullable(FetchedStoreProfile.Settings::showAcceptMarketingCheckbox), - IgnoreNullable(FetchedStoreProfile.Settings::snapPixelId), - IgnoreNullable(FetchedStoreProfile.Settings::storeDescription), - IgnoreNullable(FetchedStoreProfile.Settings::storeName), - IgnoreNullable(FetchedStoreProfile.Settings::tikTokPixel), - AllowNullable(FetchedStoreProfile.Settings::storeDescriptionTranslated), - AllowNullable(FetchedStoreProfile.Settings::rootCategorySeoTitle), - AllowNullable(FetchedStoreProfile.Settings::rootCategorySeoTitleTranslated), - AllowNullable(FetchedStoreProfile.Settings::rootCategorySeoDescription), - AllowNullable(FetchedStoreProfile.Settings::rootCategorySeoDescriptionTranslated), - IgnoreNullable(FetchedStoreProfile.Shipping::handlingFee), - IgnoreNullable(FetchedStoreProfile.Shipping::shippingOptions), - IgnoreNullable(FetchedStoreProfile.Shipping::shippingOrigin), - IgnoreNullable(FetchedStoreProfile.ShippingOrigin::city), - IgnoreNullable(FetchedStoreProfile.ShippingOrigin::companyName), - IgnoreNullable(FetchedStoreProfile.ShippingOrigin::countryCode), - IgnoreNullable(FetchedStoreProfile.ShippingOrigin::email), - IgnoreNullable(FetchedStoreProfile.ShippingOrigin::phone), - IgnoreNullable(FetchedStoreProfile.ShippingOrigin::postalCode), - IgnoreNullable(FetchedStoreProfile.ShippingOrigin::stateOrProvinceCode), - IgnoreNullable(FetchedStoreProfile.ShippingOrigin::street), - AllowNullable(FetchedStoreProfile.ShippingSettings::enabledShippingMethods), - IgnoreNullable(FetchedStoreProfile.TaxSettings::automaticTaxEnabled), - IgnoreNullable(FetchedStoreProfile.TaxSettings::pricesIncludeTax), - IgnoreNullable(FetchedStoreProfile.TaxSettings::taxes), - IgnoreNullable(FetchedStoreProfile.TaxSettings.TaxRule::tax), - IgnoreNullable(FetchedStoreProfile.TaxSettings.TaxRule::zoneId), - IgnoreNullable(FetchedStoreProfile.TaxSettings.Taxes::appliedByDefault), - IgnoreNullable(FetchedStoreProfile.TaxSettings.Taxes::defaultTax), - IgnoreNullable(FetchedStoreProfile.TaxSettings.Taxes::enabled), - IgnoreNullable(FetchedStoreProfile.TaxSettings.Taxes::id), - IgnoreNullable(FetchedStoreProfile.TaxSettings.Taxes::includeInPrice), - IgnoreNullable(FetchedStoreProfile.TaxSettings.Taxes::name), - IgnoreNullable(FetchedStoreProfile.TaxSettings.Taxes::rules), - IgnoreNullable(FetchedStoreProfile.TaxSettings.Taxes::taxShipping), - IgnoreNullable(FetchedStoreProfile.TaxSettings.Taxes::useShippingAddress), - IgnoreNullable(FetchedStoreProfile.TikTokPixelSettings::code), - IgnoreNullable(FetchedStoreProfile.Zone::countryCodes), - IgnoreNullable(FetchedStoreProfile.Zone::id), - IgnoreNullable(FetchedStoreProfile.Zone::name), - IgnoreNullable(FetchedStoreProfile.Zone::postCodes), - IgnoreNullable(FetchedStoreProfile.Zone::stateOrProvinceCodes), - AllowNullable(FetchedStoreProfile.Settings::googleProductCategory), - AllowNullable(FetchedStoreProfile.Settings::googleProductCategoryName), - AllowNullable(FetchedStoreProfile.InstantSiteInfo::ecwidSubdomainSuffix), - AllowNullable(FetchedStoreProfile.InstantSiteInfo::slugsWithoutIdsEnabled), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedSubscriptionRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedSubscriptionRules.kt deleted file mode 100644 index c8780e6ce..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedSubscriptionRules.kt +++ /dev/null @@ -1,116 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.subscriptions.result.FetchedSubscription -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val fetchedSubscriptionsNullablePropertyRules: List> = listOf( - AllowNullable(FetchedSubscription::cancelled), - AllowNullable(FetchedSubscription::createTimestamp), - AllowNullable(FetchedSubscription::updateTimestamp), - AllowNullable(FetchedSubscription::paymentMethod), - - AllowNullable(FetchedSubscription.PaymentMethod::creditCardMaskedNumber), - AllowNullable(FetchedSubscription.PaymentMethod::creditCardBrand), - - AllowNullable(FetchedSubscription.OrderTemplate::id), - AllowNullable(FetchedSubscription.OrderTemplate::email), - AllowNullable(FetchedSubscription.OrderTemplate::additionalInfo), - AllowNullable(FetchedSubscription.OrderTemplate::orderComments), - AllowNullable(FetchedSubscription.OrderTemplate::paymentMethod), - AllowNullable(FetchedSubscription.OrderTemplate::paymentModule), - AllowNullable(FetchedSubscription.OrderTemplate::total), - AllowNullable(FetchedSubscription.OrderTemplate::subtotal), - AllowNullable(FetchedSubscription.OrderTemplate::usdTotal), - AllowNullable(FetchedSubscription.OrderTemplate::tax), - AllowNullable(FetchedSubscription.OrderTemplate::customerTaxExempt), - AllowNullable(FetchedSubscription.OrderTemplate::customerTaxId), - AllowNullable(FetchedSubscription.OrderTemplate::customerTaxIdValid), - AllowNullable(FetchedSubscription.OrderTemplate::reversedTaxApplied), - AllowNullable(FetchedSubscription.OrderTemplate::items), - AllowNullable(FetchedSubscription.OrderTemplate::billingPerson), - AllowNullable(FetchedSubscription.OrderTemplate::shippingPerson), - AllowNullable(FetchedSubscription.OrderTemplate::shippingOption), - AllowNullable(FetchedSubscription.OrderTemplate::handlingFee), - AllowNullable(FetchedSubscription.OrderTemplate::pricesIncludeTax), - - - AllowNullable(FetchedSubscription.AdditionalInfo::creditCard), - AllowNullable(FetchedSubscription.AdditionalInfo::creditCardExpirationMonth), - AllowNullable(FetchedSubscription.AdditionalInfo::creditCardExpirationYear), - AllowNullable(FetchedSubscription.AdditionalInfo::googleCustomerId), - AllowNullable(FetchedSubscription.AdditionalInfo::stripeCardId), - AllowNullable(FetchedSubscription.AdditionalInfo::stripeCreditCardBrand), - AllowNullable(FetchedSubscription.AdditionalInfo::stripeCreditCardLast4Digit), - AllowNullable(FetchedSubscription.AdditionalInfo::stripeCustomerId), - AllowNullable(FetchedSubscription.AdditionalInfo::stripeFingerprint), - AllowNullable(FetchedSubscription.AdditionalInfo::stripeLiveMode), - - AllowNullable(FetchedSubscription.OrderItem::id), - AllowNullable(FetchedSubscription.OrderItem::productId), - AllowNullable(FetchedSubscription.OrderItem::categoryId), - AllowNullable(FetchedSubscription.OrderItem::price), - AllowNullable(FetchedSubscription.OrderItem::productPrice), - AllowNullable(FetchedSubscription.OrderItem::shipping), - AllowNullable(FetchedSubscription.OrderItem::tax), - AllowNullable(FetchedSubscription.OrderItem::fixedShippingRate), - AllowNullable(FetchedSubscription.OrderItem::sku), - AllowNullable(FetchedSubscription.OrderItem::name), - AllowNullable(FetchedSubscription.OrderItem::nameTranslated), - AllowNullable(FetchedSubscription.OrderItem::shortDescription), - AllowNullable(FetchedSubscription.OrderItem::quantity), - AllowNullable(FetchedSubscription.OrderItem::quantityInStock), - AllowNullable(FetchedSubscription.OrderItem::weight), - AllowNullable(FetchedSubscription.OrderItem::trackQuantity), - AllowNullable(FetchedSubscription.OrderItem::fixedShippingRateOnly), - AllowNullable(FetchedSubscription.OrderItem::digital), - AllowNullable(FetchedSubscription.OrderItem::productAvailable), - AllowNullable(FetchedSubscription.OrderItem::imageUrl), - AllowNullable(FetchedSubscription.OrderItem::smallThumbnailUrl), - AllowNullable(FetchedSubscription.OrderItem::hdThumbnailUrl), - AllowNullable(FetchedSubscription.OrderItem::recurringChargeSettings), - AllowNullable(FetchedSubscription.OrderItem::selectedOptions), - AllowNullable(FetchedSubscription.OrderItem::taxes), - AllowNullable(FetchedSubscription.OrderItem::dimensions), - - - AllowNullable(FetchedSubscription.SelectedOptions::name), - AllowNullable(FetchedSubscription.SelectedOptions::type), - AllowNullable(FetchedSubscription.SelectedOptions::value), - AllowNullable(FetchedSubscription.SelectedOptions::valuesArray), - AllowNullable(FetchedSubscription.SelectedOptions::selections), - - AllowNullable(FetchedSubscription.Selections::selectionTitle), - AllowNullable(FetchedSubscription.Selections::selectionModifier), - AllowNullable(FetchedSubscription.Selections::selectionModifierType), - - - AllowNullable(FetchedSubscription.Taxes::name), - AllowNullable(FetchedSubscription.Taxes::value), - AllowNullable(FetchedSubscription.Taxes::total), - AllowNullable(FetchedSubscription.Taxes::taxOnDiscountedSubtotal), - AllowNullable(FetchedSubscription.Taxes::taxOnShipping), - AllowNullable(FetchedSubscription.Taxes::includeInPrice), - - AllowNullable(FetchedSubscription.Dimensions::length), - AllowNullable(FetchedSubscription.Dimensions::width), - AllowNullable(FetchedSubscription.Dimensions::height), - - AllowNullable(FetchedSubscription.PersonInfo::name), - AllowNullable(FetchedSubscription.PersonInfo::companyName), - AllowNullable(FetchedSubscription.PersonInfo::street), - AllowNullable(FetchedSubscription.PersonInfo::city), - AllowNullable(FetchedSubscription.PersonInfo::countryCode), - AllowNullable(FetchedSubscription.PersonInfo::countryName), - AllowNullable(FetchedSubscription.PersonInfo::postalCode), - AllowNullable(FetchedSubscription.PersonInfo::stateOrProvinceCode), - AllowNullable(FetchedSubscription.PersonInfo::stateOrProvinceName), - AllowNullable(FetchedSubscription.PersonInfo::phone), - - AllowNullable(FetchedSubscription.ShippingOption::shippingMethodName), - AllowNullable(FetchedSubscription.ShippingOption::shippingRate), - - AllowNullable(FetchedSubscription.HandlingFee::name), - AllowNullable(FetchedSubscription.HandlingFee::value), - AllowNullable(FetchedSubscription.HandlingFee::description), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedVariationRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedVariationRules.kt deleted file mode 100644 index 0f5457c0e..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/FetchedVariationRules.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.common.FetchedAlt -import com.ecwid.apiclient.v3.dto.variation.result.FetchedVariation -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val fetchedVariationTypeNullablePropertyRules: List> = listOf( - IgnoreNullable(FetchedVariation::attributes), - AllowNullable(FetchedVariation::borderInfo), - IgnoreNullable(FetchedVariation::compareToPrice), - IgnoreNullable(FetchedVariation::lowestPrice), - IgnoreNullable(FetchedVariation::defaultDisplayedLowestPrice), - IgnoreNullable(FetchedVariation::defaultDisplayedLowestPriceFormatted), - AllowNullable(FetchedVariation.LowestPriceSettings::manualLowestPrice), - AllowNullable(FetchedVariation.LowestPriceSettings::defaultDisplayedLowestPrice), - AllowNullable(FetchedVariation.LowestPriceSettings::defaultDisplayedLowestPriceFormatted), - AllowNullable(FetchedVariation.LowestPriceSettings::automaticLowestPrice), - AllowNullable(FetchedVariation.LowestPriceSettings::defaultDisplayedAutomaticLowestPrice), - AllowNullable(FetchedVariation.LowestPriceSettings::defaultDisplayedAutomaticLowestPriceFormatted), - AllowNullable(FetchedVariation::costPrice), - AllowNullable(FetchedVariation::customsHsTariffCode), - IgnoreNullable(FetchedVariation::defaultDisplayedPrice), - IgnoreNullable(FetchedVariation::defaultDisplayedPriceFormatted), - AllowNullable(FetchedVariation::dimensions), - IgnoreNullable(FetchedVariation::hdThumbnailUrl), - IgnoreNullable(FetchedVariation::imageUrl), - AllowNullable(FetchedVariation::inStock), - IgnoreNullable(FetchedVariation::isShippingRequired), - IgnoreNullable(FetchedVariation::options), - IgnoreNullable(FetchedVariation::originalImageUrl), - IgnoreNullable(FetchedVariation::price), - IgnoreNullable(FetchedVariation::quantity), - IgnoreNullable(FetchedVariation::outOfStockVisibilityBehaviour), - IgnoreNullable(FetchedVariation::sku), - IgnoreNullable(FetchedVariation::smallThumbnailUrl), - IgnoreNullable(FetchedVariation::thumbnailUrl), - IgnoreNullable(FetchedVariation::unlimited), - IgnoreNullable(FetchedVariation::warningLimit), - AllowNullable(FetchedVariation::minPurchaseQuantity), - AllowNullable(FetchedVariation::maxPurchaseQuantity), - IgnoreNullable(FetchedVariation::weight), - IgnoreNullable(FetchedVariation::wholesalePrices), - AllowNullable(FetchedVariation::externalReferenceId), - IgnoreNullable(FetchedVariation.AttributeValue::id), - IgnoreNullable(FetchedVariation.AttributeValue::name), - IgnoreNullable(FetchedVariation.AttributeValue::show), - IgnoreNullable(FetchedVariation.AttributeValue::type), - IgnoreNullable(FetchedVariation.AttributeValue::value), - IgnoreNullable(FetchedVariation.AttributeValue::valueTranslated), - AllowNullable(FetchedVariation.BorderInfo::homogeneity), - AllowNullable(FetchedVariation.BorderInfo::dominatingColor), - AllowNullable(FetchedVariation.Color::alpha), - AllowNullable(FetchedVariation.Color::blue), - AllowNullable(FetchedVariation.Color::green), - AllowNullable(FetchedVariation.Color::red), - IgnoreNullable(FetchedVariation.Option::name), - IgnoreNullable(FetchedVariation.Option::nameTranslated), - IgnoreNullable(FetchedVariation.Option::value), - IgnoreNullable(FetchedVariation.Option::valueTranslated), - IgnoreNullable(FetchedVariation::subscriptionSettings), - IgnoreNullable(FetchedVariation.RecurringChargeSettings::signUpFee), - IgnoreNullable(FetchedVariation.RecurringChargeSettings::signUpFeeFormatted), - AllowNullable(FetchedVariation.RecurringChargeSettings::subscriptionPriceWithSignUpFee), - IgnoreNullable(FetchedVariation.RecurringChargeSettings::subscriptionPriceWithSignUpFeeFormatted), - IgnoreNullable(FetchedVariation.SubscriptionSettings::oneTimePurchaseMarkup), - IgnoreNullable(FetchedVariation.SubscriptionSettings::oneTimePurchaseMarkupFormatted), - IgnoreNullable(FetchedVariation.SubscriptionSettings::oneTimePurchaseMarkupPercent), - IgnoreNullable(FetchedVariation.SubscriptionSettings::oneTimePurchaseMarkupPercentFormatted), - IgnoreNullable(FetchedVariation.SubscriptionSettings::displayedOneTimePurchaseMarkupPercent), - IgnoreNullable(FetchedVariation.SubscriptionSettings::displayedOneTimePurchaseMarkupPercentFormatted), - AllowNullable(FetchedVariation.SubscriptionSettings::oneTimePurchasePrice), - IgnoreNullable(FetchedVariation.SubscriptionSettings::oneTimePurchasePriceFormatted), - AllowNullable(FetchedVariation::locationInventory), - AllowNullable(FetchedVariation::alt), - AllowNullable(FetchedAlt::main), - AllowNullable(FetchedAlt::translated), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/GetProductFiltersRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/GetProductFiltersRequestRules.kt deleted file mode 100644 index e83f2dacd..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/GetProductFiltersRequestRules.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.product.request.GetProductFiltersRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val getProductFiltersRequestNullablePropertyRules: List> = listOf( - AllowNullable(GetProductFiltersRequest::attributes), - AllowNullable(GetProductFiltersRequest::categories), - AllowNullable(GetProductFiltersRequest::createdFrom), - AllowNullable(GetProductFiltersRequest::createdTo), - AllowNullable(GetProductFiltersRequest::enabled), - AllowNullable(GetProductFiltersRequest::filterFacetLimits), - AllowNullable(GetProductFiltersRequest::filterParentCategoryId), - AllowNullable(GetProductFiltersRequest::includeProductsFromSubcategories), - AllowNullable(GetProductFiltersRequest::inventory), - AllowNullable(GetProductFiltersRequest::keyword), - AllowNullable(GetProductFiltersRequest::lang), - AllowNullable(GetProductFiltersRequest::onSale), - AllowNullable(GetProductFiltersRequest::options), - AllowNullable(GetProductFiltersRequest::priceFrom), - AllowNullable(GetProductFiltersRequest::priceTo), - AllowNullable(GetProductFiltersRequest::updatedFrom), - AllowNullable(GetProductFiltersRequest::updatedTo) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrderForCalculateRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrderForCalculateRules.kt deleted file mode 100644 index c969c8605..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrderForCalculateRules.kt +++ /dev/null @@ -1,148 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.cart.request.OrderForCalculate -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.IgnoreNullable - -val orderForCalculateNullablePropertyRules: List> = listOf( - IgnoreNullable(OrderForCalculate::billingPerson), - IgnoreNullable(OrderForCalculate::customerId), - AllowNullable(OrderForCalculate::customerTaxId), - AllowNullable(OrderForCalculate::customerTaxExempt), - AllowNullable(OrderForCalculate::customSurcharges), - IgnoreNullable(OrderForCalculate::discountCoupon), - IgnoreNullable(OrderForCalculate::discountInfo), - IgnoreNullable(OrderForCalculate::email), - AllowNullable(OrderForCalculate::handlingFee), - AllowNullable(OrderForCalculate::giftCardCode), - AllowNullable(OrderForCalculate::giftCardId), - AllowNullable(OrderForCalculate::giftCardUuid), - AllowNullable(OrderForCalculate::giftCardTransactionOrderId), - AllowNullable(OrderForCalculate::giftCardRedemption), - AllowNullable(OrderForCalculate::totalBeforeGiftCardRedemption), - AllowNullable(OrderForCalculate::giftCardDoubleSpending), - IgnoreNullable(OrderForCalculate::ipAddress), - IgnoreNullable(OrderForCalculate::items), - AllowNullable(OrderForCalculate::paymentOptionsDetails), - AllowNullable(OrderForCalculate::reversedTaxApplied), - AllowNullable(OrderForCalculate::shippingOption), - IgnoreNullable(OrderForCalculate::shippingPerson), - AllowNullable(OrderForCalculate.CustomSurcharge::description), - AllowNullable(OrderForCalculate.CustomSurcharge::id), - AllowNullable(OrderForCalculate.CustomSurcharge::taxable), - AllowNullable(OrderForCalculate.CustomSurcharge::type), - AllowNullable(OrderForCalculate.CustomSurcharge::value), - IgnoreNullable(OrderForCalculate.DiscountCouponCatalogLimit::categories), - IgnoreNullable(OrderForCalculate.DiscountCouponCatalogLimit::products), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::applicationLimit), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::catalogLimit), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::code), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::creationDate), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::discount), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::discountType), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::expirationDate), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::launchDate), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::name), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::orderCount), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::status), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::totalLimit), - IgnoreNullable(OrderForCalculate.DiscountCouponInfo::usesLimit), - IgnoreNullable(OrderForCalculate.DiscountInfo::base), - IgnoreNullable(OrderForCalculate.DiscountInfo::description), - IgnoreNullable(OrderForCalculate.DiscountInfo::orderTotal), - IgnoreNullable(OrderForCalculate.DiscountInfo::type), - IgnoreNullable(OrderForCalculate.DiscountInfo::value), - AllowNullable(OrderForCalculate.DiscountInfo::appliesToProducts), - AllowNullable(OrderForCalculate.DiscountInfo::appliesToItems), - AllowNullable(OrderForCalculate.HandlingFee::description), - AllowNullable(OrderForCalculate.HandlingFee::name), - AllowNullable(OrderForCalculate.HandlingFee::taxes), - AllowNullable(OrderForCalculate.HandlingFee::value), - AllowNullable(OrderForCalculate.HandlingFeeTax::name), - AllowNullable(OrderForCalculate.HandlingFeeTax::value), - AllowNullable(OrderForCalculate.HandlingFeeTax::total), - IgnoreNullable(OrderForCalculate.OrderItem::categoryId), - IgnoreNullable(OrderForCalculate.OrderItem::couponAmount), - IgnoreNullable(OrderForCalculate.OrderItem::couponApplied), - AllowNullable(OrderForCalculate.OrderItem::giftCard), - IgnoreNullable(OrderForCalculate.OrderItem::digital), - IgnoreNullable(OrderForCalculate.OrderItem::dimensions), - IgnoreNullable(OrderForCalculate.OrderItem::discounts), - IgnoreNullable(OrderForCalculate.OrderItem::files), - IgnoreNullable(OrderForCalculate.OrderItem::fixedShippingRate), - IgnoreNullable(OrderForCalculate.OrderItem::fixedShippingRateOnly), - IgnoreNullable(OrderForCalculate.OrderItem::id), - IgnoreNullable(OrderForCalculate.OrderItem::imageUrl), - IgnoreNullable(OrderForCalculate.OrderItem::isShippingRequired), - IgnoreNullable(OrderForCalculate.OrderItem::name), - AllowNullable(OrderForCalculate.OrderItem::needCalculateWholesalePrice), - IgnoreNullable(OrderForCalculate.OrderItem::price), - IgnoreNullable(OrderForCalculate.OrderItem::productId), - IgnoreNullable(OrderForCalculate.OrderItem::productPrice), - IgnoreNullable(OrderForCalculate.OrderItem::quantity), - IgnoreNullable(OrderForCalculate.OrderItem::quantityInStock), - IgnoreNullable(OrderForCalculate.OrderItem::selectedOptions), - AllowNullable(OrderForCalculate.OrderItem::combinationId), - IgnoreNullable(OrderForCalculate.OrderItem::shipping), - IgnoreNullable(OrderForCalculate.OrderItem::shortDescription), - IgnoreNullable(OrderForCalculate.OrderItem::sku), - IgnoreNullable(OrderForCalculate.OrderItem::tax), - IgnoreNullable(OrderForCalculate.OrderItem::taxes), - IgnoreNullable(OrderForCalculate.OrderItem::trackQuantity), - IgnoreNullable(OrderForCalculate.OrderItem::weight), - IgnoreNullable(OrderForCalculate.OrderItemDiscountInfo::base), - IgnoreNullable(OrderForCalculate.OrderItemDiscountInfo::orderTotal), - IgnoreNullable(OrderForCalculate.OrderItemDiscountInfo::type), - IgnoreNullable(OrderForCalculate.OrderItemDiscountInfo::value), - IgnoreNullable(OrderForCalculate.OrderItemDiscounts::discountInfo), - IgnoreNullable(OrderForCalculate.OrderItemDiscounts::total), - IgnoreNullable(OrderForCalculate.OrderItemOptionFile::id), - IgnoreNullable(OrderForCalculate.OrderItemOptionFile::name), - IgnoreNullable(OrderForCalculate.OrderItemOptionFile::size), - IgnoreNullable(OrderForCalculate.OrderItemOptionFile::url), - IgnoreNullable(OrderForCalculate.OrderItemOption::files), - IgnoreNullable(OrderForCalculate.OrderItemOption::name), - IgnoreNullable(OrderForCalculate.OrderItemOption::selections), - IgnoreNullable(OrderForCalculate.OrderItemOption::type), - IgnoreNullable(OrderForCalculate.OrderItemOption::value), - IgnoreNullable(OrderForCalculate.OrderItemOption::valuesArray), - IgnoreNullable(OrderForCalculate.OrderItemProductFile::adminUrl), - IgnoreNullable(OrderForCalculate.OrderItemProductFile::customerUrl), - IgnoreNullable(OrderForCalculate.OrderItemProductFile::description), - IgnoreNullable(OrderForCalculate.OrderItemProductFile::expire), - IgnoreNullable(OrderForCalculate.OrderItemProductFile::maxDownloads), - IgnoreNullable(OrderForCalculate.OrderItemProductFile::name), - IgnoreNullable(OrderForCalculate.OrderItemProductFile::productFileId), - IgnoreNullable(OrderForCalculate.OrderItemProductFile::remainingDownloads), - IgnoreNullable(OrderForCalculate.OrderItemProductFile::size), - AllowNullable(OrderForCalculate.OrderItemTax::taxType), - IgnoreNullable(OrderForCalculate.OrderItemTax::includeInPrice), - IgnoreNullable(OrderForCalculate.OrderItemTax::name), - IgnoreNullable(OrderForCalculate.OrderItemTax::taxOnDiscountedSubtotal), - IgnoreNullable(OrderForCalculate.OrderItemTax::taxOnShipping), - IgnoreNullable(OrderForCalculate.OrderItemTax::total), - IgnoreNullable(OrderForCalculate.OrderItemTax::value), - AllowNullable(OrderForCalculate.PaymentOption::paymentId), - IgnoreNullable(OrderForCalculate.PersonInfo::city), - IgnoreNullable(OrderForCalculate.PersonInfo::companyName), - IgnoreNullable(OrderForCalculate.PersonInfo::countryCode), - IgnoreNullable(OrderForCalculate.PersonInfo::countryName), - IgnoreNullable(OrderForCalculate.PersonInfo::name), - IgnoreNullable(OrderForCalculate.PersonInfo::phone), - IgnoreNullable(OrderForCalculate.PersonInfo::postalCode), - IgnoreNullable(OrderForCalculate.PersonInfo::stateOrProvinceCode), - IgnoreNullable(OrderForCalculate.PersonInfo::stateOrProvinceName), - IgnoreNullable(OrderForCalculate.PersonInfo::street), - IgnoreNullable(OrderForCalculate.ProductDimensions::height), - IgnoreNullable(OrderForCalculate.ProductDimensions::length), - IgnoreNullable(OrderForCalculate.ProductDimensions::width), - IgnoreNullable(OrderForCalculate.SelectionInfo::selectionModifier), - IgnoreNullable(OrderForCalculate.SelectionInfo::selectionModifierType), - IgnoreNullable(OrderForCalculate.SelectionInfo::selectionTitle), - AllowNullable(OrderForCalculate.ShippingOption::fulfillmentType), - AllowNullable(OrderForCalculate.ShippingOption::pickupInstruction), - AllowNullable(OrderForCalculate.ShippingOption::shippingMethodId), - AllowNullable(OrderForCalculate.ShippingOption::shippingMethodName), - AllowNullable(OrderForCalculate.ShippingOption::shippingRate), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrdersSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrdersSearchRequestRules.kt deleted file mode 100644 index 8092c0149..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/OrdersSearchRequestRules.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.order.request.OrdersSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val ordersSearchRequestRequestNullablePropertyRules: List> = listOf( - AllowNullable(OrdersSearchRequest::couponCode), - AllowNullable(OrdersSearchRequest::createdFrom), - AllowNullable(OrdersSearchRequest::createdTo), - AllowNullable(OrdersSearchRequest::customer), - AllowNullable(OrdersSearchRequest::customerId), - AllowNullable(OrdersSearchRequest::email), - AllowNullable(OrdersSearchRequest::customerIdOrEmail), - AllowNullable(OrdersSearchRequest::fulfillmentStatus), - AllowNullable(OrdersSearchRequest::ids), - AllowNullable(OrdersSearchRequest::keywords), - AllowNullable(OrdersSearchRequest::orderNumber), - AllowNullable(OrdersSearchRequest::paymentMethod), - AllowNullable(OrdersSearchRequest::paymentStatus), - AllowNullable(OrdersSearchRequest::shippingMethod), - AllowNullable(OrdersSearchRequest::totalFrom), - AllowNullable(OrdersSearchRequest::totalTo), - AllowNullable(OrdersSearchRequest::updatedFrom), - AllowNullable(OrdersSearchRequest::updatedTo), - AllowNullable(OrdersSearchRequest::vendorOrderNumber), - AllowNullable(OrdersSearchRequest::subscriptionIds), - AllowNullable(OrdersSearchRequest::pickupTimeFrom), - AllowNullable(OrdersSearchRequest::pickupTimeTo), - AllowNullable(OrdersSearchRequest::paymentReference), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductDetailsRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductDetailsRequestRules.kt deleted file mode 100644 index dc65a4b7d..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductDetailsRequestRules.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.product.request.ProductDetailsRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val productDetailsRequestNullablePropertyRules: List> = listOf( - AllowNullable(ProductDetailsRequest::baseUrl), - AllowNullable(ProductDetailsRequest::cleanUrls), - AllowNullable(ProductDetailsRequest::slugsWithoutIds), - AllowNullable(ProductDetailsRequest::lang) -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewMassUpdateRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewMassUpdateRequestRules.kt deleted file mode 100644 index 29869f3e2..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewMassUpdateRequestRules.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.productreview.request.ProductReviewMassUpdate -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val productReviewMassUpdateRequestNullablePropertyRules: List> = listOf( - AllowNullable(ProductReviewMassUpdate.Filters::createdFrom), - AllowNullable(ProductReviewMassUpdate.Filters::createdTo), - AllowNullable(ProductReviewMassUpdate.Filters::orderId), - AllowNullable(ProductReviewMassUpdate.Filters::productId), - AllowNullable(ProductReviewMassUpdate.Filters::rating), - AllowNullable(ProductReviewMassUpdate.Filters::reviewId), - AllowNullable(ProductReviewMassUpdate.Filters::searchKeyword), - AllowNullable(ProductReviewMassUpdate.Filters::status), - AllowNullable(ProductReviewMassUpdate::filters), - AllowNullable(ProductReviewMassUpdate::newStatus), - AllowNullable(ProductReviewMassUpdate::reviewIds), - AllowNullable(ProductReviewMassUpdate::selectMode), - AllowNullable(ProductReviewMassUpdate::sendUpdateToReviewsService), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewSearchRequestRules.kt deleted file mode 100644 index 08e2c79a9..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductReviewSearchRequestRules.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.productreview.request.ProductReviewSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val productReviewSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(ProductReviewSearchRequest::createdFrom), - AllowNullable(ProductReviewSearchRequest::createdTo), - AllowNullable(ProductReviewSearchRequest::orderId), - AllowNullable(ProductReviewSearchRequest::productId), - AllowNullable(ProductReviewSearchRequest::rating), - AllowNullable(ProductReviewSearchRequest::reviewId), - AllowNullable(ProductReviewSearchRequest::searchKeyword), - AllowNullable(ProductReviewSearchRequest::sortBy), - AllowNullable(ProductReviewSearchRequest::status), - AllowNullable(ProductReviewSearchRequest::updatedFrom), - AllowNullable(ProductReviewSearchRequest::updatedTo), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductsSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductsSearchRequestRules.kt deleted file mode 100644 index 0713ded8f..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/ProductsSearchRequestRules.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.product.request.ProductsSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val productsSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(ProductsSearchRequest.ByFilters::attributes), - AllowNullable(ProductsSearchRequest.ByFilters::baseUrl), - AllowNullable(ProductsSearchRequest.ByFilters::categories), - AllowNullable(ProductsSearchRequest.ByFilters::cleanUrls), - AllowNullable(ProductsSearchRequest.ByFilters::slugsWithoutIds), - AllowNullable(ProductsSearchRequest.ByFilters::createdFrom), - AllowNullable(ProductsSearchRequest.ByFilters::createdTo), - AllowNullable(ProductsSearchRequest.ByFilters::enabled), - AllowNullable(ProductsSearchRequest.ByFilters::inStock), - AllowNullable(ProductsSearchRequest.ByFilters::includeProductsFromSubcategories), - AllowNullable(ProductsSearchRequest.ByFilters::inventory), - AllowNullable(ProductsSearchRequest.ByFilters::keyword), - AllowNullable(ProductsSearchRequest.ByFilters::lang), - AllowNullable(ProductsSearchRequest.ByFilters::onSale), - AllowNullable(ProductsSearchRequest.ByFilters::options), - AllowNullable(ProductsSearchRequest.ByFilters::priceFrom), - AllowNullable(ProductsSearchRequest.ByFilters::priceTo), - AllowNullable(ProductsSearchRequest.ByFilters::searchMethod), - AllowNullable(ProductsSearchRequest.ByFilters::sku), - AllowNullable(ProductsSearchRequest.ByFilters::sortBy), - AllowNullable(ProductsSearchRequest.ByFilters::updatedFrom), - AllowNullable(ProductsSearchRequest.ByFilters::updatedTo), - AllowNullable(ProductsSearchRequest.ByFilters::externalReferenceId), - AllowNullable(ProductsSearchRequest.ByFilters::isGiftCard), - AllowNullable(ProductsSearchRequest.ByFilters::discountsAllowed), - AllowNullable(ProductsSearchRequest.ByFilters::isCustomerSetPrice), - AllowNullable(ProductsSearchRequest.ByFilters::visibleInStorefront), - AllowNullable(ProductsSearchRequest.ByIds::baseUrl), - AllowNullable(ProductsSearchRequest.ByIds::cleanUrls), - AllowNullable(ProductsSearchRequest.ByIds::slugsWithoutIds), - AllowNullable(ProductsSearchRequest.ByIds::sortBy), - AllowNullable(ProductsSearchRequest.ByIds::lang), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/SlugInfoRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/SlugInfoRequestRules.kt deleted file mode 100644 index ab01f811b..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/SlugInfoRequestRules.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.sluginfo.SlugInfoRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val slugInfoRequestNullablePropertyRules: List> = listOf( - AllowNullable(SlugInfoRequest::degeneratorParams), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/SubscriptionsSearchRequestRules.kt b/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/SubscriptionsSearchRequestRules.kt deleted file mode 100644 index c746afb34..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/rule/nullablepropertyrules/SubscriptionsSearchRequestRules.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.ecwid.apiclient.v3.rule.nullablepropertyrules - -import com.ecwid.apiclient.v3.dto.subscriptions.request.SubscriptionsSearchRequest -import com.ecwid.apiclient.v3.rule.NullablePropertyRule -import com.ecwid.apiclient.v3.rule.NullablePropertyRule.AllowNullable - -val subscriptionsSearchRequestNullablePropertyRules: List> = listOf( - AllowNullable(SubscriptionsSearchRequest::id), - AllowNullable(SubscriptionsSearchRequest::createdFrom), - AllowNullable(SubscriptionsSearchRequest::createdTo), - AllowNullable(SubscriptionsSearchRequest::cancelledFrom), - AllowNullable(SubscriptionsSearchRequest::cancelledTo), - AllowNullable(SubscriptionsSearchRequest::updatedFrom), - AllowNullable(SubscriptionsSearchRequest::updatedTo), - AllowNullable(SubscriptionsSearchRequest::customerId), - AllowNullable(SubscriptionsSearchRequest::status), - AllowNullable(SubscriptionsSearchRequest::nextChargeFrom), - AllowNullable(SubscriptionsSearchRequest::nextChargeTo), - AllowNullable(SubscriptionsSearchRequest::recurringInterval), - AllowNullable(SubscriptionsSearchRequest::recurringIntervalCount), - AllowNullable(SubscriptionsSearchRequest::productId), - AllowNullable(SubscriptionsSearchRequest::email), - AllowNullable(SubscriptionsSearchRequest::orderId), - AllowNullable(SubscriptionsSearchRequest::orderTotal), - AllowNullable(SubscriptionsSearchRequest::orderCreatedFrom), - AllowNullable(SubscriptionsSearchRequest::orderCreatedTo), - AllowNullable(SubscriptionsSearchRequest::lang), -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/DTORandomDataProviderStrategy.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/DTORandomDataProviderStrategy.kt deleted file mode 100644 index f069fc371..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/DTORandomDataProviderStrategy.kt +++ /dev/null @@ -1,94 +0,0 @@ -package com.ecwid.apiclient.v3.util - -import org.reflections.Reflections -import org.reflections.util.ReflectionUtilsPredicates.withClassModifier -import uk.co.jemos.podam.api.AbstractRandomDataProviderStrategy -import uk.co.jemos.podam.api.DataProviderStrategy -import uk.co.jemos.podam.common.PodamConstants -import java.lang.reflect.Constructor -import java.lang.reflect.Modifier -import java.util.* - -internal class DTORandomDataProviderStrategy : AbstractRandomDataProviderStrategy() { - - private val concreteSubclassesMap = HashMap, ConcreteSubclassesProvider<*>>() - - override fun sort(constructors: Array>, order: DataProviderStrategy.Order) { - // We should not call surrogate data constructor with random parameters - // Instead we should call the second most parameters constructor - constructors.sortWith( - compareBy { c: Constructor<*> -> - c.parameterTypes.lastOrNull()?.simpleName == "DefaultConstructorMarker" - }.thenByDescending { c: Constructor<*> -> - c.parameterTypes.size - } - ) - } - - override fun getSpecificClass(abstractClass: Class): Class { - return getConcreteSubclassesProvider(abstractClass).next - } - - override fun getNumberOfCollectionElements(type: Class<*>): Int { - return when { - type.isEnum -> type.enumConstants.size - type.isInterface || Modifier.isAbstract(type.modifiers) -> getConcreteSubclassesProvider(type).count - else -> PodamConstants.DEFAULT_NBR_COLLECTION_ELEMENTS - } - } - - private fun getConcreteSubclassesProvider(abstractClass: Class): ConcreteSubclassesProvider { - @Suppress("UNCHECKED_CAST") - return concreteSubclassesMap.getOrPut(abstractClass) { - ConcreteSubclassesProvider(abstractClass) - } as ConcreteSubclassesProvider - } - - private class ConcreteSubclassesProvider(val abstractClass: Class) { - - private val subclasses = LinkedList>() - private var iterator: Iterator> - - val next: Class - get() { - if (subclasses.isEmpty()) { - return abstractClass - } - if (!iterator.hasNext()) { - iterator = subclasses.iterator() - } - return iterator.next() - } - - val count: Int - get() = subclasses.size - - init { - fillConcreteSubclasses(abstractClass) - sortClassesByName(subclasses) - iterator = subclasses.iterator() - } - - @Suppress("UNCHECKED_CAST") - private fun fillConcreteSubclasses(abstractClass: Class) { - val subclasses = reflections.getSubTypesOf(abstractClass as Class) - .filter { clazz -> - val isAbstract = withClassModifier(Modifier.ABSTRACT).test(clazz) - val isInterface = withClassModifier(Modifier.INTERFACE).test(clazz) - val isSubclassOfEnum = clazz?.superclass?.isEnum == true - !isAbstract && !isInterface && !isSubclassOfEnum - } - this.subclasses.addAll(subclasses) - } - - private fun sortClassesByName(classes: MutableList>) { - classes.sortWith { x, y -> - x.simpleName.compareTo(y.simpleName) - } - } - - companion object { - private val reflections = Reflections("com.ecwid.apiclient.v3") - } - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/DTOsEmptinessChecker.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/DTOsEmptinessChecker.kt deleted file mode 100644 index 4164d2618..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/DTOsEmptinessChecker.kt +++ /dev/null @@ -1,189 +0,0 @@ -package com.ecwid.apiclient.v3.util - -import java.lang.reflect.Modifier -import java.util.* -import kotlin.reflect.KProperty1 -import kotlin.reflect.jvm.kotlinProperty - -internal fun checkDTOFieldsEmptiness( - values: Collection, - ignoredFields: List> -): Set { - val problemsCollector = mutableSetOf() - values.forEach { value -> - checkFieldEmptiness( - value = value, - fieldName = "", - declaringClass = value?.javaClass, - problemsCollector = problemsCollector, - ignoredProperties = ignoredFields - ) - } - return problemsCollector.toSet() -} - -private fun checkFieldEmptiness( - value: Any?, - fieldName: String, - declaringClass: Class<*>?, - problemsCollector: MutableSet, - ignoredProperties: List> -) { - when { - value == null -> { - problemsCollector.add( - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.NULL_VALUE, - fieldClass = declaringClass, - fieldName = fieldName - ) - ) - } - value.javaClass.kotlin.javaPrimitiveType != null -> { - if (isPrimitiveAndHasDefaultValue(value)) { - problemsCollector.add( - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = declaringClass, - fieldName = fieldName - ) - ) - } else { - // That's fine - } - } - value is String -> { - if (value == "") { - problemsCollector.add( - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = declaringClass, - fieldName = fieldName - ) - ) - } else { - // Any non-empty string is fine - } - } - value is Date -> { - if (value == Date(0)) { - problemsCollector.add( - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.DEFAULT_VALUE, - fieldClass = declaringClass, - fieldName = fieldName - ) - ) - } else { - // Any nonnull dates and dates not equal to epoch timestamp are fine - } - } - value is Enum<*> -> { - // Any nonnull enum value is fine - } - value is List<*> -> { - value.filterNotNull() - .apply { - if (isEmpty()) { - problemsCollector.add( - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.EMPTY_LIST, - fieldClass = declaringClass, - fieldName = fieldName - ) - ) - } - } - .forEach { listValue -> - checkFieldEmptiness( - value = listValue, - fieldName = "$fieldName (list value)", - declaringClass = declaringClass, - problemsCollector = problemsCollector, - ignoredProperties = ignoredProperties - ) - } - } - value is Map<*, *> -> { - value.entries - .mapNotNull { (k, v) -> - if (k != null && v != null) { - k to v - } else { - null - } - } - .apply { - if (isEmpty()) { - problemsCollector.add( - FieldEmptinessProblem( - kind = FieldEmptinessProblemKind.EMPTY_MAP, - fieldClass = declaringClass, - fieldName = fieldName - ) - ) - } - } - .forEach { (k, v) -> - checkFieldEmptiness( - value = k, - fieldName = "$fieldName (map key)", - declaringClass = declaringClass, - problemsCollector = problemsCollector, - ignoredProperties = ignoredProperties - ) - checkFieldEmptiness( - value = v, - fieldName = "$fieldName (map value)", - declaringClass = declaringClass, - problemsCollector = problemsCollector, - ignoredProperties = ignoredProperties - ) - } - } - else -> { - value.javaClass.declaredFields - .forEach { innerField -> - if (!Modifier.isStatic(innerField.modifiers)) { - innerField.trySetAccessible() - val fieldValue = innerField.get(value) - val isCompanion = fieldValue?.javaClass?.kotlin?.isCompanion ?: false - val isIgnored = innerField.kotlinProperty in ignoredProperties - if (!isCompanion && !isIgnored) { - checkFieldEmptiness( - value = fieldValue, - fieldName = innerField.name, - declaringClass = value.javaClass, - problemsCollector = problemsCollector, - ignoredProperties = ignoredProperties - ) - } - } - } - } - } -} - -private fun isPrimitiveAndHasDefaultValue(value: Any) = when (value) { - is Byte -> value == 0.toByte() - is Boolean -> value == false - is Short -> value == 0.toShort() - is Int -> value == 0 - is Long -> value == 0L - is Float -> value == 0.0f - is Double -> value == 0.0 - else -> false -} - -internal enum class FieldEmptinessProblemKind { - NULL_VALUE, - DEFAULT_VALUE, - EMPTY_LIST, - EMPTY_MAP -} - -internal data class FieldEmptinessProblem( - val kind: FieldEmptinessProblemKind, - val fieldClass: Class<*>?, - val fieldName: String? -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/FetchedUpdatedDTOsChecker.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/FetchedUpdatedDTOsChecker.kt deleted file mode 100644 index 4331d2909..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/FetchedUpdatedDTOsChecker.kt +++ /dev/null @@ -1,304 +0,0 @@ -package com.ecwid.apiclient.v3.util - -import com.ecwid.apiclient.v3.dto.common.NullableUpdatedValue -import com.ecwid.apiclient.v3.rule.NonUpdatablePropertyRule -import java.lang.reflect.Field -import java.lang.reflect.ParameterizedType -import java.lang.reflect.Type -import kotlin.reflect.jvm.kotlinProperty - -data class FetchedUpdatedDTO( - val fetchedClass: Class<*>, - val updatedClass: Class<*> -) - -internal fun checkFetchedUpdatedDTOsFields( - fetchedDTOClass: Class<*>, - updatedDTOClass: Class<*>, - nonUpdatablePropertyRules: List> -): List { - val fetchedUpdatedDTOs = listOf( - FetchedUpdatedDTO( - fetchedClass = fetchedDTOClass, - updatedClass = updatedDTOClass - ) - ) - return checkFetchedUpdatedDTOsFields(fetchedUpdatedDTOs, nonUpdatablePropertyRules) -} - -internal fun checkFetchedUpdatedDTOsFields( - fetchedUpdatedDTOs: List, - nonUpdatablePropertyRules: List> -): List { - val problemsCollector = mutableListOf() - fetchedUpdatedDTOs.forEach { fetchedUpdatedDTO -> - checkClass( - fetchedDTOClass = fetchedUpdatedDTO.fetchedClass, - updatedDTOClass = fetchedUpdatedDTO.updatedClass, - nonUpdatablePropertyRules = nonUpdatablePropertyRules, - problemsCollector = problemsCollector - ) - } - return problemsCollector.toList() -} - -private fun checkClass( - fetchedDTOClass: Class<*>, - updatedDTOClass: Class<*>, - nonUpdatablePropertyRules: List>, - problemsCollector: MutableList -) { - fetchedDTOClass.declaredFields - .forEach { fetchedDTOField -> - val updatedDTOField = updatedDTOClass.declaredFields - .find { declaredField -> - declaredField.name == fetchedDTOField.name - } - if (updatedDTOField == null) { - val kotlinProperty = fetchedDTOField.kotlinProperty - val isIgnored = nonUpdatablePropertyRules.any { rule -> - rule.property == kotlinProperty - } - if (!isIgnored) { - problemsCollector.add( - FieldProblem( - kind = FieldProblemKind.FIELD_NOT_FOUND, - fetchedDTOClass = fetchedDTOClass, - updatedDTOClass = updatedDTOClass, - fieldName = fetchedDTOField.name, - expectedFieldClass = fetchedDTOField.type, - actualFieldClass = null - ) - ) - } else { - // That's fine - } - } else { - checkField( - fetchedDTOClass = fetchedDTOClass, - updatedDTOClass = updatedDTOClass, - fetchedDTOField = fetchedDTOField, - updatedDTOField = updatedDTOField, - fieldName = fetchedDTOField.name, - nonUpdatablePropertyRules = nonUpdatablePropertyRules, - problemsCollector = problemsCollector - ) - } - } -} - -private fun checkClassOrPrimitive( - fetchedDTOClass: Class<*>, - updatedDTOClass: Class<*>, - parentFetchedDTOClass: Class<*>, - parentUpdatedDTOClass: Class<*>, - fieldName: String, - nonUpdatablePropertyRules: List>, - problemsCollector: MutableList -) { - if (fetchedDTOClass.isJreType() || fetchedDTOClass.isEnum) { - // Primitive type - val isCompatibleJreTypes = - fetchedDTOClass.isJreType() && fetchedDTOClass.kotlin.javaObjectType == updatedDTOClass.kotlin.javaObjectType - val isCompatibleEnumTypes = fetchedDTOClass.isEnum && updatedDTOClass.isEnum - if (!isCompatibleJreTypes && !isCompatibleEnumTypes) { - problemsCollector.add( - FieldProblem( - kind = FieldProblemKind.PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - fetchedDTOClass = parentFetchedDTOClass, - updatedDTOClass = parentUpdatedDTOClass, - fieldName = fieldName, - expectedFieldClass = fetchedDTOClass, - actualFieldClass = updatedDTOClass - ) - ) - } else { - // That's fine - } - } else { - // Complex DTO - if (fetchedDTOClass == updatedDTOClass) { - problemsCollector.add( - FieldProblem( - kind = FieldProblemKind.TYPE_MUST_NOT_BE_REUSED, - fetchedDTOClass = parentFetchedDTOClass, - updatedDTOClass = parentUpdatedDTOClass, - fieldName = fieldName, - expectedFieldClass = null, - actualFieldClass = fetchedDTOClass - ) - ) - } else { - checkClass( - fetchedDTOClass = fetchedDTOClass, - updatedDTOClass = updatedDTOClass, - nonUpdatablePropertyRules = nonUpdatablePropertyRules, - problemsCollector = problemsCollector - ) - } - } -} - -private fun checkField( - fetchedDTOClass: Class<*>, - updatedDTOClass: Class<*>, - fetchedDTOField: Field, - updatedDTOField: Field, - fieldName: String, - nonUpdatablePropertyRules: List>, - problemsCollector: MutableList -) { - val fetchedDTOFieldClass = fetchedDTOField.type - val updatedDTOFieldClass = updatedDTOField.type - when { - fetchedDTOFieldClass.isMap() -> { - if (!updatedDTOFieldClass.isMap()) { - problemsCollector.add( - FieldProblem( - kind = FieldProblemKind.FIELD_IS_NOT_MAP, - fetchedDTOClass = fetchedDTOClass, - updatedDTOClass = updatedDTOClass, - fieldName = fieldName, - expectedFieldClass = fetchedDTOFieldClass, - actualFieldClass = updatedDTOFieldClass - ) - ) - } else { - val (fetchedKeyClass, fetchedValueClass) = fetchedDTOField.extractMapGenericArgumentClasses() - val (updatedKeyClass, updatedValueClass) = updatedDTOField.extractMapGenericArgumentClasses() - - checkClassOrPrimitive( - fetchedDTOClass = fetchedKeyClass, - updatedDTOClass = updatedKeyClass, - parentFetchedDTOClass = fetchedDTOClass, - parentUpdatedDTOClass = updatedDTOClass, - fieldName = "$fieldName (map key)", - nonUpdatablePropertyRules = nonUpdatablePropertyRules, - problemsCollector = problemsCollector - ) - checkClassOrPrimitive( - fetchedDTOClass = fetchedValueClass, - updatedDTOClass = updatedValueClass, - parentFetchedDTOClass = fetchedDTOClass, - parentUpdatedDTOClass = updatedDTOClass, - fieldName = "$fieldName (map value)", - nonUpdatablePropertyRules = nonUpdatablePropertyRules, - problemsCollector = problemsCollector - ) - } - } - fetchedDTOFieldClass.isList() -> { - if (!updatedDTOFieldClass.isList()) { - problemsCollector.add( - FieldProblem( - kind = FieldProblemKind.FIELD_IS_NOT_LIST, - fetchedDTOClass = fetchedDTOClass, - updatedDTOClass = updatedDTOClass, - fieldName = fieldName, - expectedFieldClass = fetchedDTOFieldClass, - actualFieldClass = updatedDTOFieldClass - ) - ) - return - } else { - val fetchedValueClass = fetchedDTOField.extractListGenericArgumentClass() - val updatedValueClass = updatedDTOField.extractListGenericArgumentClass() - checkClassOrPrimitive( - fetchedDTOClass = fetchedValueClass, - updatedDTOClass = updatedValueClass, - parentFetchedDTOClass = fetchedDTOClass, - parentUpdatedDTOClass = updatedDTOClass, - fieldName = "$fieldName (list value)", - nonUpdatablePropertyRules = nonUpdatablePropertyRules, - problemsCollector = problemsCollector - ) - } - } - else -> { - val updatedDTOFieldClassCorrected = if (updatedDTOFieldClass == NullableUpdatedValue::class.java) { - (updatedDTOField.genericType as ParameterizedType).actualTypeArguments[0] as Class<*> - } else { - updatedDTOFieldClass - } - - checkClassOrPrimitive( - fetchedDTOClass = fetchedDTOFieldClass, - updatedDTOClass = updatedDTOFieldClassCorrected, - parentFetchedDTOClass = fetchedDTOClass, - parentUpdatedDTOClass = updatedDTOClass, - fieldName = fieldName, - nonUpdatablePropertyRules = nonUpdatablePropertyRules, - problemsCollector = problemsCollector - ) - } - } -} - -private fun Field.extractListGenericArgumentClass(): Class<*> { - val genericType = genericType - return if (genericType is ParameterizedType) { - // val foo: List - genericType.actualTypeArguments[0] as Class<*> - } else { - val genericSuperclass = type.genericSuperclass - if (genericSuperclass is ParameterizedType) { - // val foo: T; T : List - genericSuperclass.actualTypeArguments[0] as Class<*> - } else { - throw NotImplementedError("Implement if necessary") - } - } -} - -private fun Field.extractMapGenericArgumentClasses(): Pair, Class<*>> { - val genericType = genericType - return if (genericType is ParameterizedType) { - // val foo: Map - Pair( - first = toClass(genericType.actualTypeArguments[0]), - second = toClass(genericType.actualTypeArguments[1]) - ) - } else { - val genericSuperclass = type.genericSuperclass - if (genericSuperclass is ParameterizedType) { - // val foo: T; T : Map - Pair( - first = toClass(genericSuperclass.actualTypeArguments[0]), - second = toClass(genericSuperclass.actualTypeArguments[1]) - ) - } else { - throw NotImplementedError("Implement if necessary") - } - } -} - -private tailrec fun toClass(type: Type?): Class<*> { - return when (type) { - is Class<*> -> type - is ParameterizedType -> toClass(type.actualTypeArguments[0]) - else -> throw NotImplementedError("Type $type is not supported") - } -} - -private fun Class<*>.isMap() = Map::class.java.isAssignableFrom(this) - -private fun Class<*>.isList() = List::class.java.isAssignableFrom(this) - -private fun Class<*>.isJreType() = packageName.startsWith("java.") - -internal enum class FieldProblemKind { - FIELD_NOT_FOUND, - FIELD_IS_NOT_MAP, - FIELD_IS_NOT_LIST, - PRIMITIVE_FIELDS_INCOMPATIBLE_TYPE, - TYPE_MUST_NOT_BE_REUSED -} - -internal data class FieldProblem( - val kind: FieldProblemKind, - val fetchedDTOClass: Class<*>, - val updatedDTOClass: Class<*>, - val fieldName: String, - val expectedFieldClass: Class<*>?, - val actualFieldClass: Class<*>? -) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt deleted file mode 100644 index bd686d068..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/OrderUtils.kt +++ /dev/null @@ -1,345 +0,0 @@ -package com.ecwid.apiclient.v3.util - -import com.ecwid.apiclient.v3.dto.common.OrderedStringToStringMap -import com.ecwid.apiclient.v3.dto.order.enums.* -import com.ecwid.apiclient.v3.dto.order.request.UpdatedOrder - -fun generateTestOrder(): UpdatedOrder { - val externalOrderId = "Order #" + randomAlphanumeric(8) - val externalFulfillment = randomBoolean() - val refererId = "Referer " + randomAlphanumeric(8) - val totalPrice = randomPrice() - val trackingNumber = randomAlphanumeric(16) - return UpdatedOrder( - email = randomEmail(), - ipAddress = randomIp(), - hidden = false, // true allowed only for paymentStatus INCOMPLETE - createDate = randomDate(), - - refererUrl = randomUrl(), - globalReferer = randomUrl(), - affiliateId = randomAlphanumeric(16), - additionalInfo = OrderedStringToStringMap( - linkedMapOf( - "additionalParam1" to randomAlphanumeric(16), - "additionalParam2" to randomAlphanumeric(16) - ) - ), - - orderComments = "Order comment " + randomAlphanumeric(16), - privateAdminNotes = "Private admin note " + randomAlphanumeric(16), - - fulfillmentStatus = randomEnumValue(), - trackingNumber = trackingNumber, - trackingUrl = "https://track.aftership.com/$trackingNumber", - - paymentStatus = randomEnumValue(OrderPaymentStatus.INCOMPLETE), - paymentMethod = "Payment method " + randomAlphanumeric(8), - paymentModule = "Payment module " + randomAlphanumeric(8), - paymentParams = OrderedStringToStringMap( - linkedMapOf( - "paymentParam1" to randomAlphanumeric(16), - "paymentParam2" to randomAlphanumeric(16) - ) - ), - paymentMessage = randomAlphanumeric(16), - creditCardStatus = UpdatedOrder.CreditCardStatus( - avsMessage = randomAlphanumeric(8), - cvvMessage = randomAlphanumeric(8) - ), - externalTransactionId = randomAlphanumeric(16), - - customerGroup = "Group " + randomAlphanumeric(8), - acceptMarketing = randomBoolean(), - - total = totalPrice, - totalBeforeGiftCardRedemption = totalPrice, - subtotal = randomPrice(), - giftCardRedemption = 0.0, - giftCardDoubleSpending = false, - - tax = randomPrice(), - customerTaxExempt = false, // TODO We cannot set this field to true, we should need update corresponding customer entity field first - customerTaxId = randomAlphanumeric(16), - customerTaxIdValid = randomBoolean(), - reversedTaxApplied = randomBoolean(), - - couponDiscount = randomPrice(), - volumeDiscount = randomPrice(), - membershipBasedDiscount = randomPrice(), - totalAndMembershipBasedDiscount = randomPrice(), - discount = randomPrice(), - discountInfo = listOf( - generateTestOnTotalDiscountInfo(), - generateTestOnMembershipDiscountInfo(), - generateTestOnTotalAndMembershipDiscountInfo(), - generateTestCustomDiscountInfo(), - generateTestItemDiscountInfo(), - generateTestShippingDiscountInfo(), - generateTestSubtotalDiscountInfo() - ), - - // TODO Pass real discount coupon code when API client will support this -// discountCoupon = UpdatedOrder.DiscountCouponInfo( -// name = "Discount coupon " + randomAlphanumeric(8), -// code = randomAlphanumeric(16), -// discountType = randomEnumValue(), -// status = randomEnumValue(), -// discount = randomPrice(), -// launchDate = randomDate(), -// expirationDate = randomDate(), -// totalLimit = randomPrice(), -// usesLimit = randomEnumValue(), -// repeatCustomerOnly = randomBoolean() -// ), - customDiscount = listOf(), - - items = listOf( - generateTestOrderItem(), - generateTestOrderItem() - ), - - billingPerson = generatePersonInfo(), - shippingPerson = generatePersonInfo(), - - shippingOption = UpdatedOrder.ShippingOption( - shippingMethodId = "MethodId " + randomAlphanumeric(8), - shippingCarrierName = "Carrier " + randomAlphanumeric(8), - shippingMethodName = "Method " + randomAlphanumeric(8), - shippingRate = randomPrice(), - estimatedTransitTime = "Estimates " + randomAlphanumeric(8), - isPickup = true, - pickupInstruction = null, // can not be set now without matching owner.newShippingSettings entry ECWID-153335 - fulfillmentType = FulfillmentType.PICKUP - ), - taxesOnShipping = listOf(), - handlingFee = UpdatedOrder.HandlingFee( - name = "Name " + randomAlphanumeric(8), - value = randomPrice(), - description = "Description " + randomAlphanumeric(64), - taxes = listOf() - ), - pricesIncludeTax = false, - disableAllCustomerNotifications = randomBoolean(), - - customSurcharges = listOf(), - - externalFulfillment = externalFulfillment, - refererId = refererId, - externalOrderId = externalOrderId, - - externalOrderData = UpdatedOrder.ExternalOrderData( - externalFulfillment = externalFulfillment, - externalOrderId = externalOrderId, - refererId = refererId, - platformSpecificFields = HashMap( - mapOf( - "field1" to randomAlphanumeric(8), - "field2" to randomAlphanumeric(8), - ) - ), - refererChannel = "Referer channel " + randomAlphanumeric(8), - ), - lang = "en", - orderExtraFields = listOf( - UpdatedOrder.OrderExtraFields( - customerInputType = "TEXT", - title = "text 1", - id = "first_id", - value = "text value one", - orderDetailsDisplaySection = "customer_info", - orderBy = "1" - ), - UpdatedOrder.OrderExtraFields( - customerInputType = "TEXT", - title = "text 2", - id = "second_id", - value = "text value two", - orderDetailsDisplaySection = "customer_info", - orderBy = "2" - ) - ) - ) -} - -private fun generateTestOnTotalDiscountInfo() = UpdatedOrder.DiscountInfo( - value = randomPrice(), - type = randomEnumValue(exclude = arrayOf(DiscountType.FIXED_PRICE)), - base = DiscountBase.ON_TOTAL, - orderTotal = randomPrice(), - description = "On total discount " + randomAlphanumeric(8) -) - -private fun generateTestOnMembershipDiscountInfo() = UpdatedOrder.DiscountInfo( - value = randomPrice(), - type = randomEnumValue(exclude = arrayOf(DiscountType.FIXED_PRICE)), - base = DiscountBase.ON_MEMBERSHIP, - description = "On membership discount " + randomAlphanumeric(8) -) - -private fun generateTestOnTotalAndMembershipDiscountInfo() = UpdatedOrder.DiscountInfo( - value = randomPrice(), - type = randomEnumValue(exclude = arrayOf(DiscountType.FIXED_PRICE)), - base = DiscountBase.ON_TOTAL_AND_MEMBERSHIP, - orderTotal = randomPrice(), - description = "On total and membership discount " + randomAlphanumeric(8) -) - -private fun generateTestCustomDiscountInfo() = UpdatedOrder.DiscountInfo( - value = randomPrice(), - type = randomEnumValue(exclude = arrayOf(DiscountType.FIXED_PRICE)), - base = DiscountBase.CUSTOM, - orderTotal = randomPrice(), - description = "Custom discount " + randomAlphanumeric(8) -) - -private fun generateTestItemDiscountInfo() = UpdatedOrder.DiscountInfo( - value = randomPrice(), - type = randomEnumValue(exclude = arrayOf(DiscountType.FIXED_PRICE)), - base = DiscountBase.ITEM, - orderTotal = randomPrice(), - description = "On item discount " + randomAlphanumeric(8) -) - -private fun generateTestShippingDiscountInfo() = UpdatedOrder.DiscountInfo( - value = randomPrice(), - type = randomEnumValue(exclude = arrayOf(DiscountType.FIXED_PRICE)), - base = DiscountBase.SHIPPING, - orderTotal = randomPrice(), - description = "On shipping discount " + randomAlphanumeric(8) -) - -private fun generateTestSubtotalDiscountInfo() = UpdatedOrder.DiscountInfo( - value = randomPrice(), - type = randomEnumValue(exclude = arrayOf(DiscountType.FIXED_PRICE)), - base = DiscountBase.SUBTOTAL, - orderTotal = randomPrice(), - description = "On subtotal discount " + randomAlphanumeric(8) -) - -private fun generateTestOrderItem() = UpdatedOrder.OrderItem( - // var id: Int? = null, // TODO readonly - // productId = com.ecwid.api.v3.randomId(), // TODO need to pass existing product id - categoryId = randomId(), - - price = randomPrice(), - productPrice = randomPrice(), - shipping = randomPrice(), - tax = randomPrice(), - fixedShippingRate = randomPrice(), - couponAmount = randomPrice(), - - sku = randomAlphanumeric(16), - name = "Order item " + randomAlphanumeric(8), - shortDescription = "Order item description " + randomAlphanumeric(32), - quantity = randomByte(), - quantityInStock = randomByte(), - weight = randomWeight(), // TODO readonly? - - isShippingRequired = true, // true for weight field - trackQuantity = randomBoolean(), - fixedShippingRateOnly = randomBoolean(), - digital = randomBoolean(), - couponApplied = randomBoolean(), - giftCard = false, - isCustomerSetPrice = randomBoolean(), - taxable = randomBoolean(), - - selectedOptions = listOf( - generateChoiceSelectedOption(), - generateChoicesSelectedOption(), - generateTextSelectedOption(), - generateDateSelectedOption(), - generateFilesSelectedOption() - ), - combinationId = randomId(), - taxes = listOf( - generateTestOrderItemTax(), - generateTestOrderItemTax() - ), - dimensions = UpdatedOrder.ProductDimensions( - length = randomDimension(), - width = randomDimension(), - height = randomDimension() - ), - discounts = listOf( - generateOrderItemDiscounts(), - generateOrderItemDiscounts() - ) -) - -private fun generateOrderItemDiscounts(): UpdatedOrder.OrderItemDiscounts { - return UpdatedOrder.OrderItemDiscounts( - discountInfo = generateTestCustomDiscountInfo(), - total = randomPrice() - ) -} - -private fun generateChoiceSelectedOption(): UpdatedOrder.OrderItemSelectedOption { - return UpdatedOrder.OrderItemSelectedOption.createForChoiceOption( - name = "Choice Option " + randomAlphanumeric(8), - selection = "Selection #1, " + randomAlphanumeric(8) - ) -} - -private fun generateChoicesSelectedOption(): UpdatedOrder.OrderItemSelectedOption { - val value1 = "Selection #1, " + randomAlphanumeric(8) - val value3 = "Selection #3, " + randomAlphanumeric(8) - return UpdatedOrder.OrderItemSelectedOption.createForChoicesOption( - name = "Choices Option " + randomAlphanumeric(8), - selections = listOf( - UpdatedOrder.OrderItemSelectionInfo( - selectionTitle = value1, - selectionModifier = randomModifier(), - selectionModifierType = randomEnumValue() - ), - UpdatedOrder.OrderItemSelectionInfo( - selectionTitle = value3, - selectionModifier = randomModifier(), - selectionModifierType = randomEnumValue() - ) - ) - ) -} - -private fun generateTextSelectedOption(): UpdatedOrder.OrderItemSelectedOption { - return UpdatedOrder.OrderItemSelectedOption.createForTextOption( - name = "Text Option " + randomAlphanumeric(8), - value = randomAlphanumeric(8) - ) -} - -private fun generateDateSelectedOption(): UpdatedOrder.OrderItemSelectedOption { - return UpdatedOrder.OrderItemSelectedOption.createForDateOption( - name = "Date Option " + randomAlphanumeric(8), - date = randomDate() - ) -} - -private fun generateFilesSelectedOption(): UpdatedOrder.OrderItemSelectedOption { - return UpdatedOrder.OrderItemSelectedOption.createForFilesOption(name = "Files Option " + randomAlphanumeric(8)) -} - -private fun generateTestOrderItemTax(): UpdatedOrder.OrderItemTax { - return UpdatedOrder.OrderItemTax( - name = "Tax " + randomAlphanumeric(8), - value = randomPrice(), - total = randomPrice(), - taxOnDiscountedSubtotal = randomPrice(), - taxOnShipping = randomPrice(), - includeInPrice = randomBoolean() - ) -} - -private fun generatePersonInfo(): UpdatedOrder.PersonInfo { - return UpdatedOrder.PersonInfo( - name = "Name " + randomAlphanumeric(8), - companyName = "Company " + randomAlphanumeric(8), - street = "Line 1 " + randomAlphanumeric(8) + "\nLine 2 " + randomAlphanumeric(8), - city = "City " + randomAlphanumeric(8), - countryCode = "US", - postalCode = randomAlphanumeric(5), - stateOrProvinceCode = "CA", - phone = randomAlphanumeric(10) - ) -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/PropertiesLoadError.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/PropertiesLoadError.kt deleted file mode 100644 index 11b0c93a8..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/PropertiesLoadError.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.ecwid.apiclient.v3.util - -class PropertiesLoadError(override val message: String) : Error(message) diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/PropertiesLoader.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/PropertiesLoader.kt deleted file mode 100644 index d50bac0cb..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/PropertiesLoader.kt +++ /dev/null @@ -1,88 +0,0 @@ -package com.ecwid.apiclient.v3.util - -import java.util.* - -private const val DEFAULT_API_HOST = "app.ecwid.com" -private const val DEFAULT_API_PORT = 443 - -object PropertiesLoader { - - private sealed class LoadResult { - data class Success(val properties: TestProperties) : LoadResult() - data class Failed(val message: String) : LoadResult() - } - - private val lazyLoadProperties = lazy { - val envProperties = fromEnv() - if (envProperties != null) { - LoadResult.Success(envProperties) - } else { - fromResource("/test.properties") - } - } - - fun load(): TestProperties { - return when (val loadResult = lazyLoadProperties.value) { - is LoadResult.Success -> loadResult.properties - is LoadResult.Failed -> throw PropertiesLoadError(loadResult.message) - } - } - - private fun fromEnv(): TestProperties? { - val apiHost = System.getenv("API_HOST") ?: DEFAULT_API_HOST - val storeId = System.getenv("STORE_ID")?.toIntOrNull() - val apiToken = System.getenv("API_TOKEN") - - return if (storeId != null && apiToken != null) { - TestProperties( - apiHost = apiHost, - apiPort = DEFAULT_API_PORT, - storeId = storeId, - apiToken = apiToken - ) - } else { - null - } - } - - private fun fromResource(resourceName: String): LoadResult { - val resource = PropertiesLoader::class.java.getResourceAsStream(resourceName) - ?: return LoadResult.Failed("File $resourceName not found in test/resources dir. Please copy test/resources/test.properties.sample and configure it") - - val p = Properties() - p.load(resource) - - val apiHostStr = p.getProperty("apiHost") - val apiHost = if (apiHostStr.isNullOrEmpty()) { - DEFAULT_API_HOST - } else { - apiHostStr - } - - val apiPort = p.getProperty("apiPort")?.toIntOrNull() ?: DEFAULT_API_PORT - - val storeIdStr = p.getProperty("storeId") - if (storeIdStr.isNullOrEmpty()) { - return LoadResult.Failed("Parameter storeId is required") - } - - val apiToken = p.getProperty("apiToken") - if (apiToken.isNullOrEmpty()) { - return LoadResult.Failed("Parameter apiToken is required") - } - - val storeId = storeIdStr.toIntOrNull() - if (storeId == null || storeId <= 0) { - return LoadResult.Failed("Parameter storeId must be a valid Store ID") - } - - val testProperties = TestProperties( - apiHost = apiHost, - apiPort = apiPort, - storeId = storeId, - apiToken = apiToken - ) - - return LoadResult.Success(testProperties) - } -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/RandomUtils.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/RandomUtils.kt deleted file mode 100644 index c5ea6fd11..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/RandomUtils.kt +++ /dev/null @@ -1,90 +0,0 @@ -package com.ecwid.apiclient.v3.util - -import java.math.RoundingMode -import java.time.Instant -import java.time.temporal.ChronoUnit -import java.util.* -import kotlin.random.Random - -internal fun randomEmail() = "test+${Random.nextInt()}@example.com" - -internal fun randomUrl() = "example${Random.nextInt()}.com" - -internal fun randomIp() = "${randomByte()}.${randomByte()}.${randomByte()}.${randomByte()}" - -internal fun randomBoolean() = Random.nextBoolean() - -internal fun randomByte() = Random.nextBytes(1)[0] + 128 - -internal fun randomId() = randomInt(10000, 1000000) - -internal fun randomIndex(collection: Collection) = randomInt(0, collection.size - 1) - -internal fun randomPrice() = Random - .nextDouble(20.0, 1000.0) - .roundDouble() - -internal fun randomWeight() = Random - .nextDouble(1.0, 100.0) - .roundDouble() - -internal fun randomDimension(): Double = Random - .nextDouble(1.0, 100.0) - .roundDouble() - -internal fun randomVolume() = Random - .nextDouble(1.0, 100.0) - .roundDouble() - -internal fun randomModifier() = Random - .nextDouble(-20.0, 20.0) - .roundDouble() - -internal fun randomDate(): Date { - val instant = Instant.now() - .minusMillis(Random.nextInt().toLong()) - .truncatedTo(ChronoUnit.SECONDS) - return Date.from(instant) -} - -internal fun randomDateFrom(date: Date): Date { - val instant = date.toInstant() - .plusSeconds(randomInt(1, 100000).toLong()) - .truncatedTo(ChronoUnit.SECONDS) - return Date.from(instant) -} - -internal fun randomAlphanumeric(size: Int): String { - val characters = ('a'..'z') + ('A'..'Z') + ('0'..'9') - return (1..size) - .map { Random.nextInt(0, characters.size) } - .map(characters::get) - .joinToString("") -} - -internal inline fun > randomEnumValue(vararg exclude: E): E { - return E::class.java.enumConstants - .toSortedSet() - .minus(exclude) - .shuffled() - .first() -} - -internal fun randomOf(vararg options: V): V { - return options - .toList() - .shuffled() - .first() -} - -internal fun randomFileName(prefix: String, extension: String) = "$prefix-${Random.nextInt()}.$extension" - -internal fun randomInt(min: Int, max: Int) = Random.nextInt(min, max) - -internal fun randomDouble(min: Double, max: Double) = Random.nextDouble(min, max) - -private fun Double.roundDouble(): Double { - return toBigDecimal() - .setScale(2, RoundingMode.UP) - .toDouble() -} diff --git a/src/test/kotlin/com/ecwid/apiclient/v3/util/TestProperties.kt b/src/test/kotlin/com/ecwid/apiclient/v3/util/TestProperties.kt deleted file mode 100644 index 131ab1dea..000000000 --- a/src/test/kotlin/com/ecwid/apiclient/v3/util/TestProperties.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.ecwid.apiclient.v3.util - -data class TestProperties( - val apiHost: String, - val apiPort: Int, - val storeId: Int, - val apiToken: String -) From 5d9526a41097c05e0e1e48d7fefb61045edb89bf Mon Sep 17 00:00:00 2001 From: "maksim.safronov" Date: Fri, 4 Apr 2025 12:48:04 +0400 Subject: [PATCH 3/4] v3 version of api changed to v1 for vuega compatibility - removed tests. Do not merge this commits --- src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt index bdf4f76c4..0dd61218e 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt @@ -47,6 +47,7 @@ class ApiClientHelper private constructor( ) { private val log = Logger.getLogger(this::class.qualifiedName) + private val apiVersion = "v3" constructor( apiServerDomain: ApiServerDomain, @@ -423,8 +424,8 @@ class ApiClientHelper private constructor( } private fun buildBaseEndpointPath(credentials: ApiCredentials) = when (credentials) { - is ApiStoreCredentials -> "/api/v1/${credentials.storeId}" - is ApiAppCredentials -> "/api/v1" + is ApiStoreCredentials -> "/api/$apiVersion/${credentials.storeId}" + is ApiAppCredentials -> "/api/$apiVersion" } } From 692ba6f0515df096219ae45e1d746e044e8ebd11 Mon Sep 17 00:00:00 2001 From: "maksim.safronov" Date: Fri, 4 Apr 2025 13:39:54 +0400 Subject: [PATCH 4/4] v3 version of api changed to v1 for vuega compatibility - removed tests. Do not merge this commits --- src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt index 0dd61218e..939ddc9c8 100644 --- a/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt +++ b/src/main/kotlin/com/ecwid/apiclient/v3/ApiClientHelper.kt @@ -47,7 +47,7 @@ class ApiClientHelper private constructor( ) { private val log = Logger.getLogger(this::class.qualifiedName) - private val apiVersion = "v3" + private var apiVersion = "v3" constructor( apiServerDomain: ApiServerDomain,