-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
130 additions
and
116 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
17 changes: 17 additions & 0 deletions
17
src/main/java/pl/amazingcode/threadscollider/Processors.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,17 @@ | ||
package pl.amazingcode.threadscollider; | ||
|
||
/** Number of processors available to the Java virtual machine. */ | ||
public final class Processors { | ||
|
||
/** Use all available processors. */ | ||
public static final int ALL = Runtime.getRuntime().availableProcessors(); | ||
|
||
/** Use half of available processors. */ | ||
public static final int HALF = ALL / 2; | ||
|
||
/** Use one third of available processors. */ | ||
public static final int ONE_THIRD = ALL / 3; | ||
|
||
/** Use one quarter of available processors. */ | ||
public static final int ONE_QUARTER = ALL / 4; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/test/java/pl/amazingcode/threadscollider/Action_Scenarios.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,24 @@ | ||
package pl.amazingcode.threadscollider; | ||
|
||
import static org.assertj.core.api.BDDAssertions.catchThrowable; | ||
import static org.assertj.core.api.BDDAssertions.then; | ||
|
||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
import org.junit.jupiter.api.DisplayNameGenerator; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) | ||
final class Action_Scenarios { | ||
|
||
@Test | ||
void Report_error_on_times_smaller_than_1() { | ||
|
||
// When | ||
Throwable throwable = catchThrowable(() -> Action.of(() -> {}, "action", 0)); | ||
|
||
// Then | ||
then(throwable) | ||
.isInstanceOf(IllegalArgumentException.class) | ||
.hasMessage("Repeat action at least once."); | ||
} | ||
} |
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
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.