mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-06 14:37:38 +08:00
[ongeki,api] support ongeki rival
This commit is contained in:
@@ -3,6 +3,7 @@ package icu.samnyan.aqua.sega.ongeki.dao.userdata;
|
||||
import icu.samnyan.aqua.sega.general.dao.CardRepository;
|
||||
import icu.samnyan.aqua.sega.general.model.Card;
|
||||
import icu.samnyan.aqua.sega.ongeki.model.userdata.*;
|
||||
import icu.samnyan.aqua.util.CardHelper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
|
||||
@@ -63,6 +64,8 @@ class OngekiRepositoryTest {
|
||||
private UserTechCountRepository userTechCountRepository;
|
||||
@Autowired
|
||||
private UserTrainingRoomRepository userTrainingRoomRepository;
|
||||
@Autowired
|
||||
private UserRivalDataRepository userRivalDataRepository;
|
||||
|
||||
@Test
|
||||
void userData_SaveLoad() {
|
||||
@@ -337,10 +340,35 @@ class OngekiRepositoryTest {
|
||||
assertThat(aL).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void userRivalData_SaveLoad() {
|
||||
var u = getNewRandomValidUser();
|
||||
var r1 = getNewRandomValidUser();
|
||||
var r2 = getNewRandomValidUser();
|
||||
var r3 = getNewRandomValidUser();
|
||||
|
||||
userRivalDataRepository.saveAll(List.of(
|
||||
getUserRival(u, r1),
|
||||
getUserRival(u, r2),
|
||||
getUserRival(r1, r2),
|
||||
getUserRival(r2, u)
|
||||
));
|
||||
|
||||
var all = userRivalDataRepository.findAll();
|
||||
assertThat(all).hasSize(4);
|
||||
|
||||
var find = userRivalDataRepository.findByUser_Card_ExtId(u.getCard().getExtId());
|
||||
assertThat(find).hasSize(2);
|
||||
}
|
||||
|
||||
private UserData getUser(Card c) {
|
||||
return new UserData(-1, c, "Hello", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "2020", "2020", "SDDT", "1.00.00", "1.00.00", "2020", "SDDT", "1.00.00", "1.00.00", "", "2020", 0, "0", 0, "123", 0, "A000000", 0, 0, 0);
|
||||
}
|
||||
|
||||
private UserData getNewRandomValidUser() {
|
||||
return userDataRepository.save(getUser(cardRepository.save(CardHelper.getRandomCard())));
|
||||
}
|
||||
|
||||
private UserActivity getActivity(UserData u, Integer activityId) {
|
||||
return new UserActivity(-1, u, 1, activityId, 0, 0, 0, 0, 0);
|
||||
}
|
||||
@@ -416,4 +444,8 @@ class OngekiRepositoryTest {
|
||||
private UserTrainingRoom getTrainingRoom(UserData u, Integer roomId) {
|
||||
return new UserTrainingRoom(-1, u, "", roomId, 1, "");
|
||||
}
|
||||
|
||||
private UserRival getUserRival(UserData user, UserData rival) {
|
||||
return new UserRival(0, user, rival.getCard().getExtId());
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,30 @@ package icu.samnyan.aqua.util;
|
||||
import icu.samnyan.aqua.sega.general.model.Card;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author sam_nya (privateamusement@protonmail.com)
|
||||
*/
|
||||
public class CardHelper {
|
||||
private static Random rand = new Random();
|
||||
|
||||
public static Card getCard() {
|
||||
var now = LocalDateTime.now();
|
||||
return new Card(1L, 114514L, "01145141919810000000", now, now);
|
||||
}
|
||||
|
||||
public static Card getRandomCard() {
|
||||
var now = LocalDateTime.now();
|
||||
|
||||
var luid = "";
|
||||
for (int i = 0; i < "01145141919810028570".length(); i++)
|
||||
luid += rand.nextInt(10);
|
||||
|
||||
var extId = 0L;
|
||||
for (int i = 0; i < "114514".length(); i++)
|
||||
extId = extId * 10 + rand.nextInt(10);
|
||||
|
||||
return new Card(0, extId, luid, now, now);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user