-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test on the ScheduledService and adjusted Team Entity
- Loading branch information
Showing
14 changed files
with
232 additions
and
41 deletions.
There are no files selected for viewing
35 changes: 27 additions & 8 deletions
35
...r/src/main/java/ckb/BattleManager/controller/SendTeamsPointsFinishedBattleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,49 @@ | ||
package ckb.BattleManager.controller; | ||
|
||
import ckb.BattleManager.dto.output.BattleFinishedMessage; | ||
import ckb.BattleManager.model.Battle; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@Slf4j | ||
public class SendTeamsPointsFinishedBattleController { | ||
private final WebClient.Builder webClientBuilder; | ||
|
||
public SendTeamsPointsFinishedBattleController() { | ||
this.webClientBuilder = WebClient.builder(); | ||
} | ||
|
||
public void sendTeamsPointsFinishedBattle(Long idTournament, List<Pair<Long, Long>> pairsIdUserPoints) { | ||
webClientBuilder.build() | ||
public void sendIdUsersPointsFinishedBattle(Battle battle, List<Pair<Long, Integer>> pairsIdUserPoints) { | ||
ResponseEntity<Object> response = webClientBuilder.build() | ||
.post() | ||
.uri("http://tournament-service:port/api/send-teams-points-finished-battle") | ||
.body( | ||
.uri("http://tournament-manager:8084/api/" + | ||
"tournament/UpdateScore") | ||
.bodyValue( | ||
new BattleFinishedMessage( | ||
idTournament, | ||
battle.getTournamentId(), | ||
pairsIdUserPoints | ||
), | ||
BattleFinishedMessage.class | ||
); | ||
) | ||
) | ||
.retrieve() | ||
.toEntity(Object.class) | ||
.block(); | ||
|
||
if (response == null) { | ||
log.error("Error sending idUsers and points of the finished battle with id: {}. The response is null", battle.getBattleId()); | ||
return; | ||
} | ||
|
||
if (!response.getStatusCode().is2xxSuccessful()) { | ||
log.error("Error sending idUsers and points of the finished battle with id: {}. Error {}", battle.getBattleId(), response.getStatusCode()); | ||
return; | ||
} | ||
|
||
log.info("Successfully sent IdUsers and points of the finished battle with id: {}", battle.getBattleId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.