File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
main/java/org/soujava/demos/mongodb/document
test/java/org/soujava/demos/mongodb/document Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 1
1
package org .soujava .demos .mongodb .document ;
2
2
3
3
import jakarta .data .repository .Delete ;
4
+ import jakarta .data .repository .Param ;
4
5
import jakarta .data .repository .Query ;
5
6
import jakarta .data .repository .Repository ;
6
7
import jakarta .data .repository .Save ;
@@ -26,4 +27,7 @@ public interface RoomRepository {
26
27
void save (List <Room > rooms );
27
28
28
29
void deleteBy ();
30
+
31
+ @ Query ("WHERE type = :type" )
32
+ List <Room > findByType (@ Param ("type" ) RoomType type );
29
33
}
Original file line number Diff line number Diff line change 16
16
import org .junit .jupiter .api .AfterEach ;
17
17
import org .junit .jupiter .api .BeforeEach ;
18
18
import org .junit .jupiter .api .Test ;
19
+ import org .junit .jupiter .params .ParameterizedTest ;
20
+ import org .junit .jupiter .params .provider .EnumSource ;
19
21
20
22
import java .util .List ;
21
23
@@ -146,4 +148,11 @@ void shouldFindRoomsNeedingCleaning() {
146
148
softly .assertThat (rooms ).allMatch (room -> !room .getStatus ().equals (RoomStatus .OUT_OF_SERVICE ));
147
149
});
148
150
}
151
+
152
+ @ ParameterizedTest (name = "should find rooms by type {0}" )
153
+ @ EnumSource (RoomType .class )
154
+ void shouldFindRoomByType (RoomType type ) {
155
+ List <Room > rooms = this .repository .findByType (type );
156
+ SoftAssertions .assertSoftly (softly -> softly .assertThat (rooms ).allMatch (room -> room .getType ().equals (type )));
157
+ }
149
158
}
You can’t perform that action at this time.
0 commit comments