use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogicTest method testCreateAndDeleteFeedbackSession.
private void testCreateAndDeleteFeedbackSession() throws InvalidParametersException, EntityAlreadyExistsException {
______TS("test create");
FeedbackSessionAttributes fs = getNewFeedbackSession();
fsLogic.createFeedbackSession(fs);
verifyPresentInDatastore(fs);
______TS("test create with invalid session name");
fs.setFeedbackSessionName("test & test");
try {
fsLogic.createFeedbackSession(fs);
signalFailureToDetectException();
} catch (Exception e) {
assertEquals("The provided feedback session name is not acceptable to TEAMMATES " + "as it cannot contain the following special html characters in brackets: " + "(< > " / ' &)", e.getMessage());
}
fs.setFeedbackSessionName("test %| test");
try {
fsLogic.createFeedbackSession(fs);
signalFailureToDetectException();
} catch (Exception e) {
assertEquals("\"test %| test\" is not acceptable to TEAMMATES as a/an feedback session name " + "because it contains invalid characters. A/An feedback session name " + "must start with an alphanumeric character, and cannot contain " + "any vertical bar (|) or percent sign (%).", e.getMessage());
}
______TS("test delete");
fs = getNewFeedbackSession();
// Create a question under the session to test for cascading during delete.
FeedbackQuestionAttributes fq = new FeedbackQuestionAttributes();
fq.feedbackSessionName = fs.getFeedbackSessionName();
fq.courseId = fs.getCourseId();
fq.questionNumber = 1;
fq.creatorEmail = fs.getCreatorEmail();
fq.numberOfEntitiesToGiveFeedbackTo = Const.MAX_POSSIBLE_RECIPIENTS;
fq.giverType = FeedbackParticipantType.STUDENTS;
fq.recipientType = FeedbackParticipantType.TEAMS;
fq.questionMetaData = new Text("question to be deleted through cascade");
fq.questionType = FeedbackQuestionType.TEXT;
fq.showResponsesTo = new ArrayList<>();
fq.showRecipientNameTo = new ArrayList<>();
fq.showGiverNameTo = new ArrayList<>();
fqLogic.createFeedbackQuestion(fq);
fsLogic.deleteFeedbackSessionCascade(fs.getFeedbackSessionName(), fs.getCourseId());
verifyAbsentInDatastore(fs);
verifyAbsentInDatastore(fq);
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackQuestionsDbTest method deleteFeedbackQuestions.
private void deleteFeedbackQuestions(int numToDelete) {
FeedbackQuestionAttributes fqa = getNewFeedbackQuestionAttributes();
for (int i = 1; i <= numToDelete; i++) {
fqa.questionNumber = i;
fqDb.deleteEntity(fqa);
}
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackQuestionsDbTest method createNewQuestionsForDifferentRecipientTypes.
private int[] createNewQuestionsForDifferentRecipientTypes() throws Exception {
int[] numberOfQuestionsToCreate = new int[] { 2, 3, 1, 2 };
FeedbackQuestionAttributes fqa;
for (int i = 1; i <= numberOfQuestionsToCreate[0]; i++) {
fqa = getNewFeedbackQuestionAttributes();
fqa.questionNumber = i;
fqa.giverType = FeedbackParticipantType.INSTRUCTORS;
fqDb.createEntity(fqa);
}
for (int i = 1; i <= numberOfQuestionsToCreate[1]; i++) {
fqa = getNewFeedbackQuestionAttributes();
fqa.questionNumber = numberOfQuestionsToCreate[0] + i;
fqa.giverType = FeedbackParticipantType.STUDENTS;
fqDb.createEntity(fqa);
}
for (int i = 1; i <= numberOfQuestionsToCreate[2]; i++) {
fqa = getNewFeedbackQuestionAttributes();
fqa.giverType = FeedbackParticipantType.SELF;
fqa.questionNumber = numberOfQuestionsToCreate[0] + numberOfQuestionsToCreate[1] + i;
fqDb.createEntity(fqa);
}
for (int i = 1; i <= numberOfQuestionsToCreate[3]; i++) {
fqa = getNewFeedbackQuestionAttributes();
fqa.giverType = FeedbackParticipantType.TEAMS;
fqa.questionNumber = numberOfQuestionsToCreate[0] + numberOfQuestionsToCreate[1] + numberOfQuestionsToCreate[2] + i;
fqDb.createEntity(fqa);
}
return numberOfQuestionsToCreate;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackQuestionsDbTest method getNewFeedbackQuestionAttributes.
private FeedbackQuestionAttributes getNewFeedbackQuestionAttributes() {
FeedbackQuestionAttributes fqa = new FeedbackQuestionAttributes();
fqa.courseId = "testCourse";
fqa.creatorEmail = "instructor@email.com";
fqa.feedbackSessionName = "testFeedbackSession";
fqa.giverType = FeedbackParticipantType.INSTRUCTORS;
fqa.recipientType = FeedbackParticipantType.SELF;
fqa.numberOfEntitiesToGiveFeedbackTo = 1;
fqa.questionNumber = 1;
FeedbackTextQuestionDetails questionDetails = new FeedbackTextQuestionDetails("Question text.");
fqa.questionType = FeedbackQuestionType.TEXT;
fqa.setQuestionDetails(questionDetails);
fqa.showGiverNameTo = new ArrayList<>();
fqa.showRecipientNameTo = new ArrayList<>();
fqa.showResponsesTo = new ArrayList<>();
return fqa;
}
use of teammates.common.datatransfer.attributes.FeedbackQuestionAttributes in project teammates by TEAMMATES.
the class FeedbackQuestionsDbTest method testGetFeedbackQuestions.
@Test
public void testGetFeedbackQuestions() throws Exception {
FeedbackQuestionAttributes expected = getNewFeedbackQuestionAttributes();
// remove possibly conflicting entity from the database
fqDb.deleteEntity(expected);
fqDb.createEntity(expected);
______TS("standard success case");
FeedbackQuestionAttributes actual = fqDb.getFeedbackQuestion(expected.feedbackSessionName, expected.courseId, expected.questionNumber);
assertEquals(expected.toString(), actual.toString());
______TS("non-existant question");
assertNull(fqDb.getFeedbackQuestion("Non-existant feedback session", "non-existent-course", 1));
______TS("null fsName");
try {
fqDb.getFeedbackQuestion(null, expected.courseId, 1);
signalFailureToDetectException();
} catch (AssertionError e) {
AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getLocalizedMessage());
}
______TS("null courseId");
try {
fqDb.getFeedbackQuestion(expected.feedbackSessionName, null, 1);
signalFailureToDetectException();
} catch (AssertionError e) {
AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, e.getLocalizedMessage());
}
______TS("get by id");
assertEquals(expected.toString(), actual.toString());
______TS("get non-existent question by id");
actual = fqDb.getFeedbackQuestion("non-existent id");
assertNull(actual);
}
Aggregations