This commit is contained in:
Lee 2024-04-08 07:20:25 +01:00
parent 0b52fe939c
commit ed91afe3ee
8 changed files with 105 additions and 32 deletions

View File

@ -14,6 +14,15 @@ jobs:
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'eclipse-temurin'
- name: Run Tests
run: mvn --batch-mode test
- name: Push to dokku
uses: dokku/github-action@master
with:

30
pom.xml
View File

@ -66,11 +66,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
@ -88,6 +83,31 @@
<version>5.3.1</version>
<scope>compile</scope>
</dependency>
<!-- Unit Tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>6.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -3,6 +3,7 @@ package cc.fascinated.model.player;
import cc.fascinated.model.mojang.MojangProfile;
import cc.fascinated.util.Tuple;
import cc.fascinated.util.UUIDUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import java.util.UUID;
@ -16,8 +17,9 @@ public class Player {
private final UUID uuid;
/**
* The name of the player
* The username of the player
*/
@JsonProperty("username")
private final String name;
/**

View File

@ -104,6 +104,15 @@ public class Skin {
*/
private final int defaultSize;
/**
* Gets the name of the part.
*
* @return the name of the part
*/
public String getName() {
return this.name().toLowerCase();
}
/**
* Gets the skin part from its name.
*

View File

@ -0,0 +1,40 @@
package cc.fascinated;
import cc.fascinated.model.player.Skin;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@AutoConfigureMockMvc
@SpringBootTest
class PlayerControllerTests {
@Autowired
private MockMvc mockMvc;
@Test
public void testPlayerLookup() throws Exception {
mockMvc.perform(get("/player/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.username").value("ImFascinated"));
}
@Test
public void testPlayerPartsLookup() throws Exception {
for (Skin.Parts part : Skin.Parts.values()) {
mockMvc.perform(get("/player/" + part.getName() + "/eeab5f8a-18dd-4d58-af78-2b3c4543da48")
.accept(MediaType.IMAGE_PNG)
.contentType(MediaType.IMAGE_PNG))
.andExpect(status().isOk());
}
}
}

View File

@ -1,16 +1,2 @@
cc\fascinated\player\impl\Skin.class
cc\fascinated\Main.class
cc\fascinated\player\impl\SkinPart.class
cc\fascinated\mojang\types\MojangSessionServerProfileProperties.class
cc\fascinated\mojang\MojangAPIService$1.class
cc\fascinated\mojang\types\MojangApiProfile.class
cc\fascinated\player\impl\Player.class
cc\fascinated\mojang\MojangAPIService$2.class
cc\fascinated\player\impl\SkinType.class
cc\fascinated\player\impl\Cape.class
cc\fascinated\player\PlayerManagerService.class
cc\fascinated\util\UUIDUtils.class
cc\fascinated\mojang\types\MojangSessionServerProfile.class
cc\fascinated\mojang\MojangAPIService.class
cc\fascinated\Consts.class
cc\fascinated\api\controller\PlayerController.class

View File

@ -1,14 +1,20 @@
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\mojang\types\MojangSessionServerProfileProperties.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\player\impl\Player.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\player\impl\SkinType.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\player\impl\Cape.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\player\impl\Skin.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\mojang\types\MojangSessionServerProfile.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\mojang\MojangUsernameToUuid.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\service\PlayerService.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\mojang\MojangProfile.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\response\Response.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\controller\HomeController.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\player\Player.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\log\TransactionLogger.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\IPUtils.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\config\Config.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\controller\PlayerController.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\exception\ExceptionControllerAdvice.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\Main.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\player\PlayerManagerService.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\mojang\types\MojangApiProfile.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\player\Cape.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\service\MojangAPIService.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\UUIDUtils.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\Consts.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\player\impl\SkinPart.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\mojang\MojangAPIService.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\api\controller\PlayerController.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\player\Skin.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\Tuple.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\WebRequest.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\model\response\impl\PlayerNotFoundResponse.java
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\main\java\cc\fascinated\util\PlayerUtils.java

View File

@ -0,0 +1 @@
C:\Users\Liam\Desktop\Projects\Minecraft-Helper\src\test\java\cc\fascinated\PlayerControllerTests.java