Event Dispatcher  v0.1.6-beta.1
Project that offers a small library that allows to subscribe and fire events.
ComparableContract.java
Go to the documentation of this file.
1 package com.fermod.contract;
2 
3 import static org.junit.jupiter.api.Assertions.assertEquals;
4 import static org.junit.jupiter.api.Assertions.assertTrue;
5 
6 import org.junit.jupiter.api.DisplayName;
7 import org.junit.jupiter.api.Tag;
8 import org.junit.jupiter.api.Test;
9 
24 @DisplayName("Comparable Test")
25 @Tag("comparable")
26 public interface ComparableContract<T extends Comparable<T>> extends Testable<T> {
27 
35  T createSmallerValue();
36 
40  @DisplayName("Compare Itself - Return Zero")
41  @Test
42  default void comparedToItself() {
43  T value = createValue();
44  assertEquals(0, value.compareTo(value));
45  }
46 
51  @DisplayName("Compare To Smaller - Return Positive Number")
52  @Test
53  default void compareToSmallerValue() {
54  T value = createValue();
55  T smallerValue = createSmallerValue();
56  assertTrue(value.compareTo(smallerValue) > 0);
57  }
58 
63  @DisplayName("Compare To Larger - Return Negative Number")
64  @Test
65  default void compareToLargerValue() {
66  T value = createValue();
67  T smallerValue = createSmallerValue();
68  assertTrue(smallerValue.compareTo(value) < 0);
69  }
70 
71 }
default void compareToLargerValue()
Compares the created value to a larger value to test that returns a negative value.
default void compareToSmallerValue()
Compares the created value to a smaller value to test that returns a positive value.
This interface defines tests to verify that the objects of each class that implements the Comparable ...
The Testable class represents a testable type used by other classes for the use of their own tests.
Definition: Testable.java:9
default void comparedToItself()
Compares the created value to itself to test that returns a zero value.