Romans
Explore posts from serversDIAdiscord.js - Imagine an appSMSatisfactory ModdingJCHJava Community | Help. Code. Learn.TIPThe Iris ProjectDHDistant Horizons
JCHJava Community | Help. Code. Learn.
•Created by Romans on 10/24/2024 in #java-help
[Sping Boot/Mockito/Junit] Lombok Coverege testing
Hello!
I'm doing Tests with Mockito, Spring Boot and Lombok.
Someone knows how to test a simple class base with only attributes, that is marked with @Data?
- I've put all the setters and getters for all attributes (except id).
- Ive set the toString().
- then created 3 instances and set for eachone a different name.
- se the .equals from then (the first with itself), first with second, second with third, first with third.
- the put for each instance the .hashCode().
- put the .canEqual as the equals.
Running the coverage it still gives
Line: 100% 9/9 Branch: 30% 16/52
And the @ Data is marked as "Partial"
Someone have tips on how could i fill the Branch?
(if i remove all the equals, can equal and hascode it goes 0/52)
Thank you so much4 replies
JCHJava Community | Help. Code. Learn.
•Created by Romans on 10/7/2024 in #java-help
Spring(Boot) Security preauthorize auth return 200 on "false" instead of 403
Hello! Hope this is the right section .I've a "problem" with spring boot and spring security.
In controllers i've the classic
@PreAuthorize("hasAnyAuthority(....)")
.
I would like to receive the error 403 (in order to redirect to the 403.ftlh in case of no authentication).
Just now instead if i open the page that does not pass the @PreAuthorize, returns the page with status 200, but blank, for because any api in the controlled is executed (correctly).
I tried to put in the security config an http.executionHandling() but it won't execute anyway.
The basic requests i've is:
But still get 200 (and blank page) opening that page10 replies
JCHJava Community | Help. Code. Learn.
•Created by Romans on 7/16/2024 in #java-help
Spring Boot @Mapping gives no read accessor error
Hello! I'm trying to use @mapping to map a DTo from entities
My Main DTO is
DTOs:
Entities:
On an other file i set ans use the entities on repos, then i want to return the MainDTO:
then i got problems on mapping them:
- If in main i've:
MainDTO mDTO(ProjectEntity projEntity, SecondEntity sEntity, TaskEntity tEntity);
it returns correctly filled the ProjectDTO and TaskDTO, except for the ProjectDTO Second, that is null.
- If i try
works, it fill the Second, but the rest of projectDTO is empty (TaskDTO is filled).
- If i try something like
or
it gives the error:
java: no read accessor for property "project" in tagret type
Someone has tips for this? THank you so much8 replies