Skip to content

Commit

Permalink
Merge pull request #72 from KjellBerlin/product-placeholder
Browse files Browse the repository at this point in the history
Modify product for productPlaceHolder
  • Loading branch information
KjellBerlin authored Sep 23, 2024
2 parents ada964e + 075b578 commit 611dd1c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/main/kotlin/com/carbonara/core/product/ProductDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ data class ProductDao(
val productPictureUrl: String,
var isActive: Boolean?,
val shortProductDescription: String,
val longProductDescription: String
val longProductDescription: String,
val isProductPlaceHolder: Boolean?
) {

fun toProductDao(): ProductDto {
Expand All @@ -25,7 +26,8 @@ data class ProductDao(
productPictureUrl = productPictureUrl,
isActive = isActive ?: false,
shortProductDescription = shortProductDescription,
longProductDescription = longProductDescription
longProductDescription = longProductDescription,
isProductPlaceHolder = isProductPlaceHolder ?: false
)
}
}
9 changes: 6 additions & 3 deletions src/main/kotlin/com/carbonara/core/product/ProductDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ data class ProductDto (
val productPictureUrl: String,

@GraphQLDescription("This product is active right now and can be purchased")
var isActive: Boolean,
val isActive: Boolean,

@GraphQLDescription("A short description for the checkout page")
var shortProductDescription: String,
val shortProductDescription: String,

@GraphQLDescription("A long description for the product page")
var longProductDescription: String
val longProductDescription: String,

@GraphQLDescription("Is the product an actual product or a placeholder")
val isProductPlaceHolder: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ProductService(
isActive = false,
shortProductDescription = createProductInput.shortProductDescription,
longProductDescription = createProductInput.longProductDescription,
isProductPlaceHolder = false
)
).awaitSingleOrNull()?.toProductDao()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ fun createProduct(
productPictureUrl = "https://example.com",
isActive = true,
shortProductDescription = "Short description",
longProductDescription = "Long description"
longProductDescription = "Long description",
isProductPlaceHolder = false
)
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/kotlin/com/carbonara/core/order/OrderServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ class OrderServiceTest {
productPictureUrl = "https://example.com",
isActive = true,
shortProductDescription = "Short description",
longProductDescription = "Long description"
longProductDescription = "Long description",
isProductPlaceHolder = false
)
val CREATE_ORDER_INPUT = CreateOrderInput(
auth0UserId = AUTH0_USER_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class ProductServiceTest {
productPictureUrl = "https://example.com",
isActive = false,
shortProductDescription = "Short description",
longProductDescription = "Long description"
longProductDescription = "Long description",
isProductPlaceHolder = false
)
val TEST_PRODUCT_1_ACTIVE = TEST_PRODUCT_1_NOT_ACTIVE.copy(isActive = true)
val TEST_PRODUCT_2_NOT_ACTIVE = ProductDao(
Expand All @@ -132,7 +133,8 @@ class ProductServiceTest {
productPictureUrl = "https://example.com",
isActive = false,
shortProductDescription = "Short description",
longProductDescription = "Long description"
longProductDescription = "Long description",
isProductPlaceHolder = false
)
val TEST_PRODUCT_2_ACTIVE = TEST_PRODUCT_2_NOT_ACTIVE.copy(isActive = true)
}
Expand Down

0 comments on commit 611dd1c

Please sign in to comment.