Skip to content

Commit 054c342

Browse files
committed
Don't create new HashSets, also use Hamcrest assertThat
1 parent 3cdcf94 commit 054c342

12 files changed

Lines changed: 18 additions & 21 deletions

src/inttest/java/com/faforever/api/data/ClanElideTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
import java.util.List;
2020
import java.util.Optional;
2121

22+
import static org.hamcrest.MatcherAssert.assertThat;
2223
import static org.hamcrest.Matchers.hasSize;
2324
import static org.hamcrest.Matchers.is;
2425
import static org.junit.Assert.assertFalse;
2526
import static org.junit.Assert.assertNotNull;
2627
import static org.junit.Assert.assertNull;
27-
import static org.junit.Assert.assertThat;
2828
import static org.junit.Assert.assertTrue;
2929
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
3030
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;

src/inttest/java/com/faforever/api/data/UserNoteTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
1212

1313
import static com.faforever.api.data.JsonApiMediaType.JSON_API_MEDIA_TYPE;
14+
import static org.hamcrest.MatcherAssert.assertThat;
1415
import static org.hamcrest.Matchers.hasSize;
1516
import static org.hamcrest.core.Is.is;
16-
import static org.junit.Assert.assertThat;
1717
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
1818
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
1919
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;

src/test/java/com/faforever/api/achievements/PlayerAchievementsControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.mockito.Mock;
1010
import org.mockito.junit.jupiter.MockitoExtension;
1111

12+
import static org.hamcrest.MatcherAssert.assertThat;
1213
import static org.hamcrest.Matchers.hasSize;
13-
import static org.junit.Assert.assertThat;
1414
import static org.junit.jupiter.api.Assertions.assertThrows;
1515
import static org.mockito.ArgumentMatchers.any;
1616
import static org.mockito.ArgumentMatchers.anyInt;

src/test/java/com/faforever/api/data/listeners/ClanEnricherListenerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.junit.jupiter.api.Test;
88

99
import static org.hamcrest.CoreMatchers.is;
10-
import static org.junit.Assert.assertThat;
10+
import static org.hamcrest.MatcherAssert.assertThat;
1111

1212
public class ClanEnricherListenerTest {
1313
private ClanEnricherListener instance;

src/test/java/com/faforever/api/data/listeners/TutorialEnricherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.springframework.context.support.MessageSourceAccessor;
1111

1212
import static org.hamcrest.CoreMatchers.is;
13-
import static org.junit.Assert.assertThat;
13+
import static org.hamcrest.MatcherAssert.assertThat;
1414

1515
@ExtendWith(MockitoExtension.class)
1616
public class TutorialEnricherTest {

src/test/java/com/faforever/api/data/listeners/VotingSubjectEnricherTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.springframework.context.support.MessageSourceAccessor;
1616

1717
import java.time.OffsetDateTime;
18-
import java.util.HashSet;
1918
import java.util.List;
2019
import java.util.Set;
2120

@@ -309,20 +308,20 @@ private void addAnswerToChoice(VotingChoice votingChoice, VotingQuestion votingQ
309308
if (vote.getVotingAnswers() != null) {
310309
vote.getVotingAnswers().add(votingAnswer);
311310
} else {
312-
vote.setVotingAnswers(new HashSet<>(Set.of(votingAnswer)));
311+
vote.setVotingAnswers(Set.of(votingAnswer));
313312
}
314313

315314
if (votingChoice != null) {
316315
if (votingChoice.getVotingAnswers() != null) {
317316
votingChoice.getVotingAnswers().add(votingAnswer);
318317
} else {
319-
votingChoice.setVotingAnswers(new HashSet<>(Set.of(votingAnswer)));
318+
votingChoice.setVotingAnswers(Set.of(votingAnswer));
320319
}
321320

322321
if (votingQuestion.getVotingChoices() != null) {
323322
votingQuestion.getVotingChoices().add(votingChoice);
324323
} else {
325-
votingQuestion.setVotingChoices(new HashSet<>(Set.of(votingChoice)));
324+
votingQuestion.setVotingChoices(Set.of(votingChoice));
326325
}
327326
}
328327
}

src/test/java/com/faforever/api/email/JavaEmailSenderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import javax.mail.internet.MimeMessage;
1616

1717
import static org.hamcrest.CoreMatchers.is;
18-
import static org.junit.Assert.assertThat;
18+
import static org.hamcrest.MatcherAssert.assertThat;
1919
import static org.mockito.Mockito.verify;
2020

2121
@ExtendWith(MockitoExtension.class)

src/test/java/com/faforever/api/leaderboard/LeaderboardControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import static org.hamcrest.CoreMatchers.is;
1818
import static org.hamcrest.CoreMatchers.notNullValue;
19+
import static org.hamcrest.MatcherAssert.assertThat;
1920
import static org.hamcrest.Matchers.hasSize;
20-
import static org.junit.Assert.assertThat;
2121
import static org.mockito.Mockito.when;
2222

2323
@ExtendWith(MockitoExtension.class)

src/test/java/com/faforever/api/leaderboard/LeaderboardServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.List;
1313

1414
import static org.hamcrest.CoreMatchers.is;
15-
import static org.junit.Assert.assertThat;
15+
import static org.hamcrest.MatcherAssert.assertThat;
1616
import static org.mockito.Mockito.verify;
1717
import static org.mockito.Mockito.when;
1818

src/test/java/com/faforever/api/security/OAuthClientDetailsServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.faforever.api.client.OAuthClient;
44
import com.faforever.api.client.OAuthClientRepository;
55
import com.faforever.api.config.FafApiProperties;
6-
import org.junit.jupiter.api.BeforeEach;
76
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.api.BeforeEach;
88
import org.junit.jupiter.api.Test;
99
import org.junit.jupiter.api.extension.ExtendWith;
1010
import org.mockito.Mock;
@@ -15,7 +15,7 @@
1515
import java.util.Optional;
1616

1717
import static org.hamcrest.CoreMatchers.notNullValue;
18-
import static org.junit.Assert.assertThat;
18+
import static org.hamcrest.MatcherAssert.assertThat;
1919
import static org.mockito.Mockito.when;
2020

2121
@ExtendWith(MockitoExtension.class)

0 commit comments

Comments
 (0)