// Path: stardao-core/src/main/java/io/stardog/stardao/exceptions/DataValidationException.java
// public class DataValidationException extends DataException {
//     private final List<ValidationError> errors;
// 
//     public DataValidationException(List<ValidationError> errors) {
//         this.errors = errors;
//     }
// 
//     public List<ValidationError> getErrors() {
//         return errors;
//     }
// 
//     @Override
//     public String getMessage() {
//         StringBuilder sb = new StringBuilder();
//         for (ValidationError error : errors) {
//             sb.append(error.toString());
//             sb.append("; ");
//         }
//         return sb.toString().substring(0, sb.toString().length()-2);
//     }
// }
// 
// Path: stardao-core/src/main/java/io/stardog/stardao/validation/ValidationError.java
// @AutoValue
// public abstract class ValidationError {
//     public abstract String getField();
//     public abstract String getMessage();
// 
//     public static ValidationError of(String field, String message) {
//         return new AutoValue_ValidationError(field, message);
//     }
// 
//     @Override
//     public String toString() {
//         return getField() + ": " + getMessage();
//     }
// }


import io.stardog.stardao.exceptions.DataValidationException;
import io.stardog.stardao.validation.ValidationError;
import org.junit.Test;
import javax.ws.rs.core.Response;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.*;
package io.stardog.stardao.jersey.exceptionmappers;




public class DataValidationExceptionMapperTest {
    @Test
    @SuppressWarnings("unchecked")
    public void toResponse() throws Exception {
        DataValidationExceptionMapper mapper = new DataValidationExceptionMapper();
        DataValidationException exception = new DataValidationException(Arrays.asList(ValidationError.of("field", "is invalid")));

        Response response = mapper.toResponse(exception);
        assertEquals(400, response.getStatus());
        assertEquals("application/json", response.getMediaType().toString());
        Map<String,Object> map = (Map<String,Object>)response.getEntity();
        assertEquals(400, map.get("code"));
        assertEquals("field: is invalid", map.get("message"));
// Path: stardao-core/src/main/java/io/stardog/stardao/exceptions/DataValidationException.java
// public class DataValidationException extends DataException {
//     private final List<ValidationError> errors;
// 
//     public DataValidationException(List<ValidationError> errors) {
//         this.errors = errors;
//     }
// 
//     public List<ValidationError> getErrors() {
//         return errors;
//     }
// 
//     @Override
//     public String getMessage() {
//         StringBuilder sb = new StringBuilder();
//         for (ValidationError error : errors) {
//             sb.append(error.toString());
//             sb.append("; ");
//         }
//         return sb.toString().substring(0, sb.toString().length()-2);
//     }
// }
// 
// Path: stardao-core/src/main/java/io/stardog/stardao/validation/ValidationError.java
// @AutoValue
// public abstract class ValidationError {
//     public abstract String getField();
//     public abstract String getMessage();
// 
//     public static ValidationError of(String field, String message) {
//         return new AutoValue_ValidationError(field, message);
//     }
// 
//     @Override
//     public String toString() {
//         return getField() + ": " + getMessage();
//     }
// }


// Path: stardao-jersey/src/test/java/io/stardog/stardao/jersey/exceptionmappers/DataValidationExceptionMapperTest.java
import io.stardog.stardao.exceptions.DataValidationException;
import io.stardog.stardao.validation.ValidationError;
import org.junit.Test;
import javax.ws.rs.core.Response;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.*;

package io.stardog.stardao.jersey.exceptionmappers;




public class DataValidationExceptionMapperTest {
    @Test
    @SuppressWarnings("unchecked")
    public void toResponse() throws Exception {
        DataValidationExceptionMapper mapper = new DataValidationExceptionMapper();
        DataValidationException exception = new DataValidationException(Arrays.asList(ValidationError.of("field", "is invalid")));

        Response response = mapper.toResponse(exception);
        assertEquals(400, response.getStatus());
        assertEquals("application/json", response.getMediaType().toString());
        Map<String,Object> map = (Map<String,Object>)response.getEntity();
        assertEquals(400, map.get("code"));
        assertEquals("field: is invalid", map.get("message"));
        assertEquals("field", ((List<ValidationError>)map.get("errors")).get(0).getField());