-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemplateTest.java
More file actions
59 lines (53 loc) · 1.76 KB
/
TemplateTest.java
File metadata and controls
59 lines (53 loc) · 1.76 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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.Disabled;
import org.junit.jupiter.api.Test;
import patterns.behavioural.template.BasicTransmission;
import patterns.creational.singleton.MissionControl;
/**
* TEMPLATE PATTERN
*
* <p>Purpose: Defines an algorithm skeleton, letting subclasses override specific steps while keeping the structure intact.
*
* <p>When to use:
* <ul>
* <li>When you want to implement the invariant parts of an algorithm once</li>
* <li>When common behavior among subclasses should be factored into a common class</li>
* <li>When you want to control subclass extensions</li>
* </ul>
*
* <p>Common Pitfalls:
* <ul>
* <li>Not properly documenting which methods are intended to be overridden</li>
* <li>Creating deep inheritance hierarchies</li>
* </ul>
*/
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 example() {
assertThatCode(() -> new BasicTransmission().startProcedure()).doesNotThrowAnyException();
assertThat(MissionControl.contact().getMessages().size()).isEqualTo(1);
}
@Test
@Disabled
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
* implement support for an array of antennas
* */
}
}