-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement test for ResourceType (#519)
* Implement test for ResourceType * Add the sunfire plugin * Improve the test code * Fix double slash
- Loading branch information
1 parent
7c1a067
commit 1862d9e
Showing
4 changed files
with
47 additions
and
1 deletion.
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
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
29 changes: 29 additions & 0 deletions
29
hypixel-api-core/src/test/java/net/hypixel/api/TestResources.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,29 @@ | ||
package net.hypixel.api; | ||
|
||
import kong.unirest.HttpResponse; | ||
import kong.unirest.JsonNode; | ||
import kong.unirest.Unirest; | ||
import net.hypixel.api.util.ResourceType; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class TestResources { | ||
|
||
static Stream<Arguments> getResourceTypes() { | ||
return Stream.of(ResourceType.values()) | ||
.map(Arguments::of); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("getResourceTypes") | ||
void testResource(ResourceType resourceType) { | ||
String url = String.format("%sresources/%s", HypixelAPI.BASE_URL, resourceType.getPath()); | ||
HttpResponse<JsonNode> response = Unirest.get(url).asJson(); | ||
Assertions.assertEquals(200, response.getStatus(), String.format("Got an invalid status code for %s", resourceType)); | ||
} | ||
|
||
} |
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