Skip to content

Commit

Permalink
feat : adds IntegrationTest for JobInvoker (#1585)
Browse files Browse the repository at this point in the history
* feat : adds IntegrationTest for JobInvoker

* adds more tests
  • Loading branch information
rajadilipkolli authored Dec 19, 2024
1 parent 8bb92f8 commit 4e35643
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion batch-boot-jpa-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
<configuration>
<java>
<googleJavaFormat>
<version>1.25.0</version>
<version>1.25.2</version>
<style>AOSP</style>
</googleJavaFormat>
<importOrder />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.assertj.MockMvcTester;

@ActiveProfiles({PROFILE_TEST})
@SpringBootTest(
Expand All @@ -19,5 +20,7 @@ public abstract class AbstractIntegrationTest {

@Autowired protected MockMvc mockMvc;

@Autowired protected MockMvcTester mockMvcTester;

@Autowired protected ObjectMapper objectMapper;
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void shouldCreateNewCustomer() throws Exception {
}

@Test
void shouldReturn400WhenCreateNewCustomerWithoutText() throws Exception {
void shouldReturn400WhenCreateNewCustomerWithoutName() throws Exception {
Customer customer = new Customer(null, null, null, null);

this.mockMvc
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.example.bootbatchjpa.web.controllers;

import com.example.bootbatchjpa.common.AbstractIntegrationTest;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;

class JobInvokerControllerIT extends AbstractIntegrationTest {

@Test
void shouldInvokeAllCustomersJob() {
mockMvcTester
.get()
.uri("/api/job/customers")
.param("minId", "0")
.param("maxId", "100")
.assertThat()
.hasStatusOk()
.hasContentType("text/plain;charset=UTF-8")
.hasBodyTextEqualTo("Batch job has been invoked as 1");
}

@Test
void shouldReturnBadRequestForMissingParameters() {
mockMvcTester
.get()
.uri("/api/job/customers")
.assertThat()
.hasStatus(HttpStatus.BAD_REQUEST);
}
}

0 comments on commit 4e35643

Please sign in to comment.