-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplateTest.java
43 lines (37 loc) · 1.32 KB
/
TemplateTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package tests.behavioural;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatCode;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;
import patterns.behavioural.template.BasicTransmission;
import patterns.creational.singleton.MissionControl;
/**
* TEMPLATE PATTERN turns an algorithm into a template method, allowing subclasses to provide
* concrete implementations. This way the common parts of the algorithm are centralized and
* structure is preserved, but the details can vary.
*/
class TemplateTest {
@AfterAll
static void afterAll() {
MissionControl.contact().getMessages().clear();
}
/**
* Our mission requires a reliable communication system. We need a repeatable procedure to contact
* Earth.
*
* <p>Use the Template pattern to implement the {@link BasicTransmission} class.
*/
@Test
void templateTest() {
assertThatCode(() -> new BasicTransmission().startProcedure()).doesNotThrowAnyException();
assertThat(MissionControl.contact().getMessages().size()).isEqualTo(3);
}
@Test
void todo() {
/*
* todo:
* we will need to establish contact with other spacecraft
* implement a new transmission procedure which doesn't default to Earth's channel
* */
}
}