All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generator.server.pagination.rest.test.RestAppPageableTest.mustache Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
package {{packageName}}.shared.pagination.infrastructure.primary;

import static org.assertj.core.api.Assertions.*;
import static {{packageName}}.BeanValidationAssertions.*;

import org.junit.jupiter.api.Test;
import {{packageName}}.UnitTest;
import {{packageName}}.shared.pagination.domain.{{baseName}}Pageable;

@UnitTest
class Rest{{baseName}}PageableTest {

  @Test
  void shouldConvertToDomain() {
    {{baseName}}Pageable pageable = pageable().toPageable();

    assertThat(pageable.page()).isEqualTo(1);
    assertThat(pageable.pageSize()).isEqualTo(15);
  }

  @Test
  void shouldNotValidateWithPageUnderZero() {
    Rest{{baseName}}Pageable pageable = pageable();
    pageable.setPage(-1);

    assertThatBean(pageable).hasInvalidProperty("page");
  }

  @Test
  void shouldNotValidateWithSizeAtZero() {
    Rest{{baseName}}Pageable pageable = pageable();
    pageable.setPageSize(0);

    assertThatBean(pageable).hasInvalidProperty("pageSize").withParameter("value", 1L);
  }

  @Test
  void shouldNotValidateWithPageSizeOverHundred() {
    Rest{{baseName}}Pageable pageable = pageable();
    pageable.setPageSize(101);

    assertThatBean(pageable).hasInvalidProperty("pageSize");
  }

  private Rest{{baseName}}Pageable pageable() {
    return new Rest{{baseName}}Pageable(1, 15);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy