From 402b106b18b6e877523fd9ed527e7b49b0e88d72 Mon Sep 17 00:00:00 2001 From: Benjamin Asbach Date: Mon, 23 Oct 2023 02:37:04 +0200 Subject: [PATCH] Replaced constructor based injection with setter based injection The CDI spec requires a normal scoped bean to be proxyable which requires the bean to provide a no-arg constructor [1]. [1]: https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0#unproxyable Fixes #165 --- .../internal/validation/boundary/TransactionalValidator.java | 5 ++--- src/test/java/io/xlate/jsonapi/rvp/JsonApiResourceTest.java | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/xlate/jsonapi/rvp/internal/validation/boundary/TransactionalValidator.java b/src/main/java/io/xlate/jsonapi/rvp/internal/validation/boundary/TransactionalValidator.java index deee1a8..41f805b 100644 --- a/src/main/java/io/xlate/jsonapi/rvp/internal/validation/boundary/TransactionalValidator.java +++ b/src/main/java/io/xlate/jsonapi/rvp/internal/validation/boundary/TransactionalValidator.java @@ -16,11 +16,10 @@ @ApplicationScoped public class TransactionalValidator { - private final Validator validator; + private Validator validator; @Inject - public TransactionalValidator(Validator validator) { - super(); + public void setValidator(Validator validator) { this.validator = validator; } diff --git a/src/test/java/io/xlate/jsonapi/rvp/JsonApiResourceTest.java b/src/test/java/io/xlate/jsonapi/rvp/JsonApiResourceTest.java index cfbd2fc..4ebe91c 100644 --- a/src/test/java/io/xlate/jsonapi/rvp/JsonApiResourceTest.java +++ b/src/test/java/io/xlate/jsonapi/rvp/JsonApiResourceTest.java @@ -80,7 +80,8 @@ void setUp() { target.handlers = Mockito.mock(Instance.class); target.request = Mockito.mock(Request.class); target.security = Mockito.mock(SecurityContext.class); - target.txValidator = new TransactionalValidator(target.validator); + target.txValidator = new TransactionalValidator(); + target.txValidator.setValidator(target.validator); Mockito.when(target.handlers.iterator()).thenReturn(handlerIterator());