// Path: src/main/java/org/blackdread/filtersortjooqapi/exception/SortingApiException.java
// public class SortingApiException extends BadUsageApiException {
// 
//     public SortingApiException(final String message) {
//         super(message);
//     }
// }


import org.blackdread.filtersortjooqapi.exception.SortingApiException;
import org.jooq.SortField;
import org.jooq.SortOrder;
import org.jooq.impl.DSL;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Sort;
import java.sql.Timestamp;
import java.util.Collection;
package org.blackdread.filtersortjooqapi.sort;



/**
 * Created by Yoann CAPLAIN on 2017/10/23.
 */
class SortingJooqTest {

    private SortingJooqImpl1 sortingJooqImpl1;

    @BeforeEach
    void setUp() {
        sortingJooqImpl1 = new SortingJooqImpl1();
    }

    @AfterEach
    void teardDown() {

    }

    @Test
    void emptySortingIsEmpty() {
        Assertions.assertEquals(true, sortingJooqImpl1.emptySorting().isEmpty());
    }

    @Test
    void emptySortingIsNotModifiable() {
        Assertions.assertThrows(UnsupportedOperationException.class, () -> sortingJooqImpl1.emptySorting().add(DSL.field("any", Integer.class).asc()));
    }

    @Test
    void buildOrderByWithEmptySort() {
        final Collection<SortField<?>> sortFields = sortingJooqImpl1.buildOrderBy(Sort.unsorted());
        Assertions.assertNotNull(sortFields);
        Assertions.assertTrue(sortFields.isEmpty());
    }

    @Test
    void buildOrderByThrowsWhenNotFoundSortKey() {
// Path: src/main/java/org/blackdread/filtersortjooqapi/exception/SortingApiException.java
// public class SortingApiException extends BadUsageApiException {
// 
//     public SortingApiException(final String message) {
//         super(message);
//     }
// }


// Path: src/test/java/org/blackdread/filtersortjooqapi/sort/SortingJooqTest.java
import org.blackdread.filtersortjooqapi.exception.SortingApiException;
import org.jooq.SortField;
import org.jooq.SortOrder;
import org.jooq.impl.DSL;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Sort;
import java.sql.Timestamp;
import java.util.Collection;

package org.blackdread.filtersortjooqapi.sort;



/**
 * Created by Yoann CAPLAIN on 2017/10/23.
 */
class SortingJooqTest {

    private SortingJooqImpl1 sortingJooqImpl1;

    @BeforeEach
    void setUp() {
        sortingJooqImpl1 = new SortingJooqImpl1();
    }

    @AfterEach
    void teardDown() {

    }

    @Test
    void emptySortingIsEmpty() {
        Assertions.assertEquals(true, sortingJooqImpl1.emptySorting().isEmpty());
    }

    @Test
    void emptySortingIsNotModifiable() {
        Assertions.assertThrows(UnsupportedOperationException.class, () -> sortingJooqImpl1.emptySorting().add(DSL.field("any", Integer.class).asc()));
    }

    @Test
    void buildOrderByWithEmptySort() {
        final Collection<SortField<?>> sortFields = sortingJooqImpl1.buildOrderBy(Sort.unsorted());
        Assertions.assertNotNull(sortFields);
        Assertions.assertTrue(sortFields.isEmpty());
    }

    @Test
    void buildOrderByThrowsWhenNotFoundSortKey() {
        Assertions.assertThrows(SortingApiException.class, () -> sortingJooqImpl1.buildOrderBy(Sort.by(Sort.Order.asc("id"), Sort.Order.desc("asdas"), Sort.Order.asc("dwadw"))));