Advertisement
Guest User

AddMemberToTeam

a guest
Jan 19th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. package WIMTest.Commands.Add;
  2.  
  3. import com.WIM.commands.add.AddMemberToTeam;
  4. import com.WIM.commands.contracts.Command;
  5. import com.WIM.core.ManagementSystemRepositoryImpl;
  6. import com.WIM.core.contracts.ManagementSystemRepository;
  7. import com.WIM.models.MemberImpl;
  8. import com.WIM.models.TeamImpl;
  9. import com.WIM.models.contracts.Member;
  10. import com.WIM.models.contracts.Team;
  11. import org.junit.Assert;
  12. import org.junit.Before;
  13. import org.junit.Test;
  14.  
  15. import java.util.ArrayList;
  16. import java.util.List;
  17.  
  18. import static com.WIM.commands.constants.CommandConstants.NO_SUCH_MEMBER;
  19. import static com.WIM.commands.constants.CommandConstants.NO_SUCH_TEAM;
  20. import static java.util.Arrays.asList;
  21.  
  22. public class AddMemberToTeam_Test {
  23. private Command testCommand;
  24. private ManagementSystemRepository managementSystemRepository;
  25. private Team teamToTest;
  26. private Member testMember;
  27.  
  28. @Before
  29. public void before() {
  30. managementSystemRepository = new ManagementSystemRepositoryImpl();
  31. testCommand = new AddMemberToTeam(managementSystemRepository);
  32. teamToTest = new TeamImpl("teamName");
  33. testMember = new MemberImpl("memberName");
  34. }
  35.  
  36. @Test (expected = IllegalArgumentException.class)
  37. public void check_If_Parameters_Are_More() {
  38. //Arrange, Act & Assert
  39. testCommand.execute(asList(new String[3]));
  40. }
  41.  
  42. @Test (expected = IllegalArgumentException.class)
  43. public void checkIf_Parameters_Are_Less() {
  44. //Arrange, Act & Assert
  45. testCommand.execute(asList(new String[1]));
  46. }
  47.  
  48. @Test
  49. public void execute_should_throwException_when_Member_notExist() {
  50. // Arrange
  51. List<String> testList = new ArrayList<>();
  52. testList.add("memberName");
  53. testList.add("teamName");
  54. managementSystemRepository.addMember(testMember);
  55.  
  56. // Act & Assert
  57. testCommand.execute(testList);
  58. //Assert
  59. Assert.assertEquals(String.format(NO_SUCH_MEMBER, "memberName1"), managementSystemRepository.addMemberToTeam("memberName1", "teamName1"));
  60. }
  61.  
  62. @Test
  63. public void execute_should_throwException_when_Team_notExist() {
  64. //Arrange
  65. List<String> testList = new ArrayList<>();
  66. testList.add("memberName");
  67. testList.add("teamName");
  68. managementSystemRepository.addMember(testMember);
  69. // Act & Assert
  70. testCommand.execute(testList);
  71. //Assert
  72. Assert.assertEquals(String.format(NO_SUCH_TEAM, "teamName1"), managementSystemRepository.addMemberToTeam("memberName", "teamName1"));
  73. }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement