TestCoverage #2

Open
n8n.gitea wants to merge 2 commits from bot_featuretest into main
3 changed files with 33 additions and 6 deletions
Showing only changes of commit 4d794afc7d - Show all commits
+2
View File
@@ -26,6 +26,8 @@ dependencies {
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-test'
testImplementation 'org.springframework.boot:spring-boot-test-autoconfigure'
}
tasks.named('test') {
@@ -3,7 +3,12 @@ package de.dev089.eventproducer;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
@SpringBootTest(properties = {
"RABBITMQ_HOST=localhost",
"RABBITMQ_PORT=5672",
"RABBITMQ_USERNAME=guest",
"RABBITMQ_PASSWORD=guest"
})
class EventProducerApplicationTests {
@Test
@@ -1,13 +1,18 @@
package de.dev089.eventproducer.web;
import de.dev089.eventproducer.producer.HealthRequestProducer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
@@ -20,14 +25,29 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
"RABBITMQ_USERNAME=guest",
"RABBITMQ_PASSWORD=guest"
})
@AutoConfigureMockMvc
class RequestProducerControllerIT {
@Autowired
private WebApplicationContext context;
@Autowired
private HealthRequestProducer healthRequestProducer;
private MockMvc mockMvc;
@MockBean
private HealthRequestProducer healthRequestProducer;
@BeforeEach
void setUp() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
}
@TestConfiguration
static class TestConfig {
@Bean
@Primary
HealthRequestProducer healthRequestProducer() {
return Mockito.mock(HealthRequestProducer.class);
}
}
@Test
void postPopulate_acceptsValidRequest() throws Exception {