Skip to content
Snippets Groups Projects
Commit b1c7eef4 authored by Nicolai Hollup Brand's avatar Nicolai Hollup Brand :penguin:
Browse files

Merge branch 'refactor/semantic-edits' into 'main'

refactor(main...Team): Changed toString-method.

See merge request carljgu/tournament-service!41
parents 41b34637 45dcd4c0
No related branches found
No related tags found
No related merge requests found
......@@ -83,18 +83,10 @@ public class Team {
@Override
public String toString() {
return (
"Team{" +
"id=" +
id +
", name='" +
name +
'\'' +
", members=" +
members +
", isCompeting=" +
isCompeting +
'}'
);
"Team: " + name +
"\nID: " + id +
"\nTeam members: " + members.size() +
"\nIn competition: " + isCompeting);
}
@Override
......
......@@ -7,12 +7,33 @@ import edu.ntnu.idatt1002.k1g4.Team;
import edu.ntnu.idatt1002.k1g4.enums.Sex;
import edu.ntnu.idatt1002.k1g4.people.Competitor;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
public class TeamTest {
Team testTeam;
@BeforeEach
public void createsInitialTeamWithMembersToUseForFurtherTesting() {
/*
This code is run before each of the following tests and instantiates a team with members.
*/
ArrayList<Competitor> teamMemberList = new ArrayList<>();
teamMemberList.add(new Competitor("Karl",
LocalDate.of(2000,3,13), Sex.MALE, 101, true, false));
teamMemberList.add(new Competitor("Andreas",
LocalDate.of(2000,6,29), Sex.MALE, 102, true, false));
teamMemberList.add(new Competitor("Lars",
LocalDate.of(2000,8,3), Sex.MALE, 103, true, false));
testTeam = new Team(1111,"TestTeam", teamMemberList, true);
}
@Nested
public class TeamConstructorThrowsException {
......@@ -36,4 +57,21 @@ public class TeamTest {
}
}
}
@Test
public void assertOutcomeOfToString() {
/*
This test asserts that the toString looks as expected.
*/
assertEquals(testTeam.toString(), """
Team: TestTeam
ID: 1111
Team members: 3
In competition: true""");
}
@Test
public void addASingleTeamMemberToTeam() {
//TODO: This method must be implemented in the Team class.
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment