Skip to content
Advertisement

Tag: spring

Prototyped bean not triggering Scheduled method in Spring Boot

I’m using Java 17, spring-boot 2.7.3 and spring 5.3.22 dependencies. I have prototyped beans as follows: My application class: I annotated the InsertTransactionDetailsByScheduleAPIInteractor also as prototype in order to have a new instance of the inner beans per schedule execution, but somehow the @Scheduled method only runs when I have a singleton InsertTransactionDetailsByScheduleAPIInteractor bean, which in my use case I

Store bearerToken until expires

I have an application that consumes a REST service from another server, which has its own authentication method to be able to consume its services. Today, for each request we have, I am calling the authentication service then i receivethe bearerToken (which has a duration of 3 hours) and after that I call the endpoint I want to use. The

Mockito not working when using Model Mapper

I have an User class: And an UpdateUserDTO class: And an UserDTO class: I’ve used Model Mapper to map the updated fields from updateUserDTO to user, which comes from the DB. My test class looks like this: But the first Mockito.when() line does not even compile, because mapper.map() is a void method, so it does not expect any return values.

Nested JSON in JSON

How can I form JSON like that: I tried creating models with one-to-one, many-to-one relationships. Controller: But I got I read about creating nodes, but didn’t understand, how integrate it with spring data. What i need to nest table Comments in table Tutorials? Answer Looks to me as if you are pretty close to the desired outcome. First of all

How can I unit-test Exception thrown inside a Lambda?

I have a method: This is how the user authorization test looks like: Is there any way to check the case when a user has entered the wrong password? In the case when I send the wrong password, it doesn’t work because given(this.repository.findByEmail(this.user.getEmail())).willReturn(Optional.of(this.user)); makes repository.findByEmail() return the result before you get to checking the password. Answer You don’t need this

Find date inside each month

In my project, in the repository, this select finds the nearest date with a currency id that is less than or equal to the date whose range I set. How can I find a date in each month that is greater than or equal to the date I want to bind, but with the condition that this date must be

Advertisement