-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from Treescrub/more-tests
Add more unit tests
- Loading branch information
Showing
12 changed files
with
331 additions
and
19 deletions.
There are no files selected for viewing
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
106 changes: 106 additions & 0 deletions
106
src/test/java/com/treescrub/spedran/data/GameAssetsTest.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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package com.treescrub.spedran.data; | ||
|
||
import com.treescrub.spedran.JSONLoader; | ||
import kong.unirest.json.JSONObject; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class GameAssetsTest { | ||
@Test | ||
void getLogo() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertEquals("https://www.speedrun.com/static/theme/68q122rp/logo?v=c717a0c", gameAssets.getLogo().getURI()); | ||
} | ||
|
||
@Test | ||
void getTinyCover() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertEquals("https://www.speedrun.com/static/game/9dowpe1p/cover?v=7b4712e", gameAssets.getTinyCover().getURI()); | ||
} | ||
|
||
@Test | ||
void getSmallCover() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertEquals("https://www.speedrun.com/static/game/9dowpe1p/cover?v=7b4712e", gameAssets.getSmallCover().getURI()); | ||
} | ||
|
||
@Test | ||
void getMediumCover() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertEquals("https://www.speedrun.com/static/game/9dowpe1p/cover?v=7b4712e", gameAssets.getMediumCover().getURI()); | ||
} | ||
|
||
@Test | ||
void getLargeCover() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertEquals("https://www.speedrun.com/static/game/9dowpe1p/cover?v=7b4712e", gameAssets.getLargeCover().getURI()); | ||
} | ||
|
||
@Test | ||
void getIcon() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertEquals("https://www.speedrun.com/static/theme/68q122rp/favicon?v=ad6f2ef", gameAssets.getIcon().getURI()); | ||
} | ||
|
||
@Test | ||
void getFirstTrophy() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertEquals("https://www.speedrun.com/static/theme/68q122rp/1st?v=0e9d8ee", gameAssets.getFirstTrophy().getURI()); | ||
} | ||
|
||
@Test | ||
void getSecondTrophy() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertEquals("https://www.speedrun.com/static/theme/68q122rp/2nd?v=aa0f425", gameAssets.getSecondTrophy().getURI()); | ||
} | ||
|
||
@Test | ||
void getThirdTrophy() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertEquals("https://www.speedrun.com/static/theme/68q122rp/3rd?v=38513e4", gameAssets.getThirdTrophy().getURI()); | ||
} | ||
|
||
@Test | ||
void getFourthTrophy() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertTrue(gameAssets.getFourthTrophy().isEmpty()); | ||
} | ||
|
||
@Test | ||
void getBackground() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertTrue(gameAssets.getBackground().isPresent()); | ||
assertEquals("https://www.speedrun.com/static/theme/68q122rp/background?v=e461fae", gameAssets.getBackground().get().getURI()); | ||
} | ||
|
||
@Test | ||
void getForeground() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/game/gameassets"); | ||
GameAssets gameAssets = new GameAssets(json); | ||
|
||
assertTrue(gameAssets.getForeground().isEmpty()); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.treescrub.spedran.data; | ||
|
||
import com.treescrub.spedran.JSONLoader; | ||
import kong.unirest.json.JSONObject; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class GuestTest { | ||
|
||
@Test | ||
void getName() { | ||
JSONObject json = JSONLoader.getJsonTestFile("guest"); | ||
Guest guest = new Guest(json); | ||
|
||
assertEquals("test", guest.getName()); | ||
} | ||
|
||
@Test | ||
void testEquals() { | ||
JSONObject json = JSONLoader.getJsonTestFile("guest"); | ||
Guest guest = new Guest(json); | ||
Guest sameGuest = new Guest(json); | ||
|
||
assertEquals(guest, sameGuest); | ||
} | ||
|
||
@Test | ||
void testHashCode() { | ||
JSONObject json = JSONLoader.getJsonTestFile("guest"); | ||
Guest guest = new Guest(json); | ||
Guest sameGuest = new Guest(json); | ||
|
||
assertEquals(guest.hashCode(), sameGuest.hashCode()); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/test/java/com/treescrub/spedran/data/NotificationTest.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.treescrub.spedran.data; | ||
|
||
import com.treescrub.spedran.JSONLoader; | ||
import kong.unirest.json.JSONObject; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Instant; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class NotificationTest { | ||
|
||
@Test | ||
void getCreationTime() { | ||
JSONObject json = JSONLoader.getJsonTestFile("notifications/run"); | ||
Notification notification = new Notification(json); | ||
|
||
assertEquals(Instant.parse("2024-07-24T15:32:28Z"), notification.getCreationTime()); | ||
} | ||
|
||
@Test | ||
void getStatus() { | ||
JSONObject readJson = JSONLoader.getJsonTestFile("notifications/run"); | ||
JSONObject unreadJson = JSONLoader.getJsonTestFile("notifications/post"); | ||
Notification readNotification = new Notification(readJson); | ||
Notification unreadNotification = new Notification(unreadJson); | ||
|
||
assertEquals(NotificationStatus.READ, readNotification.getStatus()); | ||
assertEquals(NotificationStatus.UNREAD, unreadNotification.getStatus()); | ||
} | ||
|
||
@Test | ||
void getNotificationText() { | ||
JSONObject json = JSONLoader.getJsonTestFile("notifications/run"); | ||
Notification notification = new Notification(json); | ||
|
||
assertEquals("A new run is waiting for verification in Left 4 Dead 2 Dead Center Solo - Any Difficulty", notification.getNotificationText()); | ||
} | ||
|
||
@Test | ||
void getItemLink() { | ||
JSONObject json = JSONLoader.getJsonTestFile("notifications/post"); | ||
Notification notification = new Notification(json); | ||
|
||
assertTrue(notification.getItemLink().getRelation().isPresent()); | ||
assertEquals("post", notification.getItemLink().getRelation().get()); | ||
assertEquals("https://www.speedrun.com/l4d2_cc/runs/y8p9n7wz", notification.getItemLink().getURI()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/com/treescrub/spedran/data/UserAssetsTest.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.treescrub.spedran.data; | ||
|
||
import com.treescrub.spedran.JSONLoader; | ||
import kong.unirest.json.JSONObject; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class UserAssetsTest { | ||
|
||
@Test | ||
void getIcon() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/user/userassets"); | ||
UserAssets userAssets = new UserAssets(json); | ||
|
||
assertTrue(userAssets.getIcon().isEmpty()); | ||
} | ||
|
||
@Test | ||
void getSupporterIcon() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/user/userassets"); | ||
UserAssets userAssets = new UserAssets(json); | ||
|
||
assertTrue(userAssets.getSupporterIcon().isEmpty()); | ||
} | ||
|
||
@Test | ||
void getAvatar() { | ||
JSONObject json = JSONLoader.getJsonTestFile("l4d/user/userassets"); | ||
UserAssets userAssets = new UserAssets(json); | ||
|
||
assertTrue(userAssets.getAvatar().isPresent()); | ||
assertEquals("https://www.speedrun.com/static/user/zx721w08/image?v=0705d37", userAssets.getAvatar().get().getURI()); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "test", | ||
"links": [ | ||
{ | ||
"rel": "self", | ||
"uri": "https://www.speedrun.com/api/v1/guests/test" | ||
}, | ||
{ | ||
"rel": "runs", | ||
"uri": "https://www.speedrun.com/api/v1/runs?guest=test" | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"logo": { | ||
"uri": "https://www.speedrun.com/static/theme/68q122rp/logo?v=c717a0c" | ||
}, | ||
"cover-tiny": { | ||
"uri": "https://www.speedrun.com/static/game/9dowpe1p/cover?v=7b4712e" | ||
}, | ||
"cover-small": { | ||
"uri": "https://www.speedrun.com/static/game/9dowpe1p/cover?v=7b4712e" | ||
}, | ||
"cover-medium": { | ||
"uri": "https://www.speedrun.com/static/game/9dowpe1p/cover?v=7b4712e" | ||
}, | ||
"cover-large": { | ||
"uri": "https://www.speedrun.com/static/game/9dowpe1p/cover?v=7b4712e" | ||
}, | ||
"icon": { | ||
"uri": "https://www.speedrun.com/static/theme/68q122rp/favicon?v=ad6f2ef" | ||
}, | ||
"trophy-1st": { | ||
"uri": "https://www.speedrun.com/static/theme/68q122rp/1st?v=0e9d8ee" | ||
}, | ||
"trophy-2nd": { | ||
"uri": "https://www.speedrun.com/static/theme/68q122rp/2nd?v=aa0f425" | ||
}, | ||
"trophy-3rd": { | ||
"uri": "https://www.speedrun.com/static/theme/68q122rp/3rd?v=38513e4" | ||
}, | ||
"trophy-4th": { | ||
"uri": null | ||
}, | ||
"background": { | ||
"uri": "https://www.speedrun.com/static/theme/68q122rp/background?v=e461fae" | ||
}, | ||
"foreground": { | ||
"uri": null | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"icon": { | ||
"uri":null | ||
}, | ||
"supporterIcon":null, | ||
"image": { | ||
"uri":"https://www.speedrun.com/static/user/zx721w08/image?v=0705d37" | ||
} | ||
} |
Oops, something went wrong.