-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd9ea10
commit 5ee4938
Showing
4 changed files
with
42 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import java.util.List; | ||
import java.util.Optional; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
|
@@ -25,7 +26,8 @@ void setUp() { | |
} | ||
|
||
@Test | ||
void testGetAll_ShouldReturnListOfShoppers() { | ||
@DisplayName("should be able to get all shoppers") | ||
void getAll_ShouldReturnListOfShoppers() { | ||
// Mock data | ||
Shopper shopper1 = new Shopper(1L, "TechNinja", "[email protected]"); | ||
Shopper shopper2 = new Shopper(2L, "CodeMaster", "[email protected]"); | ||
|
@@ -44,7 +46,8 @@ void testGetAll_ShouldReturnListOfShoppers() { | |
} | ||
|
||
@Test | ||
void testGetById_ShouldReturnShopper() { | ||
@DisplayName("should be able to get shopper by id") | ||
void getShopperById_ShouldReturnShopper() { | ||
// Mock data | ||
Shopper shopper = new Shopper(1L, "DataGuru", "[email protected]"); | ||
|
||
|
@@ -59,7 +62,8 @@ void testGetById_ShouldReturnShopper() { | |
} | ||
|
||
@Test | ||
void testGetById_ShouldThrowNotFoundException() { | ||
@DisplayName("should throw NotFoundException when shopper not found") | ||
void getShopperById_ShouldThrowNotFoundException() { | ||
// Mock repository method returning empty optional | ||
when(shopperRepository.findById(1)).thenReturn(Optional.empty()); | ||
|
||
|
@@ -68,7 +72,8 @@ void testGetById_ShouldThrowNotFoundException() { | |
} | ||
|
||
@Test | ||
void testGetByUsername_ShouldReturnShopper() { | ||
@DisplayName("should be able to get shopper by username") | ||
void getShopperByUsername_ShouldReturnShopper() { | ||
// Mock data | ||
Shopper shopper = new Shopper(1L, "DataGuru", "[email protected]"); | ||
|
||
|
@@ -83,7 +88,8 @@ void testGetByUsername_ShouldReturnShopper() { | |
} | ||
|
||
@Test | ||
void testGetByUsername_ShouldThrowNotFoundException() { | ||
@DisplayName("should throw NotFoundException when shopper not found") | ||
void getByUsername_ShouldThrowNotFoundException() { | ||
// Mock repository method returning empty optional | ||
when(shopperRepository.findByUsername("DataGuru")).thenReturn(Optional.empty()); | ||
|
||
|