33import ch .ethz .seb .sps .domain .api .API ;
44import ch .ethz .seb .sps .domain .model .Page ;
55import ch .ethz .seb .sps .domain .model .PageSortOrder ;
6+ import ch .ethz .seb .sps .domain .model .service .DistinctMetadataWindowForExam ;
67import ch .ethz .seb .sps .domain .model .service .Exam ;
78import ch .ethz .seb .sps .domain .model .service .GroupViewData ;
89import ch .ethz .seb .sps .domain .model .service .ScreenshotSearchResult ;
910import ch .ethz .seb .sps .domain .model .service .ScreenshotViewData ;
1011import ch .ethz .seb .sps .domain .model .service .ScreenshotsInGroupData ;
1112import ch .ethz .seb .sps .domain .model .service .SessionSearchResult ;
1213import ch .ethz .seb .sps .domain .model .service .TimelineViewData ;
13- import ch .ethz .seb .sps .server .datalayer .dao .ClientAccessDAO ;
14- import ch .ethz .seb .sps .server .datalayer .dao .ScreenshotDataDAO ;
15- import ch .ethz .seb .sps .server .datalayer .dao .UserDAO ;
16- import ch .ethz .seb .sps .server .weblayer .AdminProctorController ;
14+ import ch .ethz .seb .sps .domain .model .service .UserListForApplicationSearch ;
1715import com .fasterxml .jackson .core .type .TypeReference ;
1816import org .junit .Test ;
19- import org .springframework .beans .factory .annotation .Autowired ;
2017import org .springframework .http .HttpMethod ;
2118
2219import java .sql .Date ;
23- import java .util .ArrayList ;
2420import java .util .Arrays ;
2521import java .util .HashMap ;
2622import java .util .List ;
@@ -42,8 +38,8 @@ public void testFullUseCaseSuccess() throws Exception {
4238 final int expectedAmountOfScreenshots = 2 ;
4339 final String expectedGroupUuid = "3cfb99c0-34a5-4ffd-a11c-6d9790b3f24c" ;
4440 final String expectedSessionUuid = "9cfb99c0-34a5-4ffd-a11c-4d9790b3f24c" ;
45- final String expectedGroupingKey = "Google Homepage " ;
46- final int expectedLengthOfGroupedScreenshotData = 10 ;
41+ final String expectedGroupingKey = "Stackoverflow " ;
42+ final int expectedLengthOfGroupedScreenshotData = 1 ;
4743 final List <Long > expectedScreenshotTimestamps = Arrays .asList (1721743482182l , 1721743483215l , 1721743484222l , 1721743485226l , 1721743486247l );
4844 final List <Date > expectedUniqueDays = Arrays .asList (Date .valueOf ("2024-07-23" ), Date .valueOf ("2024-07-11" ));
4945 final List <String > expectedSessionSearchUuids = Arrays .asList ("9cfb99c0-34a5-4ffd-a11c-4d9790b3f24c" , "4461dec0-5579-4fef-a86f-0ec7b252c779" , "c8ebdedc-1105-4ecb-bd04-c20ba2e221a5" );
@@ -183,9 +179,9 @@ public void testFullUseCaseSuccess() throws Exception {
183179 @ Test
184180 public void testApplicationSearch () throws Exception {
185181 //GIVEN
186- Long expectedExamId = 1l ;
187- List < Long > expectedGroupIds = Arrays . asList ( 1l , 2l ) ;
188- // List<String> expectedMetadataApp = Arrays.asList("")
182+ int expectedAmountOfDistinctMetadataApp = 3 ;
183+ int expectedAmountOfDistinctMetadataWindow = 2 ;
184+ int expectedAmountOfUsers = 4 ;
189185
190186 //WHEN
191187 //1. get exams in the given time frame
@@ -199,29 +195,53 @@ public void testApplicationSearch() throws Exception {
199195 //2. get groupIds for given exam
200196 //endpoint: /search/applications/groupdIds/<examId>
201197 List <Long > groupIds = createMockApiCall (
202- API .APPLICATION_SEARCH_ENDPOINT + "/groupIds/" + 1L ,
198+ API .APPLICATION_SEARCH_ENDPOINT + "/groupIds/" + exams . get ( 0 ). getId () ,
203199 HttpMethod .GET ,
204200 new TypeReference <List <Long >>(){},
205201 new HashMap <>());
206202
207- //2 . get metadata application for given groupIds
203+ //3 . get metadata application for given groupIds
208204 //endpoint: /search/applications/metadata/app
209- Map <String , String > groupIdsAttributes = new HashMap <>();
210- groupIdsAttributes .put ("groupIds" , "1,2" );
211- //
212- // List<String> metadataAppList = createMockApiCall(
213- // API.APPLICATION_SEARCH_METADATA_APP_ENDPOINT,
214- // HttpMethod.GET,
215- // new TypeReference<List<String>>(){},
216- // groupIdsAttributes);
217- //
218- // System.out.println(exams);
205+ //set groupIds attributes (same for all calls)
206+ Map <String , String > metadataAppAttributes = new HashMap <>();
207+ metadataAppAttributes .put ("groupIds" , groupIds .get (0 ) + "," + groupIds .get (1 ));
219208
209+ List <String > metadataAppList = createMockApiCall (
210+ API .APPLICATION_SEARCH_METADATA_APP_ENDPOINT ,
211+ HttpMethod .GET ,
212+ new TypeReference <List <String >>(){},
213+ metadataAppAttributes );
220214
215+ //4. get metadata window titles for given groupIds
216+ //endpoint: /search/applications/metadata/window
217+ Map <String , String > metadataWindowAttributes = new HashMap <>();
218+ metadataWindowAttributes .put ("groupIds" , groupIds .get (0 ) + "," + groupIds .get (1 ));
219+ metadataWindowAttributes .put ("screenProctoringMetadataApplication" , metadataAppList .get (0 ));
220+
221+ DistinctMetadataWindowForExam metadataWindowList = createMockApiCall (
222+ API .APPLICATION_SEARCH_METADATA_WINDOW_ENDPOINT ,
223+ HttpMethod .GET ,
224+ new TypeReference <DistinctMetadataWindowForExam >(){},
225+ metadataWindowAttributes );
221226
222- //THEN
223227
228+ //5. get a list of users who match the metadata search
229+ //endpoint: /search/applications/users
230+ Map <String , String > usersAttributes = new HashMap <>();
231+ usersAttributes .put ("groupIds" , groupIds .get (0 ) + "," + groupIds .get (1 ));
232+ usersAttributes .put ("screenProctoringMetadataApplication" , metadataAppList .get (0 ));
233+ usersAttributes .put ("screenProctoringMetadataWindowTitle" , metadataWindowList .distinctWindowTitles ().stream ().toList ().get (0 ));
224234
235+ List <UserListForApplicationSearch > userList = createMockApiCall (
236+ API .APPLICATION_SEARCH_USER_LIST_ENDPOINT ,
237+ HttpMethod .GET ,
238+ new TypeReference <List <UserListForApplicationSearch >>(){},
239+ usersAttributes );
240+
241+ //THEN
242+ assertEquals (expectedAmountOfDistinctMetadataApp , metadataAppList .size ());
243+ assertEquals (expectedAmountOfDistinctMetadataWindow , metadataWindowList .distinctWindowTitles ().size ());
244+ assertEquals (expectedAmountOfUsers , userList .size ());
225245 }
226246
227247
0 commit comments