-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Parser caching. * Improve performance of Argument#hashcode * Remove ConcurrentHashMap from BiHashMap. Add unit tests for async arguments initialize. * Fix BlockingArgumentResolver * Fix javadocs.
- Loading branch information
Showing
24 changed files
with
256 additions
and
88 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
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
69 changes: 69 additions & 0 deletions
69
...tations/test/dev/rollczi/litecommands/annotations/async/AsyncArgumentsInitializeTest.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,69 @@ | ||
package dev.rollczi.litecommands.annotations.async; | ||
|
||
import dev.rollczi.litecommands.argument.Argument; | ||
import dev.rollczi.litecommands.programmatic.LiteCommand; | ||
import static dev.rollczi.litecommands.programmatic.LiteProgrammatic.async; | ||
import dev.rollczi.litecommands.scheduler.SchedulerExecutorPoolImpl; | ||
import dev.rollczi.litecommands.unit.AssertExecute; | ||
import dev.rollczi.litecommands.unit.LiteCommandsTestFactory; | ||
import dev.rollczi.litecommands.unit.TestPlatform; | ||
import dev.rollczi.litecommands.unit.TestSender; | ||
import dev.rollczi.litecommands.util.FutureUtil; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.time.LocalDateTime; | ||
import java.time.Period; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class AsyncArgumentsInitializeTest { | ||
|
||
private final static List<Class<?>> ARGUMENTS_TYPES = Arrays.asList( | ||
String.class, | ||
Integer.class, | ||
Long.class, | ||
Double.class, | ||
Float.class, | ||
Byte.class, | ||
Short.class, | ||
Boolean.class, | ||
Duration.class, | ||
Period.class, | ||
Instant.class, | ||
LocalDateTime.class | ||
); | ||
|
||
@Test | ||
@DisplayName("Test for async arguments parsers initialization, should not throw any exceptions while running") | ||
void test() { | ||
LiteCommand<TestSender> command = new LiteCommand<>("test"); | ||
|
||
for (Class<?> type : ARGUMENTS_TYPES) { | ||
command.argument(async(Argument.of(type.getSimpleName(), type))); | ||
} | ||
|
||
List<CompletableFuture<AssertExecute>> futures = new ArrayList<>(); | ||
for (int i = 0; i < 50; i++) { | ||
TestPlatform platform = LiteCommandsTestFactory.startPlatform(config -> config | ||
.scheduler(new SchedulerExecutorPoolImpl("lite-commands", 10)) | ||
.commands(command) | ||
); | ||
|
||
for (int j = 0; j < 10; j++) { | ||
futures.add(platform.executeAsync("test test 1 100 1.0 1.0f 1 1 true 1s 1d 2021-01-01 00:00:00 2021-01-01 00:00:00")); | ||
} | ||
} | ||
|
||
List<AssertExecute> executes = FutureUtil.asList(futures).join(); | ||
|
||
assertThat(executes) | ||
.hasSize(500) | ||
.allSatisfy(assertExecute -> assertExecute.assertSuccess()); | ||
} | ||
|
||
} |
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
16 changes: 16 additions & 0 deletions
16
litecommands-core/src/dev/rollczi/litecommands/argument/MutableArgument.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,16 @@ | ||
package dev.rollczi.litecommands.argument; | ||
|
||
import dev.rollczi.litecommands.argument.profile.ArgumentProfile; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
@ApiStatus.Internal | ||
public interface MutableArgument<T> extends Argument<T> { | ||
|
||
@ApiStatus.Experimental | ||
@ApiStatus.Internal | ||
<P extends ArgumentProfile<P>> Argument<T> addProfile(P profile); | ||
|
||
@ApiStatus.Internal | ||
void setKey(ArgumentKey key); | ||
|
||
} |
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
Oops, something went wrong.