diff --git a/.github/workflows/build-dev-environment.yml b/.github/workflows/build-dev-environment.yml
index c2cc510..a7c0ff9 100644
--- a/.github/workflows/build-dev-environment.yml
+++ b/.github/workflows/build-dev-environment.yml
@@ -35,7 +35,7 @@ jobs:
env:
ENCRYPTION_KEY: hwJdNY1/yC3miXQR+Vw2V3qtt1e3FPJ2y62BKtROUJs=
ENCRYPTION_IV: DKKyySzj8ao5WgraQpwj+A==
- run: mvn --batch-mode clean package
+ run: mvn --batch-mode clean package -T 6
- name: Publish Package Artifacts
uses: actions/upload-artifact@v3
diff --git a/.github/workflows/build-production.yml b/.github/workflows/build-production.yml
index b330905..dd2c90c 100644
--- a/.github/workflows/build-production.yml
+++ b/.github/workflows/build-production.yml
@@ -34,7 +34,7 @@ jobs:
server-password: MAVEN_PASSWORD
- name: Publish to the Maven Central Repository
- run: mvn --batch-mode clean deploy
+ run: mvn --batch-mode clean deploy -T 6
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
@@ -64,7 +64,7 @@ jobs:
cache: maven
- name: Build with Maven
- run: mvn --batch-mode clean package
+ run: mvn --batch-mode clean package -T 6
- name: Publish Package Artifacts
uses: actions/upload-artifact@v3
diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index d2e1006..d7f2dbe 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -26,4 +26,4 @@ jobs:
cache: maven
- name: Build with Maven
- run: mvn --batch-mode --update-snapshots clean verify -Dmaven.javadoc.skip -Dgpg.skip
+ run: mvn --batch-mode --update-snapshots clean verify -Dmaven.javadoc.skip -Dgpg.skip -T 6
diff --git a/.github/workflows/sonarqube-scan.yml b/.github/workflows/sonarqube-scan.yml
index a194b1d..e7b17d4 100644
--- a/.github/workflows/sonarqube-scan.yml
+++ b/.github/workflows/sonarqube-scan.yml
@@ -47,4 +47,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=FunixProductions_FunixAPI_AYNRa2sBsXlKxBk9mU9x
+ run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=FunixProductions_FunixAPI_AYNRa2sBsXlKxBk9mU9x -T 6
diff --git a/Dockerfile b/Dockerfile
index 98f24c2..78fc731 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,7 +4,7 @@ ARG service_name
ARG service_base_dir
ENV SERVICE_NAME=${service_name}
ENV SERVICE_BASE_DIR=${service_base_dir}
-ENV APP_VERSION=1.3.0.7
+ENV APP_VERSION=1.3.0.8
WORKDIR /container/java
diff --git a/modules/core/client/pom.xml b/modules/core/client/pom.xml
index 352d804..89fedc5 100644
--- a/modules/core/client/pom.xml
+++ b/modules/core/client/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api.core
funixgaming-core
- 1.3.0.7
+ 1.3.0.8
fr.funixgaming.api.core.client
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index e932834..493c565 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api
funixgaming-api
- 1.3.0.7
+ 1.3.0.8
../../pom.xml
diff --git a/modules/core/service/pom.xml b/modules/core/service/pom.xml
index 7d92ba8..709b36c 100644
--- a/modules/core/service/pom.xml
+++ b/modules/core/service/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api.core
funixgaming-core
- 1.3.0.7
+ 1.3.0.8
fr.funixgaming.api.core.service
diff --git a/modules/core/test/pom.xml b/modules/core/test/pom.xml
index 8d98630..f4155a4 100644
--- a/modules/core/test/pom.xml
+++ b/modules/core/test/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api.core
funixgaming-core
- 1.3.0.7
+ 1.3.0.8
fr.funixgaming.api.core.test
diff --git a/modules/funixbot/client/pom.xml b/modules/funixbot/client/pom.xml
index 7f6f82c..fe650a8 100644
--- a/modules/funixbot/client/pom.xml
+++ b/modules/funixbot/client/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api.funixbot
funixgaming-funixbot
- 1.3.0.7
+ 1.3.0.8
fr.funixgaming.api.funixbot.client
diff --git a/modules/funixbot/pom.xml b/modules/funixbot/pom.xml
index 7a9f949..4f1a7b9 100644
--- a/modules/funixbot/pom.xml
+++ b/modules/funixbot/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api
funixgaming-api
- 1.3.0.7
+ 1.3.0.8
../../pom.xml
diff --git a/modules/funixbot/service/pom.xml b/modules/funixbot/service/pom.xml
index bffb20c..fb94b0f 100644
--- a/modules/funixbot/service/pom.xml
+++ b/modules/funixbot/service/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api.funixbot
funixgaming-funixbot
- 1.3.0.7
+ 1.3.0.8
fr.funixgaming.api.funixbot.service
diff --git a/modules/twitch/client/pom.xml b/modules/twitch/client/pom.xml
index 440b4bd..0717d53 100644
--- a/modules/twitch/client/pom.xml
+++ b/modules/twitch/client/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api.twitch
funixgaming-twitch
- 1.3.0.7
+ 1.3.0.8
fr.funixgaming.api.twitch.client
diff --git a/modules/twitch/client/src/main/java/fr/funixgaming/api/twitch/client/clients/FunixGamingTwitchUserClient.java b/modules/twitch/client/src/main/java/fr/funixgaming/api/twitch/client/clients/FunixGamingTwitchUserClient.java
index f7bddd7..a8d9941 100644
--- a/modules/twitch/client/src/main/java/fr/funixgaming/api/twitch/client/clients/FunixGamingTwitchUserClient.java
+++ b/modules/twitch/client/src/main/java/fr/funixgaming/api/twitch/client/clients/FunixGamingTwitchUserClient.java
@@ -21,12 +21,10 @@ public interface FunixGamingTwitchUserClient {
/**
* Check if a user is following a streamer
* @param userId viewer id to check
- * @param streamerId streamer id to check
* @return a single element list if the user is following otherwise not following
*/
@GetMapping("isFollowing")
- TwitchDataResponseDTO isUserFollowingStreamer(@RequestParam(name = "user_id") String userId,
- @RequestParam(name = "streamer_id") String streamerId);
+ TwitchDataResponseDTO isUserFollowingStreamer(@RequestParam(name = "user_id") String userId);
@GetMapping("usersByName")
TwitchDataResponseDTO getUsersByName(@RequestParam(name = "login") List name);
diff --git a/modules/twitch/pom.xml b/modules/twitch/pom.xml
index 532a673..503112f 100644
--- a/modules/twitch/pom.xml
+++ b/modules/twitch/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api
funixgaming-api
- 1.3.0.7
+ 1.3.0.8
../../pom.xml
diff --git a/modules/twitch/service/pom.xml b/modules/twitch/service/pom.xml
index e3aa0d2..d9c2924 100644
--- a/modules/twitch/service/pom.xml
+++ b/modules/twitch/service/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api.twitch
funixgaming-twitch
- 1.3.0.7
+ 1.3.0.8
fr.funixgaming.api.twitch.service
diff --git a/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchGameResource.java b/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchGameResource.java
index b3ec3e7..8903043 100644
--- a/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchGameResource.java
+++ b/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchGameResource.java
@@ -3,6 +3,7 @@
import com.funixproductions.api.twitch.reference.client.clients.game.TwitchGameClient;
import com.funixproductions.api.twitch.reference.client.dtos.responses.TwitchDataResponseDTO;
import com.funixproductions.api.twitch.reference.client.dtos.responses.game.TwitchGameDTO;
+import com.funixproductions.core.exceptions.ApiException;
import fr.funixgaming.api.twitch.client.clients.FunixGamingTwitchGameClient;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -17,11 +18,23 @@ public class TwitchGameResource implements FunixGamingTwitchGameClient {
@Override
public TwitchDataResponseDTO getGameByName(String name) {
- return twitchGameClient.getGameByName(name);
+ try {
+ return twitchGameClient.getGameByName(name);
+ } catch (ApiException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApiException("Erreur interne: " + e.getMessage(), e);
+ }
}
@Override
public TwitchDataResponseDTO getGameById(String id) {
- return twitchGameClient.getGameById(id);
+ try {
+ return twitchGameClient.getGameById(id);
+ } catch (ApiException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApiException("Erreur interne: " + e.getMessage(), e);
+ }
}
}
diff --git a/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchStreamResource.java b/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchStreamResource.java
index c283b7a..5436eff 100644
--- a/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchStreamResource.java
+++ b/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchStreamResource.java
@@ -4,6 +4,7 @@
import com.funixproductions.api.twitch.reference.client.dtos.responses.channel.chat.TwitchChannelChattersDTO;
import com.funixproductions.api.twitch.reference.client.dtos.responses.channel.stream.TwitchStreamDTO;
import com.funixproductions.core.exceptions.ApiBadRequestException;
+import com.funixproductions.core.exceptions.ApiException;
import fr.funixgaming.api.twitch.client.clients.FunixGamingTwitchStreamClient;
import fr.funixgaming.api.twitch.service.services.DrakkadesTwitchStreamService;
import fr.funixgaming.api.twitch.service.services.FunixGamingTwitchStreamService;
@@ -21,17 +22,29 @@ public class TwitchStreamResource implements FunixGamingTwitchStreamClient {
@Override
public TwitchDataResponseDTO getStream(String channel) {
- if (channel.equals("funixgaming")) {
- return funixTwitchStreamService.getCacheStream();
- } else if (channel.equals("drakkades")) {
- return drakkadesTwitchStreamService.getCacheStream();
- } else {
- throw new ApiBadRequestException("Le nom du stream est invalide ou ne fait pas parti de la liste des streams autorisés.");
+ try {
+ if (channel.equals("funixgaming")) {
+ return funixTwitchStreamService.getCacheStream();
+ } else if (channel.equals("drakkades")) {
+ return drakkadesTwitchStreamService.getCacheStream();
+ } else {
+ throw new ApiBadRequestException("Le nom du stream est invalide ou ne fait pas parti de la liste des streams autorisés.");
+ }
+ } catch (ApiException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApiException("Erreur interne: " + e.getMessage(), e);
}
}
@Override
public TwitchDataResponseDTO getChatters(String channel) {
- return funixTwitchStreamService.getCacheChatters();
+ try {
+ return funixTwitchStreamService.getCacheChatters();
+ } catch (ApiException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApiException("Erreur interne: " + e.getMessage(), e);
+ }
}
}
diff --git a/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchUserResource.java b/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchUserResource.java
index f4676f0..f425dc2 100644
--- a/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchUserResource.java
+++ b/modules/twitch/service/src/main/java/fr/funixgaming/api/twitch/service/ressources/TwitchUserResource.java
@@ -1,10 +1,14 @@
package fr.funixgaming.api.twitch.service.ressources;
+import com.funixproductions.api.twitch.reference.client.clients.channel.TwitchChannelClient;
import com.funixproductions.api.twitch.reference.client.clients.users.TwitchUsersClient;
import com.funixproductions.api.twitch.reference.client.dtos.responses.TwitchDataResponseDTO;
import com.funixproductions.api.twitch.reference.client.dtos.responses.user.TwitchFollowDTO;
import com.funixproductions.api.twitch.reference.client.dtos.responses.user.TwitchUserDTO;
+import com.funixproductions.api.user.client.dtos.UserDTO;
+import com.funixproductions.core.exceptions.ApiException;
import fr.funixgaming.api.twitch.client.clients.FunixGamingTwitchUserClient;
+import fr.funixgaming.api.twitch.service.services.FunixGamingInformationService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -16,20 +20,42 @@
@RequiredArgsConstructor
public class TwitchUserResource implements FunixGamingTwitchUserClient {
- private final TwitchUsersClient service;
+ private final TwitchUsersClient usersClient;
+ private final TwitchChannelClient channelClient;
+ private final FunixGamingInformationService funixGamingInformationService;
@Override
- public TwitchDataResponseDTO isUserFollowingStreamer(String userId, String streamerId) {
- return service.isUserFollowingStreamer(userId, streamerId);
+ public TwitchDataResponseDTO isUserFollowingStreamer(String userId) {
+ try {
+ final UserDTO userDTO = funixGamingInformationService.getFunixGamingUser();
+
+ return channelClient.getChannelFollowers(null, null, userId, userDTO.getId().toString());
+ } catch (ApiException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApiException("Erreur interne: " + e.getMessage(), e);
+ }
}
@Override
public TwitchDataResponseDTO getUsersByName(List name) {
- return service.getUsersByName(name);
+ try {
+ return usersClient.getUsersByName(name);
+ } catch (ApiException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApiException("Erreur interne: " + e.getMessage(), e);
+ }
}
@Override
public TwitchDataResponseDTO getUsersById(List id) {
- return service.getUsersById(id);
+ try {
+ return usersClient.getUsersById(id);
+ } catch (ApiException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new ApiException("Erreur interne: " + e.getMessage(), e);
+ }
}
}
diff --git a/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchGameResourceTest.java b/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchGameResourceTest.java
index ba42ce5..b6df427 100644
--- a/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchGameResourceTest.java
+++ b/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchGameResourceTest.java
@@ -2,10 +2,14 @@
import com.funixproductions.api.twitch.reference.client.clients.chat.TwitchChatClient;
import com.funixproductions.api.twitch.reference.client.clients.game.TwitchGameClient;
+import com.funixproductions.api.twitch.reference.client.clients.stream.TwitchStreamsClient;
import com.funixproductions.api.twitch.reference.client.dtos.responses.TwitchDataResponseDTO;
+import com.funixproductions.api.user.client.clients.InternalUserCrudClient;
import com.funixproductions.api.user.client.clients.UserAuthClient;
import com.funixproductions.api.user.client.dtos.UserDTO;
import com.funixproductions.api.user.client.enums.UserRole;
+import com.funixproductions.core.crud.dtos.PageDTO;
+import fr.funixgaming.api.twitch.service.services.FunixGamingInformationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -16,10 +20,10 @@
import org.springframework.test.web.servlet.MockMvc;
import java.util.Date;
+import java.util.List;
import java.util.UUID;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -34,9 +38,18 @@ class TwitchGameResourceTest {
@MockBean
private UserAuthClient userAuthClient;
+ @MockBean
+ private InternalUserCrudClient internalUserCrudClient;
+
@MockBean
private TwitchChatClient twitchChatClient;
+ @MockBean
+ private TwitchStreamsClient twitchStreamsClient;
+
+ @Autowired
+ private FunixGamingInformationService funixGamingInformationService;
+
@Autowired
private MockMvc mockMvc;
@@ -53,6 +66,16 @@ void setupMocks() {
when(twitchGameClient.getGameById(anyString())).thenReturn(new TwitchDataResponseDTO<>());
when(userAuthClient.current(anyString())).thenReturn(userDTO);
when(twitchChatClient.getChannelChatters(anyInt(), anyString(), anyString())).thenReturn(new TwitchDataResponseDTO<>());
+ when(twitchStreamsClient.getStreams(anyString())).thenReturn(new TwitchDataResponseDTO<>());
+
+ final PageDTO pageDTO = new PageDTO<>();
+ pageDTO.setActualPage(0);
+ pageDTO.setTotalPages(1);
+ pageDTO.setContent(List.of(userDTO));
+ pageDTO.setTotalElementsThisPage(1);
+ pageDTO.setTotalElementsDatabase(1L);
+ when(internalUserCrudClient.getAll(any(), any(), any(), any())).thenReturn(pageDTO);
+ funixGamingInformationService.fetchUserInfos();
}
diff --git a/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchStreamResourceTest.java b/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchStreamResourceTest.java
index 600f78e..6f19869 100644
--- a/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchStreamResourceTest.java
+++ b/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchStreamResourceTest.java
@@ -3,9 +3,12 @@
import com.funixproductions.api.twitch.reference.client.clients.chat.TwitchChatClient;
import com.funixproductions.api.twitch.reference.client.clients.stream.TwitchStreamsClient;
import com.funixproductions.api.twitch.reference.client.dtos.responses.TwitchDataResponseDTO;
+import com.funixproductions.api.user.client.clients.InternalUserCrudClient;
import com.funixproductions.api.user.client.clients.UserAuthClient;
import com.funixproductions.api.user.client.dtos.UserDTO;
import com.funixproductions.api.user.client.enums.UserRole;
+import com.funixproductions.core.crud.dtos.PageDTO;
+import fr.funixgaming.api.twitch.service.services.FunixGamingInformationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,10 +18,10 @@
import org.springframework.test.web.servlet.MockMvc;
import java.util.Date;
+import java.util.List;
import java.util.UUID;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -36,6 +39,12 @@ class TwitchStreamResourceTest {
@MockBean
private TwitchChatClient twitchChatClient;
+ @MockBean
+ private InternalUserCrudClient internalUserCrudClient;
+
+ @Autowired
+ private FunixGamingInformationService funixGamingInformationService;
+
@Autowired
private MockMvc mockMvc;
@@ -52,6 +61,15 @@ void setupMocks() {
userDTO.setUsername("toto");
when(userAuthClient.current(anyString())).thenReturn(userDTO);
+
+ final PageDTO pageDTO = new PageDTO<>();
+ pageDTO.setActualPage(0);
+ pageDTO.setTotalPages(1);
+ pageDTO.setContent(List.of(userDTO));
+ pageDTO.setTotalElementsThisPage(1);
+ pageDTO.setTotalElementsDatabase(1L);
+ when(internalUserCrudClient.getAll(any(), any(), any(), any())).thenReturn(pageDTO);
+ funixGamingInformationService.fetchUserInfos();
}
@Test
diff --git a/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchUserResourceTest.java b/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchUserResourceTest.java
index 6d894f6..289e308 100644
--- a/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchUserResourceTest.java
+++ b/modules/twitch/service/src/test/java/fr/funixgaming/api/twitch/service/ressources/TwitchUserResourceTest.java
@@ -1,11 +1,16 @@
package fr.funixgaming.api.twitch.service.ressources;
+import com.funixproductions.api.twitch.reference.client.clients.channel.TwitchChannelClient;
import com.funixproductions.api.twitch.reference.client.clients.chat.TwitchChatClient;
+import com.funixproductions.api.twitch.reference.client.clients.stream.TwitchStreamsClient;
import com.funixproductions.api.twitch.reference.client.clients.users.TwitchUsersClient;
import com.funixproductions.api.twitch.reference.client.dtos.responses.TwitchDataResponseDTO;
+import com.funixproductions.api.user.client.clients.InternalUserCrudClient;
import com.funixproductions.api.user.client.clients.UserAuthClient;
import com.funixproductions.api.user.client.dtos.UserDTO;
import com.funixproductions.api.user.client.enums.UserRole;
+import com.funixproductions.core.crud.dtos.PageDTO;
+import fr.funixgaming.api.twitch.service.services.FunixGamingInformationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -16,6 +21,7 @@
import org.springframework.test.web.servlet.MockMvc;
import java.util.Date;
+import java.util.List;
import java.util.UUID;
import static org.mockito.ArgumentMatchers.*;
@@ -30,12 +36,24 @@ class TwitchUserResourceTest {
@MockBean
private TwitchUsersClient twitchUsersClient;
+ @MockBean
+ private TwitchChannelClient twitchChannelClient;
+
@MockBean
private UserAuthClient userAuthClient;
+ @MockBean
+ private InternalUserCrudClient internalUserCrudClient;
+
+ @MockBean
+ private TwitchStreamsClient twitchStreamsClient;
+
@MockBean
private TwitchChatClient twitchChatClient;
+ @Autowired
+ private FunixGamingInformationService funixGamingInformationService;
+
@Autowired
private MockMvc mockMvc;
@@ -43,21 +61,31 @@ class TwitchUserResourceTest {
void setupMocks() {
when(twitchUsersClient.getUsersById(anyList())).thenReturn(new TwitchDataResponseDTO<>());
when(twitchUsersClient.getUsersByName(anyList())).thenReturn(new TwitchDataResponseDTO<>());
- when(twitchUsersClient.isUserFollowingStreamer(anyString(), anyString())).thenReturn(new TwitchDataResponseDTO<>());
+ when(twitchChannelClient.getChannelFollowers(anyString(), anyString(), anyString(), anyString())).thenReturn(new TwitchDataResponseDTO<>());
when(twitchChatClient.getChannelChatters(anyInt(), anyString(), anyString())).thenReturn(new TwitchDataResponseDTO<>());
+ when(twitchStreamsClient.getStreams(anyString())).thenReturn(new TwitchDataResponseDTO<>());
final UserDTO userDTO = new UserDTO();
userDTO.setRole(UserRole.MODERATOR);
userDTO.setEmail("oui@gmail.com");
userDTO.setId(UUID.randomUUID());
userDTO.setCreatedAt(new Date());
- userDTO.setUsername("toto");
+ userDTO.setUsername("funix");
when(userAuthClient.current(anyString())).thenReturn(userDTO);
+
+ final PageDTO pageDTO = new PageDTO<>();
+ pageDTO.setActualPage(0);
+ pageDTO.setTotalPages(1);
+ pageDTO.setContent(List.of(userDTO));
+ pageDTO.setTotalElementsThisPage(1);
+ pageDTO.setTotalElementsDatabase(1L);
+ when(internalUserCrudClient.getAll(any(), any(), any(), any())).thenReturn(pageDTO);
}
@Test
void testIsFollowing() throws Exception {
+ funixGamingInformationService.fetchUserInfos();
mockMvc.perform(get("/twitch/user/isFollowing?user_id=123&streamer_id=456")
.header(HttpHeaders.AUTHORIZATION, "Bearer token"))
.andExpect(status().isOk());
diff --git a/pom.xml b/pom.xml
index a0a8758..e752762 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
fr.funixgaming.api
funixgaming-api
- 1.3.0.7
+ 1.3.0.8
FunixGamingAPI
Project used in Funix projects
https://github.com/FunixProductions/FunixGaming-API
@@ -15,7 +15,7 @@
com.funixproductions.api
funixproductions-api
- 1.2.2.1
+ 1.2.2.3
@@ -47,7 +47,7 @@
- 1.3.0.7
+ 1.3.0.8
${java.version}
${java.version}