All Questions
Tagged with junit spring-boot
2,368
questions
0
votes
0
answers
9
views
JUnit test failing Status expected:<201> but was:<404>
I've spent a lot of time trying to figure out this issue, but when I'm running my tests on my UserControllerTest class I'm getting Status expected:<201> but was:<404>.
Here's my ...
0
votes
0
answers
13
views
I'm trying to work testcode about Java Spring Boot 6.x Websocket code with STOMP but in trouble
public class WebSocketIntegrationTest {
@LocalServerPort
private int port;
@Autowired
private MockMvc mockMvc;
@Autowired
private ObjectMapper objectMapper;
private ...
1
vote
0
answers
42
views
SpringBootTest with Togglz
I just recently added togglz to the spring-boot 3.1.9 application, which contains also much stuff like spring-security, spring-data, etc.
Maven dependency:
<dependency>
<groupId>org....
0
votes
0
answers
22
views
Dependency not getting mocked in unit test
I am trying to run a unit test for my springboot controller as:
@WebMvcTest(controllers = MyController.class)
@ExtendWith(SpringExtension.class)
public class MyControllerTest {
@Autowired
...
0
votes
0
answers
13
views
Junit expecting a 400 response but getting a 200
I am trying to test my springboot controller /save endpoint. I want to test that if you send a json request with a null agency name you should get back a 400 status and the response "Agency Name ...
0
votes
0
answers
40
views
Spring Boot microservices with JWT (Cannot run Integration test (401 Unauthorized Error))
I try to implement an example of Spring Boot microservices with JWT. I have some problem. I cannot run all integration tests of product service even if I defined bearer token in terms of admin and ...
-1
votes
2
answers
63
views
How to write a unit test with a controller method that has protected code in it [duplicate]
I am trying to write a unit test for the following controller:
@RestController
@RequestMapping(value = ENDPOINT_URL)
public class MainController extends RestControllerBase {
MainService ...
0
votes
1
answer
49
views
How to use class member variables inside Junit-Mockito tests
class MyClass {
MyErrorServiceList myErrorServiceList; // myErrorServiceList is initialized by some complex method calls
public boolean processErrorServiceList() {
if (...
0
votes
0
answers
34
views
I created a test case method named 'testRegisterCustomerSuccess,' but it encountered issues related to JPA queries
I have a method named registerCustomer in a service implementation class. I created a test case named testRegisterCustomerSuccess for this method in a class named UserServiceImplTest, where I mock ...
0
votes
0
answers
34
views
Mock WebClient webflux bean with Qualifier
I have the following scenario:
A config class with two WebClient beans with different names
public class WebClientConfig {
@Bean("bean_1)
public WebClient getWebClient1(WebClient.Builder ...
0
votes
1
answer
81
views
Unable to pass multipart file through mockMvc
I am writing junit test for my request method. Im using mockMvc to trigger the rest request.
When I run my test I get the error
java.lang.NullPointerException: Cannot invoke "org.springframework....
0
votes
0
answers
32
views
Junit for GCS files reading in spring boot
I have an application in spring boot where I am fetching multiple files from GCS and then iterate to read file content. I am able to mock gcs storage but not able to mock the file content. I want to ...
1
vote
1
answer
38
views
Sprinboot api application performance test
I want to test the performance of my backend REST API application written with Spring Boot under high requests.
How can I perform this process?
Which tools should I use and what should I do step by ...
0
votes
2
answers
56
views
Junit local object mock with arguments
I want to use mockito for mocking the constructor call when a specific argument is passed.
Lets say this is my class -
public class MyTestClass {
private final String argument;
public ...
0
votes
0
answers
40
views
Spring Boot test: Why is my response body empty when testing a POST request?
I'm trying to test a POST endpoint in my Spring Boot application that creates a ChallengeReport. However, the response body is always empty, even though the status code is correct. I need help ...