forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCitizen.java
More file actions
39 lines (27 loc) · 1.16 KB
/
Citizen.java
File metadata and controls
39 lines (27 loc) · 1.16 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
package com.designpatterns.structural.proxy;
import com.designpatterns.structural.proxy.president.PresidentSecretary;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class Citizen {
private PresidentSecretary presidentSecretary = new PresidentSecretary();
@Test
public void talkToPresident_secretaryShouldRejectTooShortMessage() {
String message = "Hi there.";
Assertions.assertThrows(RuntimeException.class, () -> {
presidentSecretary.leaveValidMessageForPresident(message);
});
}
@Test
public void talkToPresident_secretaryShouldRejectTooLongMessage() {
String message = "Hi there. this is a message about some personal issue which I have decided to share with Mr.President.";
Assertions.assertThrows(RuntimeException.class, () -> {
presidentSecretary.leaveValidMessageForPresident(message);
});
}
@Test
public void talkToPresident_secretaryShouldAcceptTheMessage() {
String message = "Hello Mr.President";
presidentSecretary.leaveValidMessageForPresident(message);
Assertions.assertTrue(true);
}
}