File tree 1 file changed +17
-0
lines changed
wrappers/bukkit/src/test/java/it/angrybear/yagl
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 26
26
import org .junit .jupiter .params .provider .EnumSource ;
27
27
import org .junit .jupiter .params .provider .MethodSource ;
28
28
import org .mockito .ArgumentCaptor ;
29
+ import org .mockito .MockedStatic ;
29
30
30
31
import java .lang .reflect .Field ;
32
+ import java .lang .reflect .Method ;
31
33
import java .util .ArrayList ;
32
34
import java .util .Collections ;
33
35
import java .util .List ;
@@ -389,6 +391,21 @@ void testInvalidDataType() {
389
391
assertThrowsExactly (IllegalArgumentException .class , () -> WrappersAdapter .convertOption (MockDataType .class , "String" ));
390
392
}
391
393
394
+ @ Test
395
+ void testItemModuleNotProvided () {
396
+ try (MockedStatic <WrappersAdapter > clazz = mockStatic (WrappersAdapter .class )) {
397
+ clazz .when (() -> {
398
+ Method method = WrappersAdapter .class .getDeclaredMethod ("getItemUtils" );
399
+ ReflectionUtils .setAccessible (method ).invoke (WrappersAdapter .class );
400
+ }).thenReturn (null );
401
+ clazz .when (() -> WrappersAdapter .itemToItemStack (any ())).thenCallRealMethod ();
402
+
403
+ assertThrowsExactly (IllegalStateException .class , () -> WrappersAdapter .itemToItemStack (null ),
404
+ "Expected exception to be thrown signaling missing item module, but nothing was thrown" );
405
+
406
+ }
407
+ }
408
+
392
409
private static void initializeBlockData () {
393
410
Server server = mock (Server .class );
394
411
when (server .createBlockData (any (Material .class ), any (String .class ))).thenReturn (mock (BlockData .class ));
You can’t perform that action at this time.
0 commit comments