Event Dispatcher  v0.1.6-beta.1
Project that offers a small library that allows to subscribe and fire events.
EqualsTest.java
Go to the documentation of this file.
1 package com.fermod;
2 
3 import static org.junit.jupiter.api.Assertions.fail;
4 
5 import java.util.Random;
6 import java.util.concurrent.ThreadLocalRandom;
7 
8 import org.apache.logging.log4j.LogManager;
9 import org.apache.logging.log4j.Logger;
10 import org.junit.jupiter.api.BeforeAll;
11 import org.junit.jupiter.api.DisplayName;
12 import org.junit.jupiter.api.Nested;
13 import org.junit.jupiter.api.TestInstance;
14 import org.junit.jupiter.api.TestInstance.Lifecycle;
15 import org.junit.jupiter.api.extension.ExtendWith;
16 
22 
26 @DisplayName("Equals Test")
27 @ExtendWith({TimingExtension.class})
28 class EqualsTest {
29 
30  private static final Logger LOGGER = LogManager.getLogger(EqualsTest.class);
31 
32  @Nested
33  @DisplayName("ObservedValue Equals Test")
35 
36  @Override
38 
39  ObservedValue<Integer> observedValue = null;
40  try {
41  observedValue = createObservedValue(10);
42  } catch (Exception e) {
43  fail("Exception raised when creating the test data.", e);
44  }
45 
46  return observedValue;
47  }
48 
49  @Override
51 
52  ObservedValue<Integer> observedValue = null;
53  try {
54  observedValue = createObservedValue(20);
55  } catch (Exception e) {
56  fail("Exception raised when creating the test data.", e);
57  }
58 
59  return observedValue;
60  }
61 
63  return new ObservedValue<>(value);
64  }
65 
66  }
67 
68  @Nested
69  @TestInstance(Lifecycle.PER_CLASS)
70  @DisplayName("PersonObject Equals Test")
72 
74 
75  @BeforeAll
76  void beforeAll() {
77  randString = new RandomString(10, ThreadLocalRandom.current());
78  }
79 
80  @Override
82 
83  PersonObject personObject = null;
84  try {
85  personObject = createRandomPersonObject();
86  } catch (Exception e) {
87  fail("Exception raised when creating the test data.", e);
88  }
89 
90  return personObject;
91  }
92 
93  @Override
95 
96  PersonObject personObject = null;
97  try {
98  personObject = createRandomPersonObject();
99  } catch (Exception e) {
100  fail("Exception raised when creating the test data.", e);
101  }
102 
103  return personObject;
104  }
105 
107 
108  String randomString = randString.nextString();
109 
110  Random random = ThreadLocalRandom.current();
111  int randomInt = random.nextInt(200);
112 
113  LOGGER.debug("Created PersonObject[name: " + randomString + ", age: " + randomInt + "]");
114 
115  return new PersonObject(randomString, randomInt);
116  }
117 
118  }
119 
120 }
Class that wraps a value and gives the utility of registering listeners that will be called after any...
ObservedValue< Integer > createNotEqualValue()
Creates and returns a non equal value to use in the equality tests.
Definition: EqualsTest.java:50
This class defines test of equality that the objects should pass.
Definition: EqualsTest.java:28
String nextString()
Returns a pseudorandom, uniformly distributed.
PersonObject createNotEqualValue()
Creates and returns a non equal value to use in the equality tests.
Definition: EqualsTest.java:94
PersonObject createValue()
Creates and returns a value used for testing.
Definition: EqualsTest.java:81
The TimingExtension class implements the BeforeTestExecutionCallback and the AfterTestExecutionCallba...
This interface defines tests to verify that the objects implements correctly the.
ObservedValue< Integer > createObservedValue(int value)
Definition: EqualsTest.java:62
A class to generate pseudorandom sequences of strings.
ObservedValue< Integer > createValue()
Creates and returns a value used for testing.
Definition: EqualsTest.java:37