@@ -56,6 +56,14 @@ public List<PVEvent> getEvents() {
5656 }
5757 }
5858
59+ /**
60+ * Waits until the condition is met. If the conditions is already met, it
61+ * returns right away. If the condition is not met after the time specified,
62+ * an {@link AssertionError} is thrown.
63+ *
64+ * @param ms the timeout in millis
65+ * @param condition the condition
66+ */
5967 public void wait (int ms , Function <List <PVEvent >, Boolean > condition ) {
6068 CountDownLatch latch = new CountDownLatch (1 );
6169 Runnable newTest = new Runnable () {
@@ -83,6 +91,15 @@ public void run() {
8391 }
8492 }
8593
94+ /**
95+ * Checks that the condition is not met. The method returns successfully
96+ * only if the condition is not met within the timeout. If the conditions is
97+ * already met, or if it is met within the time specified, an
98+ * {@link AssertionError} is thrown.
99+ *
100+ * @param ms the timeout in millis
101+ * @param condition the condition
102+ */
86103 public void dontExpect (int ms , Function <List <PVEvent >, Boolean > condition ) {
87104 CountDownLatch latch = new CountDownLatch (1 );
88105 Runnable newTest = new Runnable () {
@@ -109,17 +126,34 @@ public void run() {
109126 throw new AssertionError ("Received " + condition + " against expectation" );
110127 }
111128 }
112-
129+
130+ /**
131+ * Returns an {@link AssertionError} if the condition is not already met.
132+ *
133+ * @param condition the condition
134+ */
113135 public void hasReceived (Function <List <PVEvent >, Boolean > condition ) {
114136 if (!condition .apply (events )) {
115137 throw new AssertionError ("Didn't receive " + condition );
116138 }
117139 }
118140
119- public boolean hasNotReceived (Function <List <PVEvent >, Boolean > condition ) {
120- return !condition .apply (events );
141+ /**
142+ * Returns an {@link AssertionError} if the condition is already met.
143+ *
144+ * @param condition the condition
145+ */
146+ public void hasNotReceived (Function <List <PVEvent >, Boolean > condition ) {
147+ if (condition .apply (events )) {
148+ throw new AssertionError ("Received " + condition );
149+ }
121150 }
122151
152+ /**
153+ * Checks that any event was received.
154+ *
155+ * @return any event condition
156+ */
123157 public static Function <List <PVEvent >, Boolean > forAnEvent () {
124158 return new Function <List <PVEvent >, Boolean >() {
125159 @ Override
@@ -134,10 +168,21 @@ public String toString() {
134168 };
135169 }
136170
171+ /**
172+ * Checks that a connection event was received.
173+ *
174+ * @return connection event condition
175+ */
137176 public static Function <List <PVEvent >, Boolean > forAConnectionEvent () {
138177 return anEventOfType (PVEvent .Type .READ_CONNECTION );
139178 }
140179
180+ /**
181+ * Checks that an event of the given type was received.
182+ *
183+ * @param type the event type
184+ * @return type of event condition
185+ */
141186 public static Function <List <PVEvent >, Boolean > anEventOfType (PVEvent .Type type ) {
142187 return new Function <List <PVEvent >, Boolean >() {
143188 @ Override
@@ -151,7 +196,13 @@ public String toString() {
151196 }
152197 };
153198 }
154-
199+
200+ /**
201+ * Checks the given number of events were received.
202+ *
203+ * @param count the number of events
204+ * @return event count condition
205+ */
155206 public static Function <List <PVEvent >, Boolean > forEventCount (final int count ) {
156207 return new Function <List <PVEvent >, Boolean >() {
157208 @ Override
0 commit comments