23
23
//
24
24
package cloud .commandframework ;
25
25
26
+ import static com .google .common .truth .Truth .assertThat ;
27
+
26
28
import cloud .commandframework .arguments .standard .IntegerArgument ;
27
29
import cloud .commandframework .execution .CommandExecutionCoordinator ;
28
30
import cloud .commandframework .keys .SimpleCloudKey ;
33
35
import cloud .commandframework .permission .OrPermission ;
34
36
import cloud .commandframework .permission .Permission ;
35
37
import cloud .commandframework .permission .PredicatePermission ;
36
- import org .junit . jupiter . api . Assertions ;
38
+ import org .checkerframework . checker . nullness . qual . NonNull ;
37
39
import org .junit .jupiter .api .BeforeAll ;
38
40
import org .junit .jupiter .api .Test ;
39
41
42
44
import java .util .concurrent .atomic .AtomicBoolean ;
43
45
44
46
import static org .junit .jupiter .api .Assertions .assertFalse ;
47
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
45
48
import static org .junit .jupiter .api .Assertions .assertTrue ;
46
49
47
50
class CommandPermissionTest {
@@ -58,16 +61,18 @@ static void setup() {
58
61
59
62
@ Test
60
63
void testCompoundPermission () {
61
- Assertions . assertTrue (manager .suggest (new TestCommandSender (), "t" ).isEmpty () );
62
- assertFalse (manager .suggest (new TestCommandSender ("test.permission.four" ), "t" ). isEmpty () );
64
+ assertThat (manager .suggest (new TestCommandSender (), "t" )) .isEmpty ();
65
+ assertThat (manager .suggest (new TestCommandSender ("test.permission.four" ), "t" )). isNotEmpty ( );
63
66
}
64
67
65
68
@ Test
66
69
void testComplexPermissions () {
67
70
manager .command (manager .commandBuilder ("first" ).permission ("first" ));
68
71
manager .command (manager .commandBuilder ("first" ).argument (IntegerArgument .of ("second" )).permission ("second" ));
72
+
69
73
manager .executeCommand (new TestCommandSender (), "first" ).join ();
70
- Assertions .assertThrows (
74
+
75
+ assertThrows (
71
76
CompletionException .class ,
72
77
() -> manager .executeCommand (new TestCommandSender (), "first 10" ).join ()
73
78
);
@@ -77,10 +82,12 @@ void testComplexPermissions() {
77
82
void testAndPermissions () {
78
83
final CommandPermission test = Permission .of ("one" ).and (Permission .of ("two" ));
79
84
final TestCommandSender sender = new TestCommandSender ("one" );
80
- assertFalse (manager .hasPermission (sender , test ));
81
- assertFalse (manager .hasPermission (new TestCommandSender ("two" ), test ));
85
+
86
+ assertThat (manager .hasPermission (sender , test )).isFalse ();
87
+ assertThat (manager .hasPermission (new TestCommandSender ("two" ), test )).isFalse ();
88
+
82
89
sender .addPermission ("two" );
83
- assertTrue (manager .hasPermission (sender , test ));
90
+ assertThat (manager .hasPermission (sender , test )). isTrue ( );
84
91
}
85
92
86
93
@ Test
@@ -126,7 +133,7 @@ void testPredicatePermissions() {
126
133
manager .executeCommand (new TestCommandSender (), "predicate" ).join ();
127
134
// Now we force it to fail
128
135
condition .set (false );
129
- Assertions . assertThrows (
136
+ assertThrows (
130
137
CompletionException .class ,
131
138
() -> manager .executeCommand (new TestCommandSender (), "predicate" ).join ()
132
139
);
@@ -141,7 +148,7 @@ private PermissionOutputtingCommandManager() {
141
148
142
149
@ Override
143
150
public boolean hasPermission (
144
- final TestCommandSender sender ,
151
+ final @ NonNull TestCommandSender sender ,
145
152
final String permission
146
153
) {
147
154
if (permission .equalsIgnoreCase ("first" )) {
@@ -154,7 +161,7 @@ public boolean hasPermission(
154
161
}
155
162
156
163
@ Override
157
- public CommandMeta createDefaultCommandMeta () {
164
+ public @ NonNull CommandMeta createDefaultCommandMeta () {
158
165
return SimpleCommandMeta .empty ();
159
166
}
160
167
0 commit comments