-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMessageHighlighterTest.java
More file actions
82 lines (61 loc) · 2.84 KB
/
MessageHighlighterTest.java
File metadata and controls
82 lines (61 loc) · 2.84 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.github.stickerifier.stickerify.logger;
import static com.github.stickerifier.stickerify.logger.HighlightHelper.START_GREEN;
import static com.github.stickerifier.stickerify.logger.MessageHighlighter.CONTINUE_WHITE;
import static com.github.stickerifier.stickerify.logger.MessageHighlighter.HIGHLIGHTED_NEW_USER;
import static com.github.stickerifier.stickerify.telegram.model.TelegramRequest.NEW_USER;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import com.github.stickerifier.stickerify.junit.Tags;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@Tag(Tags.LOG)
class MessageHighlighterTest {
private static final String LOG_MESSAGE = "Received request";
private static final String MIME_TYPE = "image/vnd.microsoft.icon";
private static final String LOG_MESSAGE_WITH_MIME_TYPE = LOG_MESSAGE + " with " + MIME_TYPE + " MIME type";
private MessageHighlighter messageHighlighter;
@BeforeEach
void setup() {
messageHighlighter = new MessageHighlighter();
}
@Test
@DisplayName("Log message from old user")
void processEventWithOldUser() {
var event = new LoggingEvent(LOG_MESSAGE);
var convertedMessage = messageHighlighter.convert(event);
assertThat(convertedMessage, is(equalTo(LOG_MESSAGE)));
}
@Test
@DisplayName("Log message from new user")
void processEventWithNewUser() {
var event = new LoggingEvent(LOG_MESSAGE + NEW_USER);
var convertedMessage = messageHighlighter.convert(event);
assertThat(convertedMessage, is(equalTo(LOG_MESSAGE + HIGHLIGHTED_NEW_USER)));
}
@Test
@DisplayName("Log message with multiple new user occurrences")
void processEventWithMultipleNewUserOccurrences() {
var event = new LoggingEvent(LOG_MESSAGE + NEW_USER + NEW_USER);
var convertedMessage = messageHighlighter.convert(event);
assertThat(convertedMessage, is(equalTo(LOG_MESSAGE + HIGHLIGHTED_NEW_USER + NEW_USER)));
}
@Test
@DisplayName("Log message with MIME type")
void processEventWithMimeType() {
var event = new LoggingEvent(LOG_MESSAGE_WITH_MIME_TYPE);
var highlightedMimeType = START_GREEN + MIME_TYPE + CONTINUE_WHITE;
var convertedMessage = messageHighlighter.convert(event);
assertThat(convertedMessage, is(equalTo(LOG_MESSAGE + " with " + highlightedMimeType + " MIME type")));
}
@Test
@DisplayName("Log message with multiple MIME types")
void processEventWithMultipleMimeTypes() {
var event = new LoggingEvent(LOG_MESSAGE_WITH_MIME_TYPE + " and " + MIME_TYPE);
var highlightedMimeType = START_GREEN + MIME_TYPE + CONTINUE_WHITE;
var convertedMessage = messageHighlighter.convert(event);
assertThat(convertedMessage, is(equalTo(LOG_MESSAGE + " with " + highlightedMimeType + " MIME type and " + MIME_TYPE)));
}
}