Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(INVT-CPC-979): Add sale price for clients in product list #533

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public class ProductRequestDTO {
private String productDescription;
private Double productPrice;
private Integer productQuantity;
private Double productSalePrice;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public class ProductResponseDTO {
private String productDescription;
private Double productPrice;
private Integer productQuantity;
private Double productSalePrice;

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ <h2>Inventory</h2>
<a class="btn btn-danger" href="javascript:void(0)" ng-click="deleteInventory(inventory); $event.stopPropagation()">Delete</a>
</td>


</td>
</tr>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h2>Inventory Products</h2>
<td>Quantity</td>
<td>Price</td>
<td>Description</td>
<td>Sale Price</td>
</tr>
<tr>
<td>
Expand All @@ -34,6 +35,11 @@ <h2>Inventory Products</h2>
<input type="number" step="0.01" min="0" ng-model="productPrice" ng-keyup="$event.keyCode == 13 && searchProduct(productName, productQuantity, productPrice)">
</span>
</td>
<td>
<span>
<input type="number" step="0.01" min="0" ng-model="productSalePrice" ng-keyup="$event.keyCode == 13">
</span>
</td>
<td></td>
<td></td>
<td>
Expand All @@ -50,6 +56,7 @@ <h2>Inventory Products</h2>
<td><span>{{product.productQuantity}}</span></td>
<td><span>{{product.productPrice}}</span></td>
<td><span>{{product.productDescription}}</span></td>
<td><span>{{product.productSalePrice}}</span></td>
<td><a ui-sref="updateProductInventory({inventoryId: $ctrl.inventoryProductList[0].inventoryId, productId: product.productId})">
<button class="add-bundle-button btn btn-success">Edit</button>
</a></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
productName: self.product.productName,
productDescription: self.product.productDescription,
productPrice: self.product.productPrice,
productQuantity: self.product.productQuantity
productQuantity: self.product.productQuantity,
productSalePrice: self.product.productSalePrice
}
var inventoryId = InventoryService.getInventoryId();
console.log("InventoryId: " + inventoryId);
$http.post('/api/gateway/inventory/' + inventoryId + '/products', data
)
.then(function (response) {

Check notice on line 20 in api-gateway/src/main/resources/static/scripts/product-form/product-form.controller.js

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Duplicated code fragment

Duplicated code
console.log(response);
$state.go('productList', {inventoryId: inventoryId});
}, function (response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ <h2 class="titleProduct form" id="title">New Product</h2>
<input class="form-control" id="quantity" ng-model="$ctrl.product.productQuantity" name="productQuantity" type="number" required title="Please enter quantities." />
</div>
</div>
<div class="form-group p-3">
<div class="bundle marg col-sm-12">
<label class="control-label" for="salePrice">Sale Price</label>
<input class="form-control" id="salePrice" ng-model="$ctrl.product.productSalePrice" name="productSalePrice" type="number" required title="Please enter the sale price." />
</div>
</div>
<div class="form-group formColor">
<div class="owner marg col-sm-6">
<button id="newBtn" class="btn btn-default" type="submit">Submit</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ angular.module('productUpdateForm')
productName: self.product.productName,
productDescription: self.product.productDescription,
productPrice: self.product.productPrice,
productQuantity: self.product.productQuantity
productQuantity: self.product.productQuantity,
productSalePrice: self.product.productSalePrice
}

$http.put('/api/gateway/inventory/' + inventoryId + '/products/' + productId, data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ <h2 class="titleProduct form" id="title">Update Product</h2>
<input class="form-control" id="quantity" ng-model="$ctrl.product.productQuantity" name="productQuantity" type="number" required title="Please enter quantities." />
</div>
</div>
<div class="form-group p-3">
<div class="bundle marg col-sm-12">
<label class="control-label" for="salePrice">Sale Price</label>
<input class="form-control" id="salePrice" ng-model="$ctrl.product.productSalePrice" name="productSalePrice" type="number" required title="Please enter the sale price." />
</div>
</div>
<div class="form-group formColor">
<div class="owner marg col-sm-6">
<button id="newBtn" class="btn btn-default" type="submit">Submit</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ void getProductsInInventoryByInventoryIdAndProductsField() throws JsonProcessing
"name",
"desc",
10.00,
2
2,
15.99

);

mockWebServer.enqueue(new MockResponse()
Expand All @@ -79,7 +81,8 @@ void addProductsToInventory() throws JsonProcessingException {
"name",
"desc",
10.00,
2
2,
15.99
);

mockWebServer.enqueue(new MockResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2813,10 +2813,11 @@ void deleteAllProductInventory_shouldSucceed() {
}
//inventory tests


@Test
void testUpdateProductInInventory() {
// Create a sample ProductRequestDTO
ProductRequestDTO requestDTO = new ProductRequestDTO("Sample Product", "Sample Description", 10.0, 100);
ProductRequestDTO requestDTO = new ProductRequestDTO("Sample Product", "Sample Description", 10.0, 100, 15.99);

// Define the expected response
ProductResponseDTO expectedResponse = ProductResponseDTO.builder()
Expand Down Expand Up @@ -2874,7 +2875,7 @@ public void deleteProductById_insideInventory(){
@DisplayName("Given valid inventoryId and valid productRequest Post and return productResponse")
void testAddProductToInventory_ShouldSucceed() {
// Create a sample ProductRequestDTO
ProductRequestDTO requestDTO = new ProductRequestDTO("Sample Product", "Sample Description", 10.0, 100);
ProductRequestDTO requestDTO = new ProductRequestDTO("Sample Product", "Sample Description", 10.0, 100, 15.99);

// Define the expected response
ProductResponseDTO expectedResponse = ProductResponseDTO.builder()
Expand All @@ -2885,6 +2886,7 @@ void testAddProductToInventory_ShouldSucceed() {
.productDescription(requestDTO.getProductDescription())
.productPrice(requestDTO.getProductPrice())
.productQuantity(requestDTO.getProductQuantity())
.productSalePrice(requestDTO.getProductSalePrice())
.build();

// Mock the behavior of the inventoryServiceClient
Expand All @@ -2906,6 +2908,7 @@ void testAddProductToInventory_ShouldSucceed() {
assertEquals(requestDTO.getProductDescription(), dto.getProductDescription());
assertEquals(requestDTO.getProductPrice(), dto.getProductPrice());
assertEquals(requestDTO.getProductQuantity(), dto.getProductQuantity());
assertEquals(requestDTO.getProductSalePrice(), dto.getProductSalePrice());
});

// Verify that the inventoryServiceClient method was called
Expand All @@ -2917,7 +2920,7 @@ void testAddProductToInventory_ShouldSucceed() {
@DisplayName("Given invalid inventoryId and valid productRequest Post and return NotFoundException")
void testAddProductToInventory_InvalidInventoryId_ShouldReturnNotFoundException() {
// Create a sample ProductRequestDTO
ProductRequestDTO requestDTO = new ProductRequestDTO("Sample Product", "Sample Description", 10.0, 100);
ProductRequestDTO requestDTO = new ProductRequestDTO("Sample Product", "Sample Description", 10.0, 100,15.99);

// Define the expected response
ProductResponseDTO expectedResponse = ProductResponseDTO.builder()
Expand Down Expand Up @@ -2960,6 +2963,7 @@ private ProductResponseDTO buildProductDTO(){
.productDescription("Sedative Medication")
.productPrice(100.00)
.productQuantity(10)
.productSalePrice(15.99)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
.flatMap(requestDTO -> inventoryRepository.findInventoryByInventoryId(inventoryId)
.switchIfEmpty(Mono.error(new NotFoundException("Inventory not found with id: " + inventoryId)))
.flatMap(inventory -> {
if (requestDTO.getProductName() == null || requestDTO.getProductPrice() == null || requestDTO.getProductQuantity() == null) {
if (requestDTO.getProductName() == null || requestDTO.getProductPrice() == null || requestDTO.getProductQuantity() == null || requestDTO.getProductSalePrice() == null) {
return Mono.error(new InvalidInputException("Product must have an inventory id, product name, product price, and product quantity."));
} else if (requestDTO.getProductPrice() < 0 || requestDTO.getProductQuantity() < 0) {
} else if (requestDTO.getProductPrice() < 0 || requestDTO.getProductQuantity() < 0 || requestDTO.getProductSalePrice() < 0) {
return Mono.error(new InvalidInputException("Product price and quantity must be greater than 0."));
} else {
Product product = EntityDTOUtil.toProductEntity(requestDTO);
Expand Down Expand Up @@ -94,9 +94,9 @@
.flatMap(requestDTO -> inventoryRepository.findInventoryByInventoryId(inventoryId)
.switchIfEmpty(Mono.error(new NotFoundException("Inventory not found with id: " + inventoryId)))
.flatMap(inventory -> {
if (requestDTO.getProductName() == null || requestDTO.getProductPrice() == null || requestDTO.getProductQuantity() == null) {
if (requestDTO.getProductName() == null || requestDTO.getProductPrice() == null || requestDTO.getProductQuantity() == null || requestDTO.getProductSalePrice() == null) {
return Mono.error(new InvalidInputException("Product must have an inventory id, product name, product price, and product quantity."));
} else if (requestDTO.getProductPrice() < 0 || requestDTO.getProductQuantity() < 0) {
} else if (requestDTO.getProductPrice() < 0 || requestDTO.getProductQuantity() < 0 || requestDTO.getProductSalePrice() < 0) {
return Mono.error(new InvalidInputException("Product price and quantity must be greater than 0."));
} else {
return productRepository.findProductByProductId(productId)
Expand All @@ -105,6 +105,7 @@
existingProduct.setProductDescription(requestDTO.getProductDescription());
existingProduct.setProductPrice(requestDTO.getProductPrice());
existingProduct.setProductQuantity(requestDTO.getProductQuantity());
existingProduct.setProductSalePrice(requestDTO.getProductSalePrice());

return productRepository.save(existingProduct)
.map(EntityDTOUtil::toProductResponseDTO);
Expand Down Expand Up @@ -227,7 +228,7 @@
return inventoryRepository
.findAllByInventoryNameAndInventoryTypeAndInventoryDescription(inventoryName, inventoryType, inventoryDescription)
.map(EntityDTOUtil::toInventoryResponseDTO)
.skip(page.getPageNumber() * page.getPageSize())

Check warning on line 231 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Integer multiplication or shift implicitly cast to 'long'

page.getPageNumber() \* page.getPageSize(): integer multiplication implicitly cast to long
.take(page.getPageSize())
.switchIfEmpty(Mono.error(new NotFoundException("Inventory not found with Name: " + inventoryName +
", Type: " + inventoryType + ", Description: " + inventoryDescription)));
Expand All @@ -237,7 +238,7 @@
return inventoryRepository
.findAllByInventoryTypeAndInventoryDescription(inventoryType, inventoryDescription)
.map(EntityDTOUtil::toInventoryResponseDTO)
.skip(page.getPageNumber() * page.getPageSize())

Check warning on line 241 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Integer multiplication or shift implicitly cast to 'long'

page.getPageNumber() \* page.getPageSize(): integer multiplication implicitly cast to long
.take(page.getPageSize())
.switchIfEmpty(Mono.error(new NotFoundException("Inventory not found with Type: " + inventoryType +
" and Description: " + inventoryDescription)));
Expand All @@ -254,7 +255,7 @@
return inventoryRepository
.findByInventoryNameRegex(regexPattern)
.map(EntityDTOUtil::toInventoryResponseDTO)
.skip(page.getPageNumber() * page.getPageSize())

Check warning on line 258 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Integer multiplication or shift implicitly cast to 'long'

page.getPageNumber() \* page.getPageSize(): integer multiplication implicitly cast to long
.take(page.getPageSize())
.switchIfEmpty(Mono.error(new NotFoundException("Inventory not found starting with: " + inventoryName)));
}
Expand All @@ -263,7 +264,7 @@
return inventoryRepository
.findByInventoryNameRegex(regexPattern)
.map(EntityDTOUtil::toInventoryResponseDTO)
.skip(page.getPageNumber() * page.getPageSize())

Check warning on line 267 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Integer multiplication or shift implicitly cast to 'long'

page.getPageNumber() \* page.getPageSize(): integer multiplication implicitly cast to long
.take(page.getPageSize())
.switchIfEmpty(Mono.error(new NotFoundException("Inventory not found with Name starting with or matching: " + inventoryName)));
}
Expand All @@ -274,7 +275,7 @@
return inventoryRepository
.findAllByInventoryType(inventoryType)
.map(EntityDTOUtil::toInventoryResponseDTO)
.skip(page.getPageNumber() * page.getPageSize())

Check warning on line 278 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Integer multiplication or shift implicitly cast to 'long'

page.getPageNumber() \* page.getPageSize(): integer multiplication implicitly cast to long
.take(page.getPageSize())
.switchIfEmpty(Mono.error(new NotFoundException("Inventory not found with Type: " + inventoryType)));
}
Expand All @@ -288,23 +289,23 @@
return inventoryRepository
.findByInventoryDescriptionRegex(regexPattern)
.map(EntityDTOUtil::toInventoryResponseDTO)
.skip(page.getPageNumber() * page.getPageSize())

Check warning on line 292 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Integer multiplication or shift implicitly cast to 'long'

page.getPageNumber() \* page.getPageSize(): integer multiplication implicitly cast to long
.take(page.getPageSize())
.switchIfEmpty(Mono.error(new NotFoundException("Inventory not found with Description: " + inventoryDescription)));
} else {
return inventoryRepository
.findByInventoryDescriptionRegex(regexPattern)
.map(EntityDTOUtil::toInventoryResponseDTO)
.skip(page.getPageNumber() * page.getPageSize())

Check warning on line 299 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Integer multiplication or shift implicitly cast to 'long'

page.getPageNumber() \* page.getPageSize(): integer multiplication implicitly cast to long
.take(page.getPageSize())
.switchIfEmpty(Mono.error(new NotFoundException("Inventory not found with Name starting with or matching: " + inventoryName)));

Check notice on line 301 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Constant values

Value `inventoryName` is always 'null'
}
}

// Default - fetch all if no criteria provided.
return inventoryRepository
.findAll()
.skip(page.getPageNumber() * page.getPageSize())

Check warning on line 308 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Integer multiplication or shift implicitly cast to 'long'

page.getPageNumber() \* page.getPageSize(): integer multiplication implicitly cast to long
.take(page.getPageSize())
.map(EntityDTOUtil::toInventoryResponseDTO);
}
Expand All @@ -313,11 +314,11 @@
@Override
public Mono<ProductResponseDTO> getProductByProductIdInInventory(String inventoryId, String productId) {
if(inventoryId == null ){
return Mono.error(new NotFoundException("Inventory id not found:" + inventoryId ));

Check notice on line 317 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Constant values

Value `inventoryId` is always 'null'

}
else if (productId == null) {
return Mono.error(new NotFoundException("product id not found:" + productId ));

Check notice on line 321 in inventory-service/src/main/java/com/petclinic/inventoryservice/businesslayer/ProductInventoryServiceImpl.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Constant values

Value `productId` is always 'null'
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Product {
private String inventoryId;
private String productName;
private String productDescription;
private Double productPrice;
private Integer productQuantity;
private Double productPrice;
private Double productSalePrice;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public class ProductRequestDTO {
private String productDescription;
private Double productPrice;
private Integer productQuantity;
private Double productSalePrice;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public class ProductResponseDTO {
private String productDescription;
private Double productPrice;
private Integer productQuantity;
private Double productSalePrice;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

@Service
public class DataBaseLoaderService implements CommandLineRunner {
@Autowired

Check notice on line 19 in inventory-service/src/main/java/com/petclinic/inventoryservice/utils/DataBaseLoaderService.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Non recommended 'field' injections

Field injection is not recommended
InventoryRepository inventoryRepository;
@Autowired

Check notice on line 21 in inventory-service/src/main/java/com/petclinic/inventoryservice/utils/DataBaseLoaderService.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Non recommended 'field' injections

Field injection is not recommended
ProductRepository productRepository;
@Autowired

Check notice on line 23 in inventory-service/src/main/java/com/petclinic/inventoryservice/utils/DataBaseLoaderService.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Non recommended 'field' injections

Field injection is not recommended
InventoryTypeRepository inventoryTypeRepository;

@Override
Expand Down Expand Up @@ -105,18 +105,23 @@
.productName("Benzodiazepines")
.productId(UUID.randomUUID().toString())
.productPrice(100.00)
.inventoryId("1")
.inventoryId(inventory1.getInventoryId())
.productQuantity(10)
.productDescription("Drugs for sleep")
.productSalePrice(10.00)
.build();


Product product2 = Product.builder()
.productName("Trazodone")
.productId(UUID.randomUUID().toString())
.productPrice(150.00)
.inventoryId("1")
.inventoryId(inventory1.getInventoryId())
.productQuantity(10)
.productDescription("Drugs for anxiety/stress")
.productSalePrice(10.00)
.build();

Flux.just(product1, product2)
.flatMap(productRepository::insert)
.log()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ProductInventoryServiceUnitTest {
.productDescription("Sedative Medication")
.productPrice(100.00)
.productQuantity(10)
.productSalePrice(15.99)
.build();
Product product = Product.builder()
.productId("12345")
Expand All @@ -54,6 +55,7 @@ class ProductInventoryServiceUnitTest {
.productDescription("Sedative Medication")
.productPrice(100.00)
.productQuantity(10)
.productSalePrice(15.99)
.build();
InventoryType inventoryType = InventoryType.builder()
.id("1")
Expand All @@ -68,11 +70,12 @@ class ProductInventoryServiceUnitTest {
.inventoryDescription("Medication for procedures")
.build();
ProductRequestDTO productRequestDTO = ProductRequestDTO.builder()
.productName("Benzodiazepines")
.productDescription("Sedative Medication")
.productPrice(100.00)
.productQuantity(10)
.build();
.productName("Benzodiazepines")
.productDescription("Sedative Medication")
.productPrice(100.00)
.productQuantity(10)
.productSalePrice(15.99)
.build();


@Test
Expand All @@ -82,6 +85,7 @@ void getAllProductsByInventoryId_andProductName_andProductPrice_andProductQuanti
Double productPrice = 100.00;
Integer productQuantity = 10;


when(productRepository
.findAllProductsByInventoryIdAndProductNameAndProductPriceAndProductQuantity(
inventoryId,
Expand Down Expand Up @@ -385,6 +389,8 @@ void updateProductInInventory_ValidRequest_ShouldUpdateAndReturnProduct() {
.productName("Updated Product Name")
.productPrice(99.99)
.productQuantity(20)
.productDescription("Description")
.productSalePrice(15.99)
.build();

Inventory inventory = Inventory.builder()
Expand All @@ -401,6 +407,7 @@ void updateProductInInventory_ValidRequest_ShouldUpdateAndReturnProduct() {
.productName("Original Product Name")
.productPrice(50.0)
.productQuantity(10)
.productSalePrice(10.10)
.build();

Product updatedProduct = Product.builder()
Expand All @@ -410,6 +417,8 @@ void updateProductInInventory_ValidRequest_ShouldUpdateAndReturnProduct() {
.productName("Updated Product Name")
.productPrice(99.99)
.productQuantity(20)
.productDescription("Description")
.productSalePrice(10.10)
.build();

when(inventoryRepository.findInventoryByInventoryId(anyString())).thenReturn(Mono.just(inventory));
Expand All @@ -427,6 +436,8 @@ void updateProductInInventory_ValidRequest_ShouldUpdateAndReturnProduct() {
assertEquals("Updated Product Name", responseDTO.getProductName());
assertEquals(99.99, responseDTO.getProductPrice());
assertEquals(20, responseDTO.getProductQuantity());
assertEquals("Description",responseDTO.getProductDescription());
assertEquals(10.10, responseDTO.getProductSalePrice());
return true;
})
.verifyComplete();
Expand All @@ -440,8 +451,10 @@ void updateProductInInventory_ProductNotFound_ShouldThrowNotFoundException() {

ProductRequestDTO productRequestDTO = ProductRequestDTO.builder()
.productName("Updated Product Name")
.productPrice(99.99)
.productPrice(-99.99)
.productQuantity(20)
.productDescription("Description")
.productSalePrice(10.10)
.build();

when(inventoryRepository.findInventoryByInventoryId(anyString())).thenReturn(Mono.empty());
Expand All @@ -466,6 +479,8 @@ void updateProductInInventory_InvalidInput_ShouldThrowInvalidInputException() {
.productName("Updated Product Name")
.productPrice(-99.99)
.productQuantity(20)
.productDescription("Description")
.productSalePrice(10.10)
.build();

Inventory inventory = Inventory.builder()
Expand Down Expand Up @@ -497,6 +512,8 @@ void updateProductInInventory_InvalidInputNull_ShouldThrowInvalidInputException(
.productName(null)
.productPrice(null)
.productQuantity(null)
.productDescription(null)
.productSalePrice(null)
.build();

// Mock the behavior of the inventoryRepository to return a dummy Inventory object
Expand Down Expand Up @@ -596,6 +613,8 @@ void addProductToInventory_ShouldSucceed(){
assertEquals(productResponseDTO.getProductName(), productRequestDTO.getProductName());
assertEquals(productResponseDTO.getProductPrice(), productRequestDTO.getProductPrice());
assertEquals(productResponseDTO.getProductQuantity(), productRequestDTO.getProductQuantity());
assertEquals(productResponseDTO.getProductDescription(),productRequestDTO.getProductDescription());
assertEquals(productResponseDTO.getProductSalePrice(), productRequestDTO.getProductSalePrice());
})
.verifyComplete();
Mockito.verify(productRepository, Mockito.times(1)).save(any(Product.class));
Expand Down Expand Up @@ -627,6 +646,8 @@ void addProductToInventory_WithInvalidProductRequest_ShouldThrowInvalidInputExce
.productDescription("Sedative Medication")
.productPrice(-100.00)
.productQuantity(10)
.productDescription("Description")
.productSalePrice(10.10)
.build();
Mockito.when(inventoryRepository.findInventoryByInventoryId(inventoryId))
.thenReturn(Mono.just(inventory));
Expand Down
Loading
Loading