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

generator.server.pagination.domain.test.AppPageableTest.mustache Maven / Gradle / Ivy

There is a newer version: 1.18.1
Show newest version
package {{packageName}}.shared.pagination.domain;

import static org.assertj.core.api.Assertions.*;

import org.junit.jupiter.api.Test;
import {{packageName}}.UnitTest;
import {{packageName}}.shared.error.domain.NumberValueTooHighException;
import {{packageName}}.shared.error.domain.NumberValueTooLowException;

@UnitTest
class {{baseName}}PageableTest {

  @Test
  void shouldNotBuildWithNegativePage() {
    assertThatThrownBy(() -> new {{baseName}}Pageable(-1, 10))
      .isExactlyInstanceOf(NumberValueTooLowException.class)
      .hasMessageContaining("page");
  }

  @Test
  void shouldNotBuildWithPageSizeAtZero() {
    assertThatThrownBy(() -> new {{baseName}}Pageable(0, 0))
      .isExactlyInstanceOf(NumberValueTooLowException.class)
      .hasMessageContaining("pageSize");
  }

  @Test
  void shouldNotBuildWithPageSizeOverHundred() {
    assertThatThrownBy(() -> new {{baseName}}Pageable(0, 101))
      .isExactlyInstanceOf(NumberValueTooHighException.class)
      .hasMessageContaining("pageSize");
  }

  @Test
  void shouldGetFirstPageInformation() {
    {{baseName}}Pageable pageable = new {{baseName}}Pageable(0, 15);

    assertThat(pageable.page()).isZero();
    assertThat(pageable.pageSize()).isEqualTo(15);
    assertThat(pageable.offset()).isZero();
  }

  @Test
  void shouldGetPageableInformation() {
    {{baseName}}Pageable pageable = new {{baseName}}Pageable(2, 15);

    assertThat(pageable.page()).isEqualTo(2);
    assertThat(pageable.pageSize()).isEqualTo(15);
    assertThat(pageable.offset()).isEqualTo(30);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy