// 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/json/Account.java
// public class Account implements AccountInterface {
// 
//     public String firstName;
//     public String lastName;
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/json/AccountDecorator.java
// public class AccountDecorator implements AccountInterface {
// 
//     @JsonUnwrapped
//     public Account account;
//     public Context context;
// 
//     public AccountDecorator() {
//     }
// 
//     public AccountDecorator(Account account) {
//         this.account = account;
//     }
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/json/Context.java
// public class Context {
// 
//     public String ref;
// 
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/mediatype/MediaType.java
// public final class MediaType extends org.springframework.http.MediaType {
// 
//     public static final org.springframework.http.MediaType APPLICATION_VND_API_V1;
//     public static final String APPLICATION_VND_API_V1_VALUE = "application/vnd.api.v1+json;charset=UTF-8";
// 
//     public static final org.springframework.http.MediaType APPLICATION_VND_API_V2;
//     public static final String APPLICATION_VND_API_V2_VALUE = "application/vnd.api.v2+json;charset=UTF-8";
// 
//     private MediaType(String type) {
//         super(type);
//     }
// 
//     static {
//         var applicationType = "application";
//         APPLICATION_VND_API_V1 = new org.springframework.http.MediaType(applicationType, "vnd.api.v1+json", StandardCharsets.UTF_8);
//         APPLICATION_VND_API_V2 = new org.springframework.http.MediaType(applicationType, "vnd.api.v2+json", StandardCharsets.UTF_8);
//     }
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/service/ToSerialize.java
// public class ToSerialize implements Cloneable {
// 
//     public String prop1;
//     public String prop2;
// 
//     @Override
//     public ToSerialize clone() throws CloneNotSupportedException {
//         return (ToSerialize) super.clone();
//     }
// }


import com.mpalourdio.springboottemplate.AbstractTestRunner;
import com.mpalourdio.springboottemplate.json.Account;
import com.mpalourdio.springboottemplate.json.AccountDecorator;
import com.mpalourdio.springboottemplate.json.Context;
import com.mpalourdio.springboottemplate.mediatype.MediaType;
import com.mpalourdio.springboottemplate.service.ToSerialize;
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 java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
/*
 * 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 = WebEnvironment.MOCK)
@AutoConfigureMockMvc
@AutoConfigureTestDatabase
class MiscControllerTest extends AbstractTestRunner {

    @Autowired
    private MockMvc mockMvc;

    @Test
    void testSerializationForMvcTests() throws Exception {
        var toSerialize = new ToSerialize();
        var input = serializeToJson(toSerialize);

        var output = toSerialize.clone();
        output.prop1 = "prop1updated";

        mockMvc.perform(post("/misc/serialization")
                .with(csrf())
                .contentType(MediaType.APPLICATION_JSON_VALUE)
                .content(input))
                .andExpect(content().contentType(MediaType.APPLICATION_JSON))
// 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/json/Account.java
// public class Account implements AccountInterface {
// 
//     public String firstName;
//     public String lastName;
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/json/AccountDecorator.java
// public class AccountDecorator implements AccountInterface {
// 
//     @JsonUnwrapped
//     public Account account;
//     public Context context;
// 
//     public AccountDecorator() {
//     }
// 
//     public AccountDecorator(Account account) {
//         this.account = account;
//     }
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/json/Context.java
// public class Context {
// 
//     public String ref;
// 
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/mediatype/MediaType.java
// public final class MediaType extends org.springframework.http.MediaType {
// 
//     public static final org.springframework.http.MediaType APPLICATION_VND_API_V1;
//     public static final String APPLICATION_VND_API_V1_VALUE = "application/vnd.api.v1+json;charset=UTF-8";
// 
//     public static final org.springframework.http.MediaType APPLICATION_VND_API_V2;
//     public static final String APPLICATION_VND_API_V2_VALUE = "application/vnd.api.v2+json;charset=UTF-8";
// 
//     private MediaType(String type) {
//         super(type);
//     }
// 
//     static {
//         var applicationType = "application";
//         APPLICATION_VND_API_V1 = new org.springframework.http.MediaType(applicationType, "vnd.api.v1+json", StandardCharsets.UTF_8);
//         APPLICATION_VND_API_V2 = new org.springframework.http.MediaType(applicationType, "vnd.api.v2+json", StandardCharsets.UTF_8);
//     }
// }
// 
// Path: src/main/java/com/mpalourdio/springboottemplate/service/ToSerialize.java
// public class ToSerialize implements Cloneable {
// 
//     public String prop1;
//     public String prop2;
// 
//     @Override
//     public ToSerialize clone() throws CloneNotSupportedException {
//         return (ToSerialize) super.clone();
//     }
// }


// Path: src/test/java/com/mpalourdio/springboottemplate/controllers/MiscControllerTest.java
import com.mpalourdio.springboottemplate.AbstractTestRunner;
import com.mpalourdio.springboottemplate.json.Account;
import com.mpalourdio.springboottemplate.json.AccountDecorator;
import com.mpalourdio.springboottemplate.json.Context;
import com.mpalourdio.springboottemplate.mediatype.MediaType;
import com.mpalourdio.springboottemplate.service.ToSerialize;
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 java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;

/*
 * 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 = WebEnvironment.MOCK)
@AutoConfigureMockMvc
@AutoConfigureTestDatabase
class MiscControllerTest extends AbstractTestRunner {

    @Autowired
    private MockMvc mockMvc;

    @Test
    void testSerializationForMvcTests() throws Exception {
        var toSerialize = new ToSerialize();
        var input = serializeToJson(toSerialize);

        var output = toSerialize.clone();
        output.prop1 = "prop1updated";

        mockMvc.perform(post("/misc/serialization")
                .with(csrf())
                .contentType(MediaType.APPLICATION_JSON_VALUE)
                .content(input))
                .andExpect(content().contentType(MediaType.APPLICATION_JSON))
                .andExpect(content().json(serializeToJson(output), true));