Question: Maven Project I am trying to understand and type a JUnit test for each of these methods. Below I have sent in my methods that

Maven Project

I am trying to understand and type a JUnit test for each of these methods. Below I have sent in my methods that I have currently. Please send back the code to do JUnit testing with the methods below.

Maven Project I am trying to understand and type a JUnit testthis is what I have so far

for each of these methods. Below I have sent in my methods

= @RestController @CrossOrigin(origins "http://localhost:4200") public class UserController { @Autowired UserRepository repository; @Autowired AuthService authService; @Autowired SaveUserService saveUserService; @etMapping("/Users") public List getUsers() { return repository.findAll(); } @etMapping("/Users/{id}") public Optional getUsers(lapathvariable String id) { return repository.findById(id); } @eleteMapping("/Users/{id}") public String deleteUser(@PathVariable String id) { repository.deleteById(id); return "user deleted with id : " + id; } @InjectMocks UserController userController; @Mock UserRepository testRepository; @Mock User testUser1 = new User("fakeEmaill@gmail.com", "fakeName1 @Test void saveUser() throws Exception { } @Test void authenticateUser() throws Exception { } @Test void getUsers() throws Exception { //given //created a list with test user in it List testList = new ArrayList(); testList.add(testUser1); // userController.saveUser(testUser1); //assertSame(testUser1, userController.getUsers()); } @Test void testGetUsers() throws Exception { } = @RestController @CrossOrigin(origins "http://localhost:4200") public class UserController { @Autowired UserRepository repository; @Autowired AuthService authService; @Autowired SaveUserService saveUserService; @etMapping("/Users") public List getUsers() { return repository.findAll(); } @etMapping("/Users/{id}") public Optional getUsers(lapathvariable String id) { return repository.findById(id); } @eleteMapping("/Users/{id}") public String deleteUser(@PathVariable String id) { repository.deleteById(id); return "user deleted with id : " + id; } @InjectMocks UserController userController; @Mock UserRepository testRepository; @Mock User testUser1 = new User("fakeEmaill@gmail.com", "fakeName1 @Test void saveUser() throws Exception { } @Test void authenticateUser() throws Exception { } @Test void getUsers() throws Exception { //given //created a list with test user in it List testList = new ArrayList(); testList.add(testUser1); // userController.saveUser(testUser1); //assertSame(testUser1, userController.getUsers()); } @Test void testGetUsers() throws Exception { }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!