All Questions

Tagged with
0 votes
1 answer
24 views

How to resolve @Value with resources in testing

I have the following service: @Service @RequiredArgsConstructor public class Service { @Value("${filename}") private String filename; private final Repository repository; } ...
  • 187
0 votes
0 answers
36 views

Mocking the methods of hashMap using Mockito

I am new to java, So I created this class which return if the key is present in map, and if does, it should return the value of the key, but when I testing the code using mockito its not returning the ...
0 votes
1 answer
21 views

How to test template engine while styling emails with junit and mockito, spring boot

I am sending an email with a thymeleaf template engine. When I didnt use thymeleaf, the mail Unit tests were running perfectly, but after I added thymeleaf the tests keep giving me ...
0 votes
1 answer
54 views

Mocking RestTemplate exchange returns null

I have looked at multiple posts here - one for example and tried multiple variations but still can't seem to be able to get a non-null value after mocking RestTemplate#exchange(String url, HttpMethod ...
  • 520
0 votes
1 answer
20 views

Spring Boot Repository JUnit Repository test - Issue of verify method (Cannot work)

What I just want to ask is to learn how we can use "verify" in these 2 methods. I added its usage to each method but I'm not sure whether it is right. I cannot handle with this process. How ...
  • 1,270
0 votes
0 answers
35 views

Getting java.lang.IllegalArgumentException: No Statement specified while Doing Junit Mockito, How to mock batch.flush()? from there I'm getting error

Below is my DAO class: ------------------------ Class DataDao{ public void updateStatus(List<DataVO> EvntLst, String Ind, String MessageID) { try{ BatchSqlUpdate batch = ...
  • 57
0 votes
0 answers
26 views

How to solve class cast exception with optional class when doing unit testing in Springboot app

I am using Java 8. when I am trying to return a list of type Items(user defined), it is throwing class cast exception. can you please tell me what I am doing wrong? here's the code. @ExtendWith(...
0 votes
1 answer
28 views

How do I write a junit test for a simple controller method that returns a service method call?

I am new to Spring, and also Junit testing. I would like to test this method so it increases my test line coverage. Here is the class: @RestController @RequestMapping("/") public class ...
0 votes
0 answers
26 views

Is there a way to test private method which is returning a string that is getting called from a public method and the string is written in file?

private String nameString(String name){ return string; } public void fileString(String someName){ File.write(nameString(someName).getBytes(StandartCharsets.UTF_8).StandardOpenOption.CREATE); } I am ...
0 votes
0 answers
19 views

Podam Unit Testing same instance

I've seen while I init and manufactor Pojo's in the multiple Unit tests that the Instance of pojo is the same, how can I get init different Instance for each Test . /Init PodamFactory PodamFactory ...
-1 votes
0 answers
10 views

Invalid Definition Exception

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of com.walmart.chp.pharmacy.common.health.model.HealthCheckResponse (no Creators, like default constructor, ...
0 votes
1 answer
46 views

My service test fails when I have an if statement in the class under test SpringBoot

I am writing tests from my springboot application. The class has a method getUserById which returns Optional<User>. This methos has an if statement that will check whether an row was returned ...
0 votes
1 answer
25 views

Jhipster mock always returning 0

I'm trying to test a rest controller method that returns message count. But it always returns 0. Service class is mocked before each run. The controller extends the parent controller auto generated by ...
  • 994
-1 votes
0 answers
22 views

Mock new Services and Components in existing JUnit tests

Some JUnit tests will stop working when adding new Services, Components, etc.. in your SpringBoot application. As an obvious solution you should add a mocked instanced in the broken unit tests. I am ...
0 votes
0 answers
85 views

Spring Boot 2.6.6 fails to run tests, but is able to load application

I'm currently building an Spring boot application that is meant as a middle-man between an SPA and another platform. When started normally, the applications runs, but tests always fails for some ...
  • 31

15 30 50 per page
1
2 3 4 5
135