Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package WIMTest.Commands.Add;
- import com.WIM.commands.add.AddMemberToTeam;
- import com.WIM.commands.contracts.Command;
- import com.WIM.core.ManagementSystemRepositoryImpl;
- import com.WIM.core.contracts.ManagementSystemRepository;
- import com.WIM.models.MemberImpl;
- import com.WIM.models.TeamImpl;
- import com.WIM.models.contracts.Member;
- import com.WIM.models.contracts.Team;
- import org.junit.Assert;
- import org.junit.Before;
- import org.junit.Test;
- import java.util.ArrayList;
- import java.util.List;
- import static com.WIM.commands.constants.CommandConstants.NO_SUCH_MEMBER;
- import static com.WIM.commands.constants.CommandConstants.NO_SUCH_TEAM;
- import static java.util.Arrays.asList;
- public class AddMemberToTeam_Test {
- private Command testCommand;
- private ManagementSystemRepository managementSystemRepository;
- private Team teamToTest;
- private Member testMember;
- @Before
- public void before() {
- managementSystemRepository = new ManagementSystemRepositoryImpl();
- testCommand = new AddMemberToTeam(managementSystemRepository);
- teamToTest = new TeamImpl("teamName");
- testMember = new MemberImpl("memberName");
- }
- @Test (expected = IllegalArgumentException.class)
- public void check_If_Parameters_Are_More() {
- //Arrange, Act & Assert
- testCommand.execute(asList(new String[3]));
- }
- @Test (expected = IllegalArgumentException.class)
- public void checkIf_Parameters_Are_Less() {
- //Arrange, Act & Assert
- testCommand.execute(asList(new String[1]));
- }
- @Test
- public void execute_should_throwException_when_Member_notExist() {
- // Arrange
- List<String> testList = new ArrayList<>();
- testList.add("memberName");
- testList.add("teamName");
- managementSystemRepository.addMember(testMember);
- // Act & Assert
- testCommand.execute(testList);
- //Assert
- Assert.assertEquals(String.format(NO_SUCH_MEMBER, "memberName1"), managementSystemRepository.addMemberToTeam("memberName1", "teamName1"));
- }
- @Test
- public void execute_should_throwException_when_Team_notExist() {
- //Arrange
- List<String> testList = new ArrayList<>();
- testList.add("memberName");
- testList.add("teamName");
- managementSystemRepository.addMember(testMember);
- // Act & Assert
- testCommand.execute(testList);
- //Assert
- Assert.assertEquals(String.format(NO_SUCH_TEAM, "teamName1"), managementSystemRepository.addMemberToTeam("memberName", "teamName1"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement