Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Changes:
- Fix: fixed issue with shoe item recommended size

### 2.12.16
- Fix: view text issue when orientation change after language change

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class UserBodyProfileJsonParser : VirtusizeJsonParser<UserBodyProfile> {
val gender = JsonUtils.optString(json, FIELD_GENDER)
val age = json.optInt(FIELD_AGE)
val height = json.optInt(FIELD_HEIGHT)
val weight = json.optString(FIELD_WEIGHT)
val weight = JsonUtils.optString(json, FIELD_WEIGHT)
var bodyData = setOf<Measurement>()
var footwearData = mapOf<String, Any>()
var braSize: Map<String, Any>? = null
Expand All @@ -23,9 +23,6 @@ class UserBodyProfileJsonParser : VirtusizeJsonParser<UserBodyProfile> {
val braSizeMap = JsonUtils.jsonObjectToMap(braSizeJsonObject)
braSize = if (braSizeMap.isEmpty()) null else braSizeMap
}
if (age == 0 || height == 0 || weight.isBlank() || bodyData.isEmpty()) {

Choose a reason for hiding this comment

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

shouldn't this be a safe guard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@devAbhimanyu I do not see this code on iOS SDK + This parameters are optional (for SHOE those are missing).

return null
}
return UserBodyProfile(gender, age, height, weight, bodyData, footwearData, braSize)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class UserBodyProfileJsonParserTest {
val actualUserBodyProfile =
UserBodyProfileJsonParser().parse(TestFixtures.NULL_USER_BODY_PROFILE)

assertThat(actualUserBodyProfile).isNull()
assertThat(actualUserBodyProfile).isEqualTo(TestFixtures.emptyUserBodyProfile)
}

@Test
fun test_parseNotFoundResponse() {
val actualUserBodyProfile = UserBodyProfileJsonParser().parse(TestFixtures.EMPTY_JSON_DATA)

assertThat(actualUserBodyProfile).isNull()
assertThat(actualUserBodyProfile).isEqualTo(TestFixtures.emptyUserBodyProfile)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ internal object TestFixtures {
val NULL_USER_BODY_PROFILE =
JSONObject(
"""
{
{
"gender": "",
"age": null,
"height": null,
Expand All @@ -118,6 +118,17 @@ internal object TestFixtures {
""".trimIndent(),
)

val emptyUserBodyProfile =
UserBodyProfile(
"",
0,
0,
"",
emptySet(),
emptyMap(),
null,
)

val userBodyProfile =
UserBodyProfile(
"female",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal class VirtusizeApiTaskTest {
}

@Test
fun testParseInputStreamStringToUserBodyProfile_return_null() {
fun testParseInputStreamStringToUserBodyProfile_return_emptyProfile() {
virtusizeApiTask.setJsonParser(UserBodyProfileJsonParser())

val returnValue =
Expand All @@ -103,11 +103,11 @@ internal class VirtusizeApiTaskTest {
"\"concernAreas\":null,\"bodyData\":null}",
)

assertThat(returnValue).isNull()
assertThat(returnValue).isEqualTo(TestFixtures.emptyUserBodyProfile)
}

@Test
fun `test user-body-measurements endpoint with UserBodyProfileJsonParser returning null`() {
fun `test user-body-measurements endpoint with UserBodyProfileJsonParser returning emptyProfile`() {
virtusizeApiTask.setJsonParser(UserBodyProfileJsonParser())

val returnValue =
Expand All @@ -127,7 +127,7 @@ internal class VirtusizeApiTaskTest {
""".trimIndent(),
)

assertThat(returnValue).isNull()
assertThat(returnValue).isEqualTo(TestFixtures.emptyUserBodyProfile)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,24 +532,6 @@ class VirtusizeAPIServiceImplTest {
)
}

@Test
fun testGetUserBodyProfileResponse_userHasEmptyBodyProfile_shouldExpectNull() =
runBlocking {
virtusizeAPIService.setHTTPURLConnection(
MockHttpsURLConnection(
mockURL,
MockedResponse(
200,
TestFixtures.NULL_USER_BODY_PROFILE.toString().byteInputStream(),
),
),
)

val actualUserBodyProfile = virtusizeAPIService.getUserBodyProfile().successData

assertThat(actualUserBodyProfile).isNull()
}

@Test
fun testGetUserBodyProfileResponse_wardrobeDoesNotExist_shouldReturn404Error() =
runBlocking {
Expand All @@ -565,7 +547,6 @@ class VirtusizeAPIServiceImplTest {

val actualError = virtusizeAPIService.getUserBodyProfile().failureData
assertThat(actualError?.code).isEqualTo(HttpURLConnection.HTTP_NOT_FOUND)
assertThat(actualError?.message).contains("{\"detail\":\"No wardrobe found\"}")
assertThat(actualError?.type).isEqualTo(VirtusizeErrorType.APIError)
}

Expand Down