Finished exam test
This commit is contained in:
parent
1c48526fce
commit
d86b8a186b
5 changed files with 78 additions and 6 deletions
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 ETH Zürich, Educational Development and Technology (LET)
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ch.ethz.seb.sebserver.gui.integration;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.test.context.jdbc.Sql;
|
||||||
|
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.Page;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetFinishedExamClientConnection;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetFinishedExamClientConnectionPage;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetFinishedExamPage;
|
||||||
|
|
||||||
|
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql", "classpath:data-test-additional.sql" })
|
||||||
|
public class FinishedExamTest extends GuiIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void finishedExamsTest() throws IOException {
|
||||||
|
final RestServiceImpl restService = createRestServiceForUser(
|
||||||
|
"admin",
|
||||||
|
"admin",
|
||||||
|
new GetFinishedExamPage(),
|
||||||
|
new GetFinishedExamClientConnectionPage(),
|
||||||
|
new GetFinishedExamClientConnection());
|
||||||
|
|
||||||
|
// get finished exams page:
|
||||||
|
final Page<Exam> finishedExams = restService
|
||||||
|
.getBuilder(GetFinishedExamPage.class)
|
||||||
|
.call()
|
||||||
|
.getOrThrow();
|
||||||
|
|
||||||
|
assertNotNull(finishedExams);
|
||||||
|
assertFalse(finishedExams.content.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -218,6 +218,9 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.DisableCl
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnection;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnection;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnectionDataList;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnectionDataList;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnectionPage;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetClientConnectionPage;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetFinishedExamClientConnection;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetFinishedExamClientConnectionPage;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetFinishedExamPage;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetMonitoringFullPageData;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetMonitoringFullPageData;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetPendingClientNotifications;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetPendingClientNotifications;
|
||||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetRunningExamPage;
|
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.session.GetRunningExamPage;
|
||||||
|
@ -2127,7 +2130,10 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest {
|
||||||
new PropagateInstruction(),
|
new PropagateInstruction(),
|
||||||
new GetClientConnectionPage(),
|
new GetClientConnectionPage(),
|
||||||
new GetPendingClientNotifications(),
|
new GetPendingClientNotifications(),
|
||||||
new ConfirmPendingClientNotification());
|
new ConfirmPendingClientNotification(),
|
||||||
|
new GetFinishedExamPage(),
|
||||||
|
new GetFinishedExamClientConnectionPage(),
|
||||||
|
new GetFinishedExamClientConnection());
|
||||||
|
|
||||||
final RestServiceImpl adminRestService = createRestServiceForUser(
|
final RestServiceImpl adminRestService = createRestServiceForUser(
|
||||||
"TestInstAdmin",
|
"TestInstAdmin",
|
||||||
|
|
|
@ -30,6 +30,7 @@ import ch.ethz.seb.sebserver.gbl.api.APIMessage.ErrorMessage;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent.EventType;
|
import ch.ethz.seb.sebserver.gbl.model.session.ClientEvent.EventType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.IndicatorValue;
|
import ch.ethz.seb.sebserver.gbl.model.session.IndicatorValue;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionRecordMapper;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionRecordMapper;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientEventRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientEventRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientEventRecordMapper;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientEventRecordMapper;
|
||||||
|
@ -71,6 +72,7 @@ public class SebConnectionTest extends ExamAPIIntegrationTester {
|
||||||
// check correct stored
|
// check correct stored
|
||||||
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
||||||
.selectByExample()
|
.selectByExample()
|
||||||
|
.where(ClientConnectionRecordDynamicSqlSupport.examId, SqlBuilder.isEqualTo(2L))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
@ -120,6 +122,7 @@ public class SebConnectionTest extends ExamAPIIntegrationTester {
|
||||||
// check correct stored
|
// check correct stored
|
||||||
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
||||||
.selectByExample()
|
.selectByExample()
|
||||||
|
.where(ClientConnectionRecordDynamicSqlSupport.examId, SqlBuilder.isEqualTo(2L))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
@ -209,6 +212,7 @@ public class SebConnectionTest extends ExamAPIIntegrationTester {
|
||||||
// check correct stored
|
// check correct stored
|
||||||
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
||||||
.selectByExample()
|
.selectByExample()
|
||||||
|
.where(ClientConnectionRecordDynamicSqlSupport.examId, SqlBuilder.isEqualTo(2L))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
@ -289,6 +293,7 @@ public class SebConnectionTest extends ExamAPIIntegrationTester {
|
||||||
// check correct stored
|
// check correct stored
|
||||||
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
||||||
.selectByExample()
|
.selectByExample()
|
||||||
|
.where(ClientConnectionRecordDynamicSqlSupport.examId, SqlBuilder.isEqualTo(2L))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
@ -316,7 +321,7 @@ public class SebConnectionTest extends ExamAPIIntegrationTester {
|
||||||
final String accessToken = super.obtainAccessToken("test", "test", "SEBClient");
|
final String accessToken = super.obtainAccessToken("test", "test", "SEBClient");
|
||||||
assertNotNull(accessToken);
|
assertNotNull(accessToken);
|
||||||
|
|
||||||
final MockHttpServletResponse createConnection = super.createConnection(accessToken, 1L, null);
|
final MockHttpServletResponse createConnection = super.createConnection(accessToken, 1L, 2L);
|
||||||
assertNotNull(createConnection);
|
assertNotNull(createConnection);
|
||||||
|
|
||||||
final String connectionToken = createConnection.getHeader(API.EXAM_API_SEB_CONNECTION_TOKEN);
|
final String connectionToken = createConnection.getHeader(API.EXAM_API_SEB_CONNECTION_TOKEN);
|
||||||
|
@ -351,6 +356,7 @@ public class SebConnectionTest extends ExamAPIIntegrationTester {
|
||||||
// check correct stored (no changes)
|
// check correct stored (no changes)
|
||||||
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
||||||
.selectByExample()
|
.selectByExample()
|
||||||
|
.where(ClientConnectionRecordDynamicSqlSupport.examId, SqlBuilder.isEqualTo(2L))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
@ -413,6 +419,7 @@ public class SebConnectionTest extends ExamAPIIntegrationTester {
|
||||||
// check correct stored (no changes)
|
// check correct stored (no changes)
|
||||||
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
||||||
.selectByExample()
|
.selectByExample()
|
||||||
|
.where(ClientConnectionRecordDynamicSqlSupport.examId, SqlBuilder.isEqualTo(2L))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import static org.junit.Assert.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mybatis.dynamic.sql.SqlBuilder;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.Cache;
|
import org.springframework.cache.Cache;
|
||||||
import org.springframework.cache.Cache.ValueWrapper;
|
import org.springframework.cache.Cache.ValueWrapper;
|
||||||
|
@ -22,6 +23,7 @@ import org.springframework.test.context.jdbc.Sql;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||||
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionRecordMapper;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionRecordMapper;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientEventRecordMapper;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientEventRecordMapper;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ClientConnectionRecord;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ClientConnectionRecord;
|
||||||
|
@ -43,7 +45,7 @@ public class SebVdiConnectionTest extends ExamAPIIntegrationTester {
|
||||||
final String accessToken = super.obtainAccessToken("testVDI", "testVDI", "read write");
|
final String accessToken = super.obtainAccessToken("testVDI", "testVDI", "read write");
|
||||||
assertNotNull(accessToken);
|
assertNotNull(accessToken);
|
||||||
|
|
||||||
final MockHttpServletResponse createConnection = super.createConnection(accessToken, 1L, null);
|
final MockHttpServletResponse createConnection = super.createConnection(accessToken, 1L, 2L);
|
||||||
assertNotNull(createConnection);
|
assertNotNull(createConnection);
|
||||||
|
|
||||||
// check correct response
|
// check correct response
|
||||||
|
@ -60,13 +62,14 @@ public class SebVdiConnectionTest extends ExamAPIIntegrationTester {
|
||||||
// check correct stored
|
// check correct stored
|
||||||
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
final List<ClientConnectionRecord> records = this.clientConnectionRecordMapper
|
||||||
.selectByExample()
|
.selectByExample()
|
||||||
|
.where(ClientConnectionRecordDynamicSqlSupport.examId, SqlBuilder.isEqualTo(2L))
|
||||||
.build()
|
.build()
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
assertTrue(records.size() == 1);
|
assertTrue(records.size() == 1);
|
||||||
final ClientConnectionRecord clientConnectionRecord = records.get(0);
|
final ClientConnectionRecord clientConnectionRecord = records.get(0);
|
||||||
assertEquals("1", String.valueOf(clientConnectionRecord.getInstitutionId()));
|
assertEquals("1", String.valueOf(clientConnectionRecord.getInstitutionId()));
|
||||||
assertNull(clientConnectionRecord.getExamId());
|
assertEquals("2", clientConnectionRecord.getExamId().toString());
|
||||||
assertEquals("CONNECTION_REQUESTED", String.valueOf(clientConnectionRecord.getStatus()));
|
assertEquals("CONNECTION_REQUESTED", String.valueOf(clientConnectionRecord.getStatus()));
|
||||||
assertEquals(connectionToken, clientConnectionRecord.getConnectionToken());
|
assertEquals(connectionToken, clientConnectionRecord.getConnectionToken());
|
||||||
assertNotNull(clientConnectionRecord.getClientAddress());
|
assertNotNull(clientConnectionRecord.getClientAddress());
|
||||||
|
|
|
@ -13,8 +13,9 @@ INSERT IGNORE INTO additional_attributes VALUES
|
||||||
;
|
;
|
||||||
|
|
||||||
INSERT IGNORE INTO exam VALUES
|
INSERT IGNORE INTO exam VALUES
|
||||||
(1, 1, 1, 'quiz1', 'super-admin', 'super-admin', 'MANAGED', null, null, 'UP_COMING', 1, 0, null, 1, null, null),
|
(1, 1, 1, 'quiz1', 'admin', 'admin', 'MANAGED', null, null, 'UP_COMING', 1, 0, null, 1, null, null),
|
||||||
(2, 1, 1, 'quiz6', 'super-admin', 'super-admin', 'MANAGED', null, null, 'RUNNING', 1, 0, null, 1, null, null)
|
(2, 1, 1, 'quiz6', 'admin', 'admin', 'MANAGED', null, null, 'RUNNING', 1, 0, null, 1, null, null),
|
||||||
|
(3, 1, 1, 'quiz3', 'admin', 'admin', 'MANAGED', null, null, 'FINISHED', 1, 0, null, 1, null, null)
|
||||||
;
|
;
|
||||||
|
|
||||||
INSERT IGNORE INTO indicator VALUES
|
INSERT IGNORE INTO indicator VALUES
|
||||||
|
@ -874,3 +875,10 @@ INSERT IGNORE INTO exam_configuration_map VALUES
|
||||||
(1, 1, 2, 1, null, null)
|
(1, 1, 2, 1, null, null)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO client_connection VALUES
|
||||||
|
(1,1,3,'CLOSED','62c4bbdc-e8a5-42bc-8161-c3d187360184','-- (connection_080)','127.0.0.1',NULL,0,NULL,1647960776988,1647960797388,NULL,NULL,'machineName','osName','versionXY'),
|
||||||
|
(2,1,3,'CLOSED','e3abf4e5-ee5c-4cf1-a13a-1ff8fd23718a','-- (connection_063)','127.0.0.1',NULL,0,NULL,1647960776989,1647960797482,NULL,NULL,'machineName','osName','versionXY'),
|
||||||
|
(3,1,3,'DISABLED','3120f91e-76a9-4810-8628-f25f4099c47b','-- (connection_043)','127.0.0.1',NULL,0,NULL,1647960814460,1648130312083,NULL,NULL,'machineName','osName','versionXY'),
|
||||||
|
(4,1,3,'ACTIVE','6b901e7f-65fb-425f-a303-25e9d6fcbdf2','-- (connection_003)','127.0.0.1',NULL,0,NULL,1648134709401,1648542395328,NULL,NULL,'machineName','osName','versionXY'),
|
||||||
|
(5,1,3,'ACTIVE','2a2013a6-1664-4798-8f1d-362e9ec0a4e4','-- (connection_038)','127.0.0.1',NULL,0,NULL,1648135999634,1648542400438,NULL,NULL,'machineName','osName','versionXY');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue