Skip to main content

All Questions

Tagged with
0 votes
1 answer
166 views

How to write mockito test case for jdbcTemplate.batchUpdate in spring boot application?

In our spring boot application, I am trying to write mockito test case for batch insert operation method but its not working. Getting below error java.lang.NullPointerException Suppressed.org.mockito....
Rahul's user avatar
  • 131
1 vote
0 answers
1k views

Pitest plugin is not detecting junit5 dependency

I'm upgrading an old application and it has the pitest plugin to improve the unit testing. Some newer tests are junit 5, so I added the junit5 plugin. However when I run the tests, it does not detect ...
BarbetNL's user avatar
  • 455
0 votes
1 answer
113 views

MockitoJUnitRunner with SpringBoot 3.1.1

having this class: @Service @Transactional(readOnly = true) public class PdfService { private final AsAPIService asAPIService; public PdfService(AsAPIService asAPIService) { this....
Nuñito Calzada's user avatar
0 votes
1 answer
244 views

Writing unit test for multipart file?

How to write unit test case for Multipart file? @Data Class Document { String name; byte[] byteFile; } @Service public class DocService { public Document makeDocument(Multipart file, ...
Amit Kumar's user avatar
1 vote
0 answers
465 views

How to suppress staticinitialization with Junit 5 and mockito without using powermock

I am facing an issue while creating Mock objects with Mockito.static method. If the class contains any static initializers , these initializers are executing while creating mocks. I don not want to ...
user3094331's user avatar
1 vote
1 answer
2k views

How to write unit test for clear all cache using cache manager

I have a method that evicts all the caches. PFB code for same: import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org....
Sweta Sharma's user avatar
  • 2,654
0 votes
0 answers
41 views

Can we mock methods also by by using mockito API in junit?

I am new to java, for curiosity I am asking, can I mock methods of another classes by using mockito, or only the classes I can mock. thanks in advance
Abhishek Lc's user avatar
0 votes
2 answers
2k views

How to write unit test for URI create in java

Below is the method I'm trying to write unit test using junit 5 @Value("${proxy.host}") private String endpoint; public Request<Void> setAwsRequestGETParameter(String ...
Sweta Sharma's user avatar
  • 2,654
10 votes
4 answers
15k views

Junit (4.12) is not executing after spring-boot 2.6.2 migration

I have migrated from Spring to Spring-boot version 2.6.2. mvn clean install is successful but none of the junit(version 4.12) is executing. After few research I got to know that Spring-boot 2.4 ...
Optimizer's user avatar
  • 225
1 vote
1 answer
5k views

How to write junit cases for @Bean for configuration classes

I have the below method in the @Configuration class and I need to write JUnit for this. Can anyone please guide me to achieve the JUnit test case? @Bean @Profile({"!test & !local"}) @...
Sdcoder's user avatar
  • 43
0 votes
1 answer
559 views

How to write Junit for if else condition under thrown exceptions from rest template

I am new in Junit. I read basics of Mockito. I am not able to figure out how to write Junit for test code coverage. I am using rest template calls to receive response object for requests sent. I am ...
Ag863's user avatar
  • 47
1 vote
1 answer
1k views

Parameterized junit test of custom validation in springboot

I have this validator in springboot which gives error when an integer is not between 1 and 3 and i am using addConstraintViolation to print a message from properties file public class SizeValidator ...
Catalina's user avatar
  • 693
1 vote
3 answers
821 views

How to write Junit Test Cases in springBoot?

Thid is my mapping from my controller class , now I want to write unit test case for the same @GetMapping(value = "/tokenSearch/{id}/{name}/{values}/{data_name}", produces = MediaType....
user avatar
0 votes
1 answer
337 views

How to Test Spring MVC along with repository MongoDb

Can someone please help me with junit testing of service, controller and repository. I'm getting lots of error when I write test cases for service and controller class. This is my service class import ...
Bhavya's user avatar
  • 177
1 vote
3 answers
1k views

Not able to mock a method with List type argument

I have a method like this public int[] processData(List<Data> dataList){ //business logic } And I have used the following way to mock it when(processData(anyList())).thenReturn(new int[]{1,...
Mohd. Samar's user avatar

15 30 50 per page