Skip to content

Commit 48bb824

Browse files
Sheikah45Brutus5000
authored andcommitted
Mostly there
1 parent 66e039f commit 48bb824

6 files changed

Lines changed: 22 additions & 11 deletions

File tree

src/inttest/java/com/faforever/api/AbstractIntegrationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.springframework.test.web.servlet.MvcResult;
3535
import org.springframework.test.web.servlet.request.RequestPostProcessor;
3636
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
37+
import org.springframework.transaction.annotation.Transactional;
3738
import org.springframework.web.context.WebApplicationContext;
3839
import org.testcontainers.containers.Network;
3940
import org.testcontainers.containers.RabbitMQContainer;
@@ -50,6 +51,7 @@
5051
@ExtendWith(SpringExtension.class)
5152
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
5253
@ActiveProfiles(ApplicationProfile.INTEGRATION_TEST)
54+
@Transactional
5355
@Import(OAuthHelper.class)
5456
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:sql/truncateTables.sql")
5557
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts = "classpath:sql/prepDefaultData.sql")

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.springframework.http.HttpHeaders;
1313
import org.springframework.test.context.jdbc.Sql;
1414
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
15+
import org.springframework.transaction.annotation.Propagation;
16+
import org.springframework.transaction.annotation.Transactional;
1517

1618
import java.time.OffsetDateTime;
1719

@@ -150,6 +152,7 @@ public void canRevokeBanWithScopeAndRole() throws Exception {
150152
}
151153

152154
@Test
155+
@Transactional(propagation = Propagation.NOT_SUPPORTED)
153156
public void canCreateBanWithModerationWithScopeAndRole() throws Exception {
154157

155158
final BanInfo ban = new BanInfo()

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.springframework.http.HttpHeaders;
1414
import org.springframework.test.context.jdbc.Sql;
1515
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
16+
import org.springframework.transaction.annotation.Propagation;
17+
import org.springframework.transaction.annotation.Transactional;
1618

1719
import java.util.ArrayList;
1820
import java.util.List;
@@ -166,14 +168,10 @@ private String generateTransferLeadershipContent(int clanId, int newLeaderId) {
166168
}
167169

168170
@Test
171+
@Transactional(propagation = Propagation.NOT_SUPPORTED)
169172
public void canDeleteClanAsLeader() throws Exception {
170-
Clan clan = clanRepository.findOneByName("Alpha Clan")
171-
.orElseThrow(() -> new IllegalStateException("Alpha Clan could not be found"));
172-
173-
List<Player> clanMember = new ArrayList<>();
174-
clan.getMemberships().stream()
175-
.map(ClanMembership::getPlayer)
176-
.forEach(clanMember::add);
173+
// clanRepository.findOneByName("Alpha Clan")
174+
// .orElseThrow(() -> new IllegalStateException("Alpha Clan could not be found"));
177175

178176
mockMvc.perform(
179177
delete("/data/clan/1")

src/inttest/java/com/faforever/api/moderationreport/ModerationReportTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import org.springframework.security.test.context.support.WithAnonymousUser;
1515
import org.springframework.test.context.jdbc.Sql;
1616
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
17+
import org.springframework.transaction.annotation.Propagation;
18+
import org.springframework.transaction.annotation.Transactional;
1719

1820
import java.util.Set;
1921

@@ -165,6 +167,7 @@ public void cannotUpdateSomeoneElsesReport() throws Exception {
165167
}
166168

167169
@Test
170+
@Transactional(propagation = Propagation.NOT_SUPPORTED)
168171
public void canUpdateOwnReport() throws Exception {
169172
reportedUsers.add((Player) new Player().setId("1"));
170173

@@ -252,6 +255,7 @@ public void canUpdateReportStatusWithScopeAndRole() throws Exception {
252255
}
253256

254257
@Test
258+
@Transactional(propagation = Propagation.NOT_SUPPORTED)
255259
public void canUpdateNoticeWithScopeAndRole() throws Exception {
256260
final ModerationReport updatedPublicNoteModerationReport = (ModerationReport) new ModerationReport()
257261
.setModeratorNotice("New moderator notice")
@@ -295,6 +299,7 @@ public void cannotUpdateNoticeWithoutRole() throws Exception {
295299
}
296300

297301
@Test
302+
@Transactional(propagation = Propagation.NOT_SUPPORTED)
298303
public void canUpdatePrivateNoteWithScopeAndRole() throws Exception {
299304
final ModerationReport updatedPrivateNoteModerationReport = (ModerationReport) new ModerationReport()
300305
.setModeratorPrivateNote("New moderator private note")
@@ -338,6 +343,7 @@ public void cannotUpdatePrivateNoteWithoutRole() throws Exception {
338343
}
339344

340345
@Test
346+
@Transactional(propagation = Propagation.NOT_SUPPORTED)
341347
public void lastModeratorIsUpdatedWhenCalledByModerator() throws Exception {
342348
final ModerationReport updatedPrivateNoteModerationReport = (ModerationReport) new ModerationReport()
343349
.setModeratorPrivateNote("New moderator private note")

src/inttest/java/com/faforever/api/user/UsersControllerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public void linkToSteamAlreadyLinkedAccount() throws Exception {
339339
.andExpect(redirectedUrlPattern(callbackUrl + "?errors=*" + ErrorCode.STEAM_ID_ALREADY_LINKED.getCode() + "*" + userThatOwnsSteamId.getLogin() + "*"));
340340
//We expect and error with code STEAM_ID_ALREADY_LINKED and that the error message contains the user that this steam account was linked to already which is MODERATOR with id 2
341341

342-
assertThat(accountLinkRepository.existsByUserAndServiceType(userRepository.getReferenceById(1), LinkedServiceType.STEAM), is(false));
342+
assertThat(accountLinkRepository.existsByUserAndServiceType(userRepository.findById(1).orElseThrow(), LinkedServiceType.STEAM), is(false));
343343
}
344344

345345
@Test
@@ -519,7 +519,7 @@ public void linkToGogSuccess() throws Exception {
519519
.params(params))
520520
.andExpect(status().isOk());
521521

522-
assertThat(accountLinkRepository.existsByUserAndServiceType(userRepository.getReferenceById(1), LinkedServiceType.GOG), is(true));
522+
assertThat(accountLinkRepository.existsByUserAndServiceType(userRepository.findById(1).orElseThrow(), LinkedServiceType.GOG), is(true));
523523
}
524524

525525
@Test
@@ -535,6 +535,6 @@ public void linkToGogAlreadyLinked() throws Exception {
535535
.params(params))
536536
.andExpect(status().isUnprocessableEntity());
537537

538-
assertThat(accountLinkRepository.existsByUserAndServiceType(userRepository.getReferenceById(1), LinkedServiceType.GOG), is(false));
538+
assertThat(accountLinkRepository.existsByUserAndServiceType(userRepository.findById(1).orElseThrow(), LinkedServiceType.GOG), is(false));
539539
}
540540
}

src/inttest/java/com/faforever/api/utils/OAuthHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.jetbrains.annotations.NotNull;
1010
import org.springframework.stereotype.Component;
1111
import org.springframework.test.web.servlet.request.RequestPostProcessor;
12+
import org.springframework.transaction.annotation.Transactional;
1213

1314
import java.util.Set;
1415
import java.util.stream.Collectors;
@@ -23,8 +24,9 @@ public OAuthHelper(PlayerRepository playerRepository) {
2324
this.playerRepository = playerRepository;
2425
}
2526

27+
@Transactional
2628
public RequestPostProcessor addBearerTokenForUser(int userId, @NotNull Set<String> scopes) {
27-
Player user = playerRepository.getReferenceById(userId);
29+
Player user = playerRepository.findById(userId).orElseThrow();
2830

2931
Set<FafRole> roles = user.getUserGroups().stream()
3032
.flatMap(userGroup -> userGroup.getPermissions().stream())

0 commit comments

Comments
 (0)