Aiven-Open/klaw

Additional Unit Tests for Switch Teams in UsersTeamsControllerService

aindriu-aiven opened this issue ยท 4 comments

Related EPIC #2427
Use cases that require additional unit tests.

updateSwitchTeamsList

  • Switch Team
  • Switch To Team which does not exist.
  • Switch to Team that exists but user is not a member of
  • Switch Team where user does not have switch team enabled.

getSwitchTeams
This is a test that would do well parameterized

  • Get Switch Teams with no teams returned
  • Get Switch Teams with single team returned
  • Get Switch Teams with multiple teams returned

updateUserTeamFromSwitchTeams

  • Expect Not Authorized response when user does not have switch teams enabled

  • Expect Not Authorized response when authorizedUser is false

  • Make team change successfully

  • Make Change but have DB return "Failure Team doesn't exist"

@aindriu-aiven I would like to work on this issue.

@aindriu-aiven I would like to work on this issue.

That sounds great just assigned it to you thanks a million!

@aindriu-aiven I have opened a pull request. Just some notes.

updateSwitchTeamsList is a private method in UsersTeamsControllerService.java, there are 3 public methods that use it showUsers, getMyProfileInfo and getUserInfoDetails.

I did not tests for getUserInfoDetails because

  1. A test already exists

  2. In the public method the updateSwitchTeamsList is called with the updateTeamName boolean as false. The parts of code where switch team names are added does not get triggered.

But I added full tests for the other two methods. I was not sure about how to test Switch To Team which does not exist and Switch to Team that exists but user is not a member of so I just configured the tests that I best saw fit to simulate the scenario.

Please let me know in the review if the test designs were ok, thanks.

@aindriu-aiven I have opened a pull request. Just some notes.

updateSwitchTeamsList is a private method in UsersTeamsControllerService.java, there are 3 public methods that use it showUsers, getMyProfileInfo and getUserInfoDetails.

I did not tests for getUserInfoDetails because

  1. A test already exists
  2. In the public method the updateSwitchTeamsList is called with the updateTeamName boolean as false. The parts of code where switch team names are added does not get triggered.

But I added full tests for the other two methods. I was not sure about how to test Switch To Team which does not exist and Switch to Team that exists but user is not a member of so I just configured the tests that I best saw fit to simulate the scenario.

Please let me know in the review if the test designs were ok, thanks.

That sounds good to me, I'm hoping to free up to get a review in tomorrow morning.
Thanks a million for your contribution!