Add integration test for RecurringTransactionController.getAll()
Also adjust .gitignore to ignore financer.log* because of rotation
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
financer.log
|
financer.log*
|
||||||
.attach*
|
.attach*
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package de.financer.controller.integration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import de.financer.FinancerApplication;
|
||||||
|
import de.financer.model.RecurringTransaction;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
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.http.MediaType;
|
||||||
|
import org.springframework.test.context.TestPropertySource;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = FinancerApplication.class)
|
||||||
|
@AutoConfigureMockMvc
|
||||||
|
@TestPropertySource(
|
||||||
|
locations = "classpath:application-integrationtest.properties")
|
||||||
|
public class RecurringTransactionService_getAllIntegrationTest {
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_getAll() throws Exception {
|
||||||
|
final MvcResult mvcResult = this.mockMvc
|
||||||
|
.perform(get("/recurringTransactions/getAll").contentType(MediaType.APPLICATION_JSON))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andReturn();
|
||||||
|
|
||||||
|
final List<RecurringTransaction> allRecurringTransactions = this.objectMapper
|
||||||
|
.readValue(mvcResult.getResponse().getContentAsByteArray(), new TypeReference<List<RecurringTransaction>>() {});
|
||||||
|
|
||||||
|
Assert.assertEquals(2, allRecurringTransactions.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user