16
16
17
17
/**
18
18
* Test suite for the SearchInteractor class.
19
- *
20
- * @author Jerry Zhu (<a href="https://github.com/jerryzhu509">...</a>)
21
19
*/
22
20
public class SearchInteractorTest {
23
21
private static SearchInteractor database ;
@@ -50,6 +48,10 @@ private String formatStr(SearchPackagesResult result, String delim) {
50
48
.collect (Collectors .joining (delim ));
51
49
}
52
50
51
+ /**
52
+ * Tests search by name when there is a match. Using lower-case to ensure that the search is not
53
+ * case-sensitive.
54
+ */
53
55
@ Test
54
56
void testSearchByNameSuccessMatch () {
55
57
var result = database .search (
@@ -58,9 +60,12 @@ void testSearchByNameSuccessMatch() {
58
60
assertEquals (result .state (), SearchPackagesResult .State .SUCCESS );
59
61
60
62
var text = formatStr (result , ", " );
61
- assertEquals (text , "Multiverse-Core" );
63
+ assertEquals ("Multiverse-Core" , text );
62
64
}
63
65
66
+ /**
67
+ * Tests search by name when there is no match. Expect an empty string.
68
+ */
64
69
@ Test
65
70
void testSearchByNameSuccessNoMatch () {
66
71
var result = database .search (
@@ -69,9 +74,12 @@ void testSearchByNameSuccessNoMatch() {
69
74
assertEquals (result .state (), SearchPackagesResult .State .SUCCESS );
70
75
71
76
var text = formatStr (result , ", " );
72
- assertEquals (text , "" );
77
+ assertEquals ("" , text );
73
78
}
74
79
80
+ /**
81
+ * Tests search by keyword when there is a match.
82
+ */
75
83
@ Test
76
84
void testSearchByKeywordSuccessMatch () {
77
85
var result = database .search (
@@ -80,9 +88,12 @@ void testSearchByKeywordSuccessMatch() {
80
88
assertEquals (result .state (), SearchPackagesResult .State .SUCCESS );
81
89
82
90
var text = formatStr (result , ", " );
83
- assertEquals (text , "Holographic Displays, WorldGuard" );
91
+ assertEquals ("Holographic Displays, WorldGuard" , text );
84
92
}
85
93
94
+ /**
95
+ * Tests search by keyword when there is no match. Expect an empty string.
96
+ */
86
97
@ Test
87
98
void testSearchByKeywordSuccessNoMatch () {
88
99
var result = database .search (
@@ -91,9 +102,13 @@ void testSearchByKeywordSuccessNoMatch() {
91
102
assertEquals (result .state (), SearchPackagesResult .State .SUCCESS );
92
103
93
104
var text = formatStr (result , ", " );
94
- assertEquals (text , "" );
105
+ assertEquals ("" , text );
95
106
}
96
107
108
+
109
+ /**
110
+ * Tests search by command when there is a match.
111
+ */
97
112
@ Test
98
113
@ SuppressWarnings ("SpellCheckingInspection" )
99
114
void testSearchByCommandSuccessMatch () {
@@ -103,9 +118,13 @@ void testSearchByCommandSuccessMatch() {
103
118
assertEquals (result .state (), SearchPackagesResult .State .SUCCESS );
104
119
105
120
var text = formatStr (result , ", " );
106
- assertEquals (text , "WorldGuard, Holographic Displays" );
121
+ assertEquals ("WorldGuard, Holographic Displays" , text );
107
122
}
108
123
124
+
125
+ /**
126
+ * Tests search by command when there is no match.
127
+ */
109
128
@ Test
110
129
void testSearchByCommandSuccessNoMatch () {
111
130
var result = database .search (
@@ -114,9 +133,12 @@ void testSearchByCommandSuccessNoMatch() {
114
133
assertEquals (result .state (), SearchPackagesResult .State .SUCCESS );
115
134
116
135
var text = formatStr (result , ", " );
117
- assertEquals (text , "" );
136
+ assertEquals ("" , text );
118
137
}
119
138
139
+ /**
140
+ * Tests invalid searches due to empty inputs.
141
+ */
120
142
@ Test
121
143
void testInvalidSearch () {
122
144
var result1 = database .search (
0 commit comments