Skip to content

Commit 75a080c

Browse files
committed
test(api): add a test for BoxAPI#api
1 parent ec59d24 commit 75a080c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package net.okocraft.box.api;
2+
3+
import org.junit.jupiter.api.Assertions;
4+
import org.junit.jupiter.api.Test;
5+
import org.mockito.Mockito;
6+
7+
class BoxAPITest {
8+
9+
@Test
10+
void testObtainingAPI() {
11+
try {
12+
// First, checking if the BoxAPI is not set.
13+
Assertions.assertFalse(BoxAPI.isLoaded());
14+
Assertions.assertThrows(IllegalStateException.class, BoxAPI::api);
15+
16+
// Set dummy BoxAPI
17+
BoxProvider.API = Mockito.mock(BoxAPI.class);
18+
19+
// Checking if the BoxAPI can be obtained.
20+
Assertions.assertTrue(BoxAPI.isLoaded());
21+
Assertions.assertDoesNotThrow(BoxAPI::api);
22+
Assertions.assertSame(BoxProvider.API, BoxAPI.api());
23+
} finally {
24+
BoxProvider.API = null;
25+
}
26+
}
27+
28+
}

0 commit comments

Comments
 (0)