Skip to main content

All Questions

Tagged with
0 votes
0 answers
60 views

How I fix 404 error when test the spring boot using junit with m:m relationship

I am using Spring Boot 3 and have two entities: "Event" and "User". The relationship between these entities is many-to-many. A user can add many events, and an event can have many ...
Reham Almutairi's user avatar
0 votes
1 answer
75 views

not able to achieve 100% coverage on equals(object) with lombok @Data annotation

i am trying to cover more than 90% , actually trying for 100%. with all these i am getting 75% to 80% here am talking about only equals method. am i missing anything ? found one article on ...
sravan ganji's user avatar
  • 5,027
0 votes
1 answer
86 views

Stubbing void method of spybean failing

I have a void method bar in a service Foo as shown: @Component @EnableAsync @AllArgsConstructor public class Foo { private final SomeOtherService someOtherService; private final ...
zeeshan's user avatar
  • 35
3 votes
5 answers
388 views

SpringBoot Application Test Cases Error with IllegalStateException

I am trying to integrate the test case in my spring boot application and for that I have added these configs in my build.gradle plugins : { id 'jacoco' id 'org.sonarqube' version '3.3' } ...
David's user avatar
  • 4,142
0 votes
1 answer
337 views

How to start embedded redis on random available port Java Springboot

@Value("${spring.redis.embedded.port}") private int redisPort; private RedisServer redisServer; @PostConstruct public void startRedisServer() throws IOException { System.out.println(&...
Anju Singh's user avatar
0 votes
0 answers
82 views

Why does my unit test fail to recognize the regex used in my search method?

I have a program which can perform case-insensitive query searches in a repository based on a name (a given name, a last name or both). But every time I run my unit test in JUnit 5, it seems to be ...
roice343's user avatar
-1 votes
1 answer
36 views

Spring-Boot+jUnit: multiple declaration of @BootstrapWith

I'm triing to combine classes dependencies injection & JPA entity use in my jUnit tests. My app configuration Java 21 Built with Maven Spring Boot 2.7 jUnit 4.3 All my unit tests runs well with ...
Damien C's user avatar
  • 1,125
0 votes
1 answer
761 views

Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) thr

I got this error while i executed my mockito test file,here i have void main and also in the src/main/java i have another main how to resolve this error i have tried this from this website https://www....
bhargava's user avatar
-1 votes
3 answers
233 views

How to test an exception case for a method that doesn't throw the exception using JUnit & Mockito?

I am trying to test the below function for exception case, public String someMethod() { String result = "default"; try { result = a.something(); } catch (Exception e) { ...
Cams Boyfriend's user avatar
0 votes
1 answer
54 views

Nested mapping only for test create NullPointerException Junit 5

Class by class I explain why it doesn't start, thanks for your help In debug i see the list of employees until the method for-each java.lang.NullPointerException: Cannot invoke "com.fincons....
Lorenzo Gaetani's user avatar
0 votes
0 answers
23 views

Does @DataJpaTest configures correctly "updatable = false" in tests when using H2 database?

I'm asking this because even using the @Column notation over the attribute with the value "updatable = false", it still passing in the test I update it. @Column(length = 100, nullable = ...
Bicho Papão's user avatar
0 votes
1 answer
63 views

Mock testing a post method which returns the location of the newly added entity and a 201 status code, using ServletUriComponentsBuilder

@PostMapping(path= "/users/{username}/events") public ResponseEntity<Object> createEventsForUser(@PathVariable String username, @RequestBody @Valid EventBean event){ event....
Prathamesh Zingade's user avatar
1 vote
1 answer
102 views

How to check using ArchUnit if there is any use of reflection in the source code?

I want to write a JUnit Test Case using ArchUnit to check if there is usage of reflection in the source that is written by the developer and fail the test case if so. How can I achieve this using ...
Abhi's user avatar
  • 334
0 votes
1 answer
39 views

JUnit5 ExpectedValue test method is failing when run the program with Null-check test method

I have two unit test case methods: TestUserEventExpectedResult(), TestUserEventNullCheck(). My problem is when I run the program only with TestUserEventExpectedResult() method, I can get the expected ...
Jathurshan 's user avatar
0 votes
2 answers
41 views

SpringBoot Test NullPointer Exception

I am trying to test whether my SpringBoot Repository works adding the new User to database and I am getting a NullPointer Exception during the Junit test. Here is the code. User: package org.example; ...
qpwoeiruty's user avatar

15 30 50 per page
1
3 4
5
6 7
158