Skip to content

Commit

Permalink
clean up fxgl-test, AlmasB#897
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmasB committed Jan 9, 2021
1 parent 04dff4e commit 79156d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fxgl-test/src/main/java/com/almasb/fxgl/test/InjectInTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import java.util.Map;

/**
* Helper class that allows injecting values into fields in test environments.
*
* @author Almas Baimagambetov ([email protected])
*/
public class InjectInTest {
public final class InjectInTest {

private InjectInTest() {}

Expand All @@ -38,13 +40,13 @@ public static void inject(MethodHandles.Lookup lookup, Object instance, String f
}

/**
* Convenience method to mass inject multiple values
* Convenience method to mass inject multiple values.
*
* @param lookup the lookup created by the module where class of instance lives
* @param instance object to inject to
* @param fieldsMap Map of field names of instances and values to inject
* @param fieldsMap map of field names of instances and values to inject
*/
public static void inject(MethodHandles.Lookup lookup, Object instance, Map<String, Object> fieldsMap) {
fieldsMap
.forEach((key, value) -> inject(lookup, instance, key, value));
fieldsMap.forEach((key, value) -> inject(lookup, instance, key, value));
}
}
3 changes: 3 additions & 0 deletions fxgl-test/src/main/java/com/almasb/fxgl/test/RunWithFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import org.junit.jupiter.api.extension.ExtensionContext;

/**
* For tests that require JavaFX platform to be initialized.
* Usage: @ExtendWith(RunWithFX.class) before the test class.
*
* @author Almas Baimagambetov ([email protected])
*/
public final class RunWithFX implements BeforeAllCallback {
Expand Down

0 comments on commit 79156d1

Please sign in to comment.