From 40496cd64dfbd039945a7ca113f13f211d8047e1 Mon Sep 17 00:00:00 2001 From: Peridot Date: Tue, 18 Jul 2023 16:38:34 +0200 Subject: [PATCH] Don't use random in a handler test --- .../inject/DependencyInjectionHandlerTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/di/src/test/java/org/panda_lang/utilities/inject/DependencyInjectionHandlerTest.java b/di/src/test/java/org/panda_lang/utilities/inject/DependencyInjectionHandlerTest.java index 13cff19..1a42857 100644 --- a/di/src/test/java/org/panda_lang/utilities/inject/DependencyInjectionHandlerTest.java +++ b/di/src/test/java/org/panda_lang/utilities/inject/DependencyInjectionHandlerTest.java @@ -20,7 +20,7 @@ public class DependencyInjectionHandlerTest { @Injectable @Retention(RetentionPolicy.RUNTIME) - @interface AwesomeRandom { } + @interface TestAnnotation { } public static class Service1 { @@ -32,7 +32,7 @@ public static class Service1 { public int fieldTwo; @Inject - @AwesomeRandom + @TestAnnotation public int fieldThree; @PostConstruct @@ -40,7 +40,7 @@ public void construct() { assertEquals("HelloWorld", this.fieldOne); assertEquals(7, this.fieldTwo); - assertTrue(this.fieldTwo >= 2 && this.fieldTwo <= 10); + assertEquals(2, this.fieldThree); } } @@ -50,11 +50,11 @@ void shouldCreateInstance() { Injector injector = DependencyInjection.createInjector(resources -> { resources.annotatedWith(Custom.class).assignHandler((type, annotation, args) -> "HelloWorld"); resources.on(int.class).assignHandler((type, annotation, args) -> { - AwesomeRandom randomAnnotation = type.getAnnotation(AwesomeRandom.class); - if (randomAnnotation == null) { + TestAnnotation testAnnotation = type.getAnnotation(TestAnnotation.class); + if (testAnnotation == null) { return 7; } - return ThreadLocalRandom.current().nextInt(2, 10); + return 2; }); });