Skip to content

Commit 5818e45

Browse files
fix test
1 parent 14b4ad4 commit 5818e45

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/test/java/com/amigoscode/product/ProductServiceTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,14 @@ void saveNewProductWithImageHandlesImageUploadFailure() {
239239
.when(productImageService).uploadProductImage(any(), any());
240240

241241
// when
242-
UUID productId = underTest.saveNewProductWithImage(name, description, price, stockLevel, mockImage);
242+
assertThatThrownBy(() -> {
243+
underTest.saveNewProductWithImage(name, description, price, stockLevel, mockImage);
244+
})
245+
.isInstanceOf(IllegalStateException.class)
246+
.hasMessageContaining("Product created but image upload failed");
243247

244248
// then
245-
assertThat(productId).isNotNull();
246249
verify(productRepository).save(any(Product.class));
247-
verify(productImageService).uploadProductImage(productId, mockImage);
248250
}
249251

250252
@Test
@@ -318,7 +320,7 @@ void canUpdateProduct() {
318320
// then
319321
verify(productRepository).findById(productId);
320322
verify(productRepository).save(existingProduct);
321-
323+
322324
assertThat(existingProduct.getName()).isEqualTo("Updated Name");
323325
assertThat(existingProduct.getDescription()).isEqualTo("Updated Description");
324326
assertThat(existingProduct.getImageUrl()).isEqualTo("updated-image.png");

0 commit comments

Comments
 (0)