Skip to content

Commit

Permalink
Replaced constructor based injection with setter based injection
Browse files Browse the repository at this point in the history
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
  • Loading branch information
asbachb committed Oct 23, 2023
1 parent 358b546 commit 402b106
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/io/xlate/jsonapi/rvp/JsonApiResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit 402b106

Please sign in to comment.