SEBSERV-148 test and fixes
This commit is contained in:
parent
7fae3f4baf
commit
449f7d5824
5 changed files with 57 additions and 9 deletions
|
@ -40,6 +40,8 @@ public final class Constants {
|
|||
public static final long HOUR_IN_MILLIS = 60 * MINUTE_IN_MILLIS;
|
||||
public static final long DAY_IN_MILLIS = 24 * HOUR_IN_MILLIS;
|
||||
|
||||
public static final int DAY_IN_MIN = 60 * 24;
|
||||
|
||||
public static final Character CARRIAGE_RETURN = '\n';
|
||||
public static final Character CURLY_BRACE_OPEN = '{';
|
||||
public static final Character CURLY_BRACE_CLOSE = '}';
|
||||
|
|
|
@ -387,11 +387,6 @@ public class ExamProctoringRoomServiceImpl implements ExamProctoringRoomService
|
|||
remoteProctoringRoom.breakOutConnections,
|
||||
examProctoringService.getDefaultInstructionAttributes());
|
||||
|
||||
// Delete room on persistent
|
||||
this.remoteProctoringRoomDAO
|
||||
.deleteRoom(remoteProctoringRoom.id)
|
||||
.getOrThrow();
|
||||
|
||||
// Dispose the proctoring room on service side
|
||||
examProctoringService
|
||||
.disposeBreakOutRoom(proctoringSettings, remoteProctoringRoom.name)
|
||||
|
@ -402,6 +397,11 @@ public class ExamProctoringRoomServiceImpl implements ExamProctoringRoomService
|
|||
proctoringSettings,
|
||||
remoteProctoringRoom.breakOutConnections,
|
||||
examProctoringService);
|
||||
|
||||
// Delete room on persistent
|
||||
this.remoteProctoringRoomDAO
|
||||
.deleteRoom(remoteProctoringRoom.id)
|
||||
.getOrThrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,6 +23,9 @@ import javax.crypto.spec.SecretKeySpec;
|
|||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.Interval;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
@ -355,6 +358,7 @@ public class ZoomProctoringService implements ExamProctoringService {
|
|||
return createAdHocMeeting(
|
||||
UUID.randomUUID().toString(),
|
||||
"Proctoring Room " + (roomNumber + 1),
|
||||
getMeetingDuration(proctoringSettings.examId),
|
||||
proctoringSettings);
|
||||
}
|
||||
|
||||
|
@ -366,9 +370,25 @@ public class ZoomProctoringService implements ExamProctoringService {
|
|||
return createAdHocMeeting(
|
||||
UUID.randomUUID().toString(),
|
||||
subject,
|
||||
getMeetingDuration(proctoringSettings.examId),
|
||||
proctoringSettings);
|
||||
}
|
||||
|
||||
private int getMeetingDuration(final Long examId) {
|
||||
try {
|
||||
final DateTime endTime = this.examSessionService
|
||||
.getRunningExam(examId)
|
||||
.getOrThrow()
|
||||
.getEndTime();
|
||||
final Long result = new Interval(DateTime.now(DateTimeZone.UTC), endTime)
|
||||
.toDurationMillis() / Constants.MINUTE_IN_MILLIS;
|
||||
return result.intValue();
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to get duration for meeting from exam: {} cause: {}", examId, e.getMessage());
|
||||
return Constants.DAY_IN_MIN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Void> disposeBreakOutRoom(
|
||||
final ProctoringServiceSettings proctoringSettings,
|
||||
|
@ -397,7 +417,9 @@ public class ZoomProctoringService implements ExamProctoringService {
|
|||
.getOrThrow();
|
||||
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException("Unexpected error while trying to dispose ad-hoc room for zoom proctoring");
|
||||
throw new RuntimeException(
|
||||
"Unexpected error while trying to dispose ad-hoc room for zoom proctoring",
|
||||
e);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -420,6 +442,7 @@ public class ZoomProctoringService implements ExamProctoringService {
|
|||
private Result<NewRoom> createAdHocMeeting(
|
||||
final String roomName,
|
||||
final String subject,
|
||||
final int duration,
|
||||
final ProctoringServiceSettings proctoringSettings) {
|
||||
|
||||
return Result.tryCatch(() -> {
|
||||
|
@ -443,6 +466,7 @@ public class ZoomProctoringService implements ExamProctoringService {
|
|||
credentials,
|
||||
userResponse.id,
|
||||
subject,
|
||||
duration,
|
||||
meetingPwd);
|
||||
final MeetingResponse meetingResponse = this.jsonMapper.readValue(
|
||||
createMeeting.getBody(),
|
||||
|
@ -668,6 +692,7 @@ public class ZoomProctoringService implements ExamProctoringService {
|
|||
final ClientCredentials credentials,
|
||||
final String userId,
|
||||
final String topic,
|
||||
final int duration,
|
||||
final CharSequence password) {
|
||||
|
||||
try {
|
||||
|
@ -678,7 +703,10 @@ public class ZoomProctoringService implements ExamProctoringService {
|
|||
.buildAndExpand(userId)
|
||||
.toUriString();
|
||||
|
||||
final CreateMeetingRequest createRoomRequest = new CreateMeetingRequest(topic, password);
|
||||
final CreateMeetingRequest createRoomRequest = new CreateMeetingRequest(
|
||||
topic,
|
||||
duration,
|
||||
password);
|
||||
|
||||
final String body = this.zoomProctoringService.jsonMapper.writeValueAsString(createRoomRequest);
|
||||
final HttpHeaders headers = getHeaders(credentials);
|
||||
|
|
|
@ -116,13 +116,18 @@ public interface ZoomRoomRequestResponse {
|
|||
@JsonProperty final int type;
|
||||
@JsonProperty final String start_time;
|
||||
@JsonProperty final String timezone;
|
||||
@JsonProperty final int duration = 60;
|
||||
@JsonProperty final int duration;
|
||||
@JsonProperty final CharSequence password;
|
||||
@JsonProperty final Settings settings;
|
||||
|
||||
public CreateMeetingRequest(final String topic, final CharSequence password) {
|
||||
public CreateMeetingRequest(
|
||||
final String topic,
|
||||
final int duration,
|
||||
final CharSequence password) {
|
||||
|
||||
this.type = 2; // Scheduled Meeting
|
||||
this.start_time = DateTime.now(DateTimeZone.UTC).toString("yyyy-MM-dd'T'HH:mm:ss");
|
||||
this.duration = duration;
|
||||
this.timezone = DateTimeZone.UTC.getID();
|
||||
this.topic = topic;
|
||||
this.password = password;
|
||||
|
|
|
@ -29,4 +29,17 @@ public class ReplTest {
|
|||
// assertEquals("", DateTimeZone.UTC.getID());
|
||||
// }
|
||||
|
||||
// @Test
|
||||
// public void testPeriod() {
|
||||
// final Period period = new Period(
|
||||
// DateTime.now(DateTimeZone.UTC),
|
||||
// DateTime.now(DateTimeZone.UTC).plusDays(1));
|
||||
//
|
||||
// final Interval interv = new Interval(
|
||||
// DateTime.now(DateTimeZone.UTC),
|
||||
// DateTime.now(DateTimeZone.UTC).plusDays(1));
|
||||
//
|
||||
// assertEquals(Constants.DAY_IN_MIN, interv.toDurationMillis() / Constants.MINUTE_IN_MILLIS);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue