// Path: src/test/java/com/mpalourdio/springboottemplate/AbstractTestRunner.java
// @ExtendWith(SpringExtension.class)
// @TestPropertySource(locations = "classpath:test.properties")
// @Import({BeansFactory.class})
// public abstract class AbstractTestRunner {
// 
//     protected Task task;
//     protected People people;
// 
//     protected void initializeData() {
//         task = new Task();
//         task.setTaskArchived(true);
//         task.setTaskName("name");
//         task.setTaskDescription("description");
//         task.setTaskPriority("LOW");
//         task.setTaskStatus("ACTIVE");
// 
//         people = new People()
//                 .setName("john")
//                 .setTask(task);
//     }
// 
//     protected String serializeToJson(Object object) throws JsonProcessingException {
//         return new ObjectMapper().writeValueAsString(object);
//     }
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/model/Dummy.java
// public class Dummy {
// 
//     public String name;
//     @JsonIgnore
//     public String desc;
// 
//     public Dummy(String name, String desc) {
//         this.name = name;
//         this.desc = desc;
//     }
// }


import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mpalourdio.springboottemplate.AbstractTestRunner;
import com.mpalourdio.springboottemplate.model.Dummy;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.lang.reflect.Type;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
/*
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.mpalourdio.springboottemplate.controllers;




@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@AutoConfigureMockMvc
@AutoConfigureTestDatabase
class PersistenceControllerTest extends AbstractTestRunner {

    @Autowired
    private EntityManager entityManager;

    @Autowired
    private MockMvc mvc;

    @BeforeEach
    void setUp() {
        initializeData();
    }

    @Test
    @Transactional
    void testHydrationWithJsonIgnoreProperty() throws Exception {

        entityManager.persist(task);
        entityManager.persist(people);

        var mvcResult = mvc.perform(get("/hydrate")).andReturn();

        var gson = new Gson();
// Path: src/test/java/com/mpalourdio/springboottemplate/AbstractTestRunner.java
// @ExtendWith(SpringExtension.class)
// @TestPropertySource(locations = "classpath:test.properties")
// @Import({BeansFactory.class})
// public abstract class AbstractTestRunner {
// 
//     protected Task task;
//     protected People people;
// 
//     protected void initializeData() {
//         task = new Task();
//         task.setTaskArchived(true);
//         task.setTaskName("name");
//         task.setTaskDescription("description");
//         task.setTaskPriority("LOW");
//         task.setTaskStatus("ACTIVE");
// 
//         people = new People()
//                 .setName("john")
//                 .setTask(task);
//     }
// 
//     protected String serializeToJson(Object object) throws JsonProcessingException {
//         return new ObjectMapper().writeValueAsString(object);
//     }
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/model/Dummy.java
// public class Dummy {
// 
//     public String name;
//     @JsonIgnore
//     public String desc;
// 
//     public Dummy(String name, String desc) {
//         this.name = name;
//         this.desc = desc;
//     }
// }


// Path: src/test/java/com/mpalourdio/springboottemplate/controllers/PersistenceControllerTest.java
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mpalourdio.springboottemplate.AbstractTestRunner;
import com.mpalourdio.springboottemplate.model.Dummy;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.lang.reflect.Type;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;

/*
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.mpalourdio.springboottemplate.controllers;




@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@AutoConfigureMockMvc
@AutoConfigureTestDatabase
class PersistenceControllerTest extends AbstractTestRunner {

    @Autowired
    private EntityManager entityManager;

    @Autowired
    private MockMvc mvc;

    @BeforeEach
    void setUp() {
        initializeData();
    }

    @Test
    @Transactional
    void testHydrationWithJsonIgnoreProperty() throws Exception {

        entityManager.persist(task);
        entityManager.persist(people);

        var mvcResult = mvc.perform(get("/hydrate")).andReturn();

        var gson = new Gson();
        var unserializationType = new TypeToken<List<Dummy>>() {