You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 03-messages/Documentation.md
+15-10
Original file line number
Diff line number
Diff line change
@@ -16,29 +16,34 @@
16
16
- T4: ``messages`` contains the same ``Message`` object multiple times
17
17
18
18
## B. Content of invocations - ``ArgumentCaptor``
19
-
19
+
The content of ``Message`` objects which are passed to ``sendMessage(String receiver, String message)``is verified by using an argumentCaptor
20
20
- T5: one message is sent, where the content is verified
21
21
- T6: ``Message`` to be sent has ``null`` as receiver and content
22
22
- T7: multiple messages are sent, where the content is verified
23
23
24
24
25
25
## C. Content of invocations—Increasing observability
26
+
The content of ``Message`` objects which are passed to ``sendMessage(String receiver, String message)``is verified by adding the ``Message`` objects to a list which is returned
26
27
- T8: one message is sent, where the content is verified
27
28
- T9: ``Message`` to be sent has ``null`` as receiver and content
28
29
- T10: multiple messages are sent, where the content is verified
29
30
- T11: ``messages`` is empty
30
31
31
32
## D. Comparison
32
33
33
-
### Advantages
34
+
### ArgumentCaptor
35
+
#### Advantages
36
+
- Verify which arguments are passed to ``sendMessage(String receiver, String message)`` without needing to change the source code
37
+
- Increases understandability as arguments expected are explicitly stated in the test
- In the book it's stated that entities should not be mocked. Therefore, the ``Order`` objects are instantiated.
6
+
- The implementation of the ``e-shop`` follows the Hexagonal Architecture. Therefore, the ``EventPublisher`` does not depend on low-level modules, instead it depends on an abstraction, the ``EventListener``. The ``EventListener`` is a port and both the ``InventoryManager`` and the ``ÈmailNotificationService`` are adapters.
7
+
- In order to mock the ``EventListener listeners`` a constructor is added to the class where this dependency will get injected.
8
+
-
9
+
- T1: test to verify that ``listener.onOrderPlaced(order)`` gets called the right number of times
10
+
11
+
- a boundary of the ``publishOrderToAllListeners`` method is that ``listeners`` contains one element and the ``listener.onOrderPlaced(order)`` is called once
12
+
- T2: ``listeners`` is empty
13
+
- T3: ``listeners`` contains one element
14
+
15
+
## B. Content of invocations - ``ArgumentCaptor``
16
+
The content of ``Order`` object which is passed to ``listener.onOrderPlaced(order)``is verified by using an argumentCaptor where it was differentiated between an ``Order`` object and ``null``
17
+
- T4: one order is placed, where the content is verified
18
+
- T5: ``Order`` to be placed is ``null``
19
+
- T6: one order is placed and there are multiple listeners, where the content is verified
20
+
21
+
22
+
## C. Content of invocations—Increasing observability
23
+
The content of ``Order`` object which is passed to ``listener.onOrderPlaced(order)``is verified by adding the ``Order`` object to a list where it was differentiated between an ``Order`` object and ``null``
24
+
- T7: one order is placed, where the content of the order is verified
25
+
- T8: ``Order`` to be published is ``null``
26
+
- T9: multiple ``listeners`` where the order content is verified
27
+
28
+
It was also verified that no content is present when there is no ``listener`` present
29
+
- T10: no ``listeners`` are present, verify that no order is placed
30
+
31
+
## D. Comparison
32
+
33
+
### Advantages
34
+
### ArgumentCaptor
35
+
#### Advantages
36
+
- Verify which arguments are passed to ``onOrderPlaced(Order order)`` without needing to change the source code
37
+
- Suitable to test void method
38
+
- Increases understandability as arguments expected are explicitly stated in the test
0 commit comments