mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-13 16:40:01 +00:00
Update Spring Boot version to 2.7.4
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
<commons-compress.version>1.21</commons-compress.version>
|
||||
<protoc.plugin.version>3.11.4</protoc.plugin.version>
|
||||
<protobuf-java.version>3.21.7</protobuf-java.version>
|
||||
<easy-random.version>5.0.0</easy-random.version>
|
||||
<easy-random-protobuf.version>0.4.0</easy-random-protobuf.version>
|
||||
|
||||
<!-- Use older version because the newer versions have problems with non-ASCII characters in properties files (umlauts etc.) -->
|
||||
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
|
||||
@@ -117,6 +119,29 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeasy</groupId>
|
||||
<artifactId>easy-random-core</artifactId>
|
||||
<version>${easy-random.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.murdos</groupId>
|
||||
<artifactId>easy-random-protobuf</artifactId>
|
||||
<version>${easy-random-protobuf.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>mockwebserver</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Dev -->
|
||||
<dependency>
|
||||
|
||||
@@ -37,6 +37,12 @@ public class IgdbWrapper {
|
||||
@Value("${gameyfin.igdb.config.preferred-platforms:6}")
|
||||
private String preferredPlatforms;
|
||||
|
||||
@Value("${gameyfin.igdb.api.endpoints.base}")
|
||||
private String igdbApiBaseUrl;
|
||||
|
||||
@Value("${gameyfin.igdb.api.endpoints.auth}")
|
||||
private String twitchAuthUrl;
|
||||
|
||||
private final WebClient.Builder webclientBuilder;
|
||||
private final WebClientConfig webClientConfig;
|
||||
private final GameMapper gameMapper;
|
||||
@@ -58,7 +64,8 @@ public class IgdbWrapper {
|
||||
log.info("Authenticating on Twitch API...");
|
||||
|
||||
URI url = UriComponentsBuilder
|
||||
.fromHttpUrl("https://id.twitch.tv/oauth2/token?client_id={client_id}&client_secret={client_secret}&grant_type=client_credentials")
|
||||
.fromHttpUrl(twitchAuthUrl)
|
||||
.query("client_id={client_id}").query("client_secret={client_secret}").query("grant_type=client_credentials")
|
||||
.buildAndExpand(clientId, clientSecret)
|
||||
.toUri();
|
||||
|
||||
@@ -163,7 +170,7 @@ public class IgdbWrapper {
|
||||
}
|
||||
|
||||
igdbApiClient = webclientBuilder
|
||||
.baseUrl("https://api.igdb.com/v4/")
|
||||
.baseUrl(igdbApiBaseUrl)
|
||||
.defaultHeader("Client-ID", clientId)
|
||||
.defaultHeader("Authorization", "Bearer %s".formatted(accessToken.getAccessToken()))
|
||||
.filter(WebClientConfig.fixProtobufContentTypeInterceptor())
|
||||
|
||||
@@ -4,6 +4,9 @@ gameyfin:
|
||||
file-extensions: iso, zip, rar, 7z, exe
|
||||
igdb:
|
||||
api:
|
||||
endpoints:
|
||||
auth: https://id.twitch.tv/oauth2/token
|
||||
base: https://api.igdb.com/v4/
|
||||
client-id:
|
||||
client-secret:
|
||||
max-concurrent-requests: 2
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package de.grimsi.gameyfin.igdb;
|
||||
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
class IgdbWrapperTest {
|
||||
|
||||
private static final MockWebServer igdbApiMock = new MockWebServer();
|
||||
private static final MockWebServer twitchApiMock = new MockWebServer();
|
||||
|
||||
private IgdbWrapper target;
|
||||
|
||||
@DynamicPropertySource
|
||||
static void setupProperties(DynamicPropertyRegistry registry) {
|
||||
registry.add("gameyfin.igdb.api.endpoints.base", () -> "http://localhost:%s".formatted(igdbApiMock.getPort()));
|
||||
registry.add("gameyfin.igdb.api.endpoints.auth", () -> "http://localhost:%s".formatted(twitchApiMock.getPort()));
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
static void setup() throws IOException {
|
||||
igdbApiMock.start();
|
||||
twitchApiMock.start();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void tearDown() throws IOException {
|
||||
igdbApiMock.shutdown();
|
||||
twitchApiMock.start();
|
||||
}
|
||||
|
||||
@Test
|
||||
void authenticate() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getGameById() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getGameBySlug() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void findPossibleMatchingTitles() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void searchForGameByTitle() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package de.grimsi.gameyfin.mapper;
|
||||
|
||||
import com.igdb.proto.Igdb;
|
||||
import de.grimsi.gameyfin.entities.Company;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CompanyMapperTest extends RandomMapperTest<Igdb.InvolvedCompany, Company> {
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
void toCompany() {
|
||||
Igdb.InvolvedCompany input = generateRandomInput();
|
||||
|
||||
Company output = CompanyMapper.toCompany(input);
|
||||
|
||||
assertThat(output.getSlug()).isEqualTo(input.getCompany().getSlug());
|
||||
assertThat(output.getName()).isEqualTo(input.getCompany().getName());
|
||||
assertThat(output.getLogoId()).isEqualTo(input.getCompany().getLogo().getImageId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
void toCompanies() {
|
||||
List<Igdb.InvolvedCompany> input = List.of(generateRandomInput(), generateRandomInput(), generateRandomInput());
|
||||
|
||||
List<Company> output = CompanyMapper.toCompanies(input);
|
||||
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
assertThat(output.get(i).getSlug()).isEqualTo(input.get(i).getCompany().getSlug());
|
||||
assertThat(output.get(i).getName()).isEqualTo(input.get(i).getCompany().getName());
|
||||
assertThat(output.get(i).getLogoId()).isEqualTo(input.get(i).getCompany().getLogo().getImageId());
|
||||
}
|
||||
}
|
||||
|
||||
private static Igdb.InvolvedCompany generateRandomInvolvedCompany() {
|
||||
Igdb.Company c = Igdb.Company.newBuilder()
|
||||
.setSlug(UUID.randomUUID().toString())
|
||||
.setName(UUID.randomUUID().toString())
|
||||
.setLogo(Igdb.CompanyLogo.newBuilder()
|
||||
.setImageId(UUID.randomUUID().toString())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
return Igdb.InvolvedCompany.newBuilder()
|
||||
.setCompany(c)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package de.grimsi.gameyfin.mapper;
|
||||
|
||||
import com.igdb.proto.Igdb;
|
||||
import de.grimsi.gameyfin.entities.Genre;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class GenreMapperTest extends RandomMapperTest<Igdb.Genre, Genre> {
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
void toGenre() {
|
||||
Igdb.Genre input = generateRandomInput();
|
||||
|
||||
Genre output = GenreMapper.toGenre(input);
|
||||
|
||||
assertThat(output.getSlug()).isEqualTo(input.getSlug());
|
||||
assertThat(output.getName()).isEqualTo(input.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
void toGenres() {
|
||||
List<Igdb.Genre> input = List.of(generateRandomInput(), generateRandomInput(), generateRandomInput());
|
||||
|
||||
List<Genre> output = GenreMapper.toGenres(input);
|
||||
|
||||
for (int i = 0; i < output.size(); i++) {
|
||||
assertThat(output.get(i).getSlug()).isEqualTo(input.get(i).getSlug());
|
||||
assertThat(output.get(i).getName()).isEqualTo(input.get(i).getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package de.grimsi.gameyfin.mapper;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
import org.jeasy.random.EasyRandom;
|
||||
import org.jeasy.random.EasyRandomParameters;
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RandomMapperTest<Input extends Message, Output> {
|
||||
|
||||
private static final int DEFAULT_COUNT = 5;
|
||||
private final EasyRandom easyRandom = new EasyRandom();
|
||||
|
||||
private final Class<Input> inputClass;
|
||||
private final Class<Output> outputClass;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public RandomMapperTest() {
|
||||
Class<?>[] typeArguments = GenericTypeResolver.resolveTypeArguments(getClass(), RandomMapperTest.class);
|
||||
assert typeArguments != null;
|
||||
inputClass = (Class<Input>) typeArguments[0];
|
||||
outputClass = (Class<Output>) typeArguments[1];
|
||||
}
|
||||
|
||||
protected Input generateRandomInput() {
|
||||
return easyRandom.nextObject(inputClass);
|
||||
}
|
||||
|
||||
protected List<Input> generateRandomInputs() {
|
||||
return easyRandom.objects(inputClass, DEFAULT_COUNT).toList();
|
||||
}
|
||||
|
||||
protected List<Input> generateRandomInputs(int count) {
|
||||
return easyRandom.objects(inputClass, count).toList();
|
||||
}
|
||||
|
||||
protected Output generateRandomOutput() {
|
||||
return easyRandom.nextObject(outputClass);
|
||||
}
|
||||
|
||||
protected List<Output> generateRandomOutputs() {
|
||||
return easyRandom.objects(outputClass, DEFAULT_COUNT).toList();
|
||||
}
|
||||
|
||||
protected List<Output> generateRandomOutputs(int count) {
|
||||
return easyRandom.objects(outputClass, count).toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
gameyfin:
|
||||
igdb:
|
||||
api:
|
||||
client-id: igdb_client_id
|
||||
client-secret: igdb_client_secret
|
||||
config:
|
||||
preferred-platforms: 6
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "1.2.3-SNAPSHOT",
|
||||
"version": "1.2.4-SNAPSHOT",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "frontend",
|
||||
"version": "1.2.3-SNAPSHOT",
|
||||
"version": "1.2.4-SNAPSHOT",
|
||||
"dependencies": {
|
||||
"@angular/animations": "^14.0.0",
|
||||
"@angular/cdk": "^14.1.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "1.2.3-SNAPSHOT",
|
||||
"version": "1.2.4-SNAPSHOT",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
|
||||
Reference in New Issue
Block a user