@Test public void testGetFeedbackResponsesForQuestion() { ______TS("standard success case"); List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesForQuestion(fras.get("response1ForQ1S1C1").feedbackQuestionId); assertEquals(2, responses.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForQuestion(null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback question"); assertTrue(frDb.getFeedbackResponsesForQuestion("non-existent fq id").isEmpty()); }
@Test public void testGetFeedbackQuestionsForSession() throws Exception { ______TS("standard success case"); int numToCreate = 3; List<FeedbackQuestionAttributes> expected = createFeedbackQuestions(numToCreate); List<FeedbackQuestionAttributes> questions = fqDb.getFeedbackQuestionsForSession(expected.get(0).feedbackSessionName, expected.get(0).courseId); for (int i = 0; i < numToCreate; i++) { expected.get(i).setId(questions.get(i).getId()); } assertEquals(questions.size(), numToCreate); AssertHelper.assertSameContentIgnoreOrder(expected, questions); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> fqDb.getFeedbackQuestionsForSession(null, expected.get(0).courseId)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> fqDb.getFeedbackQuestionsForSession(expected.get(0).feedbackSessionName, null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent session"); assertTrue(fqDb.getFeedbackQuestionsForSession("non-existent session", expected.get(0).courseId).isEmpty()); ______TS("no questions in session"); assertTrue(fqDb.getFeedbackQuestionsForSession("Empty session", expected.get(0).courseId).isEmpty()); deleteFeedbackQuestions(numToCreate); }
private void testGetFeedbackSessionsForCourse() { ______TS("standard success case"); List<FeedbackSessionAttributes> sessions = fsDb.getFeedbackSessionsForCourse("idOfTypicalCourse1"); String expected = dataBundle.feedbackSessions.get("session1InCourse1").toString() + System.lineSeparator() + dataBundle.feedbackSessions.get("session2InCourse1").toString() + System.lineSeparator() + dataBundle.feedbackSessions.get("empty.session").toString() + System.lineSeparator() + dataBundle.feedbackSessions.get("awaiting.session").toString() + System.lineSeparator() + dataBundle.feedbackSessions.get("closedSession").toString() + System.lineSeparator() + dataBundle.feedbackSessions.get("gracePeriodSession").toString() + System.lineSeparator(); for (FeedbackSessionAttributes session : sessions) { AssertHelper.assertContains(session.toString(), expected); } assertEquals(6, sessions.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> fsDb.getFeedbackSessionsForCourse(null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existant course"); assertTrue(fsDb.getFeedbackSessionsForCourse("non-existant course").isEmpty()); ______TS("no sessions in course"); assertTrue(fsDb.getFeedbackSessionsForCourse("idOfCourseNoEvals").isEmpty()); }
@Test public void testGetFeedbackResponsesForSession() { ______TS("standard success case"); String feedbackSessionName = fras.get("response1ForQ1S1C1").feedbackSessionName; String courseId = fras.get("response1ForQ1S1C1").courseId; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesForSession(feedbackSessionName, courseId); assertEquals(6, responses.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSession(null, courseId)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSession(feedbackSessionName, null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback session"); assertTrue(frDb.getFeedbackResponsesForSession("non-existent feedback session", courseId).isEmpty()); ______TS("non-existent course"); assertTrue(frDb.getFeedbackResponsesForSession(feedbackSessionName, "non-existent courseId").isEmpty()); }
@Test public void testGetFeedbackResponsesFromGiverForCourse() { ______TS("standard success case"); String courseId = fras.get("response1ForQ1S1C1").courseId; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesFromGiverForCourse(courseId, "student1InCourse1@gmail.tmt"); assertEquals(2, responses.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesFromGiverForCourse(null, "student1InCourse1@gmail.tmt")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesFromGiverForCourse(courseId, null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback question"); assertTrue(frDb.getFeedbackResponsesFromGiverForCourse( "non-existent courseId", "student1InCourse1@gmail.tmt").isEmpty()); ______TS("non-existent giver"); assertTrue(frDb.getFeedbackResponsesFromGiverForCourse( courseId, "non-existentStudentInCourse1@gmail.tmt").isEmpty()); }
@Test public void testGetFeedbackResponsesForSessionWithinRange() { ______TS("standard success case"); String courseId = fras.get("response1ForQ1S1C1").courseId; String feedbackSessionName = fras.get("response1ForQ1S1C1").feedbackSessionName; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesForSessionWithinRange(feedbackSessionName, courseId, 1); assertEquals(responses.size(), 2); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSessionWithinRange(null, courseId, 5)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSessionWithinRange(feedbackSessionName, null, 4)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback session"); assertTrue(frDb.getFeedbackResponsesForSessionWithinRange( "non-existent feedback session", courseId, 1).isEmpty()); ______TS("non-existent course"); assertTrue(frDb.getFeedbackResponsesForSessionWithinRange( feedbackSessionName, "non-existent courseId", 1).isEmpty()); }
@Test public void testGetFeedbackResponsesForSessionInSection() { ______TS("standard success case"); String courseId = fras.get("response1ForQ1S1C1").courseId; String feedbackSessionName = fras.get("response1ForQ1S1C1").feedbackSessionName; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesForSessionInSection(feedbackSessionName, courseId, "Section 1"); assertEquals(5, responses.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSessionInSection(null, courseId, "Section 1")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSessionInSection(feedbackSessionName, null, "Section 1")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback session"); assertTrue(frDb.getFeedbackResponsesForSessionInSection( "non-existent feedback session", courseId, "Section 1").isEmpty()); ______TS("non-existent course"); assertTrue(frDb.getFeedbackResponsesForSessionInSection( feedbackSessionName, "non-existent courseId", "Section 1").isEmpty()); }
@Test public void testGetFeedbackResponsesForReceiverForQuestion() { ______TS("standard success case"); String questionId = fras.get("response1ForQ1S1C1").feedbackQuestionId; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesForReceiverForQuestion(questionId, "student1InCourse1@gmail.tmt"); assertEquals(1, responses.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForReceiverForQuestion(null, "student1InCourse1@gmail.tmt")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForReceiverForQuestion(questionId, null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback question"); assertTrue(frDb.getFeedbackResponsesForReceiverForQuestion( "non-existent fq id", "student1InCourse1@gmail.tmt").isEmpty()); ______TS("non-existent receiver"); assertTrue(frDb.getFeedbackResponsesForReceiverForQuestion( questionId, "non-existentStudentInCourse1@gmail.tmt").isEmpty()); }
@Test public void testGetFeedbackResponsesFromGiverForQuestion() { ______TS("standard success case"); String questionId = fras.get("response1ForQ1S1C1").feedbackQuestionId; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesFromGiverForQuestion(questionId, "student1InCourse1@gmail.tmt"); assertEquals(responses.size(), 1); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesFromGiverForQuestion(null, "student1InCourse1@gmail.tmt")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesFromGiverForQuestion(questionId, null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback question"); assertTrue(frDb.getFeedbackResponsesFromGiverForQuestion( "non-existent fq id", "student1InCourse1@gmail.tmt").isEmpty()); ______TS("non-existent receiver"); assertTrue(frDb.getFeedbackResponsesFromGiverForQuestion( questionId, "non-existentStudentInCourse1@gmail.tmt").isEmpty()); }
@Test public void testGetFeedbackResponsesForReceiverForCourse() { ______TS("standard success case"); String courseId = fras.get("response1ForQ1S1C1").courseId; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesForReceiverForCourse(courseId, "student1InCourse1@gmail.tmt"); assertEquals(1, responses.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForReceiverForCourse(null, "student1InCourse1@gmail.tmt")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForReceiverForCourse(courseId, null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent courseId"); assertTrue(frDb.getFeedbackResponsesForReceiverForCourse( "non-existent courseId", "student1InCourse1@gmail.tmt").isEmpty()); ______TS("non-existent receiver"); assertTrue(frDb.getFeedbackResponsesForReceiverForCourse( courseId, "non-existentStudentInCourse1@gmail.tmt").isEmpty()); }
@Test public void testGetFeedbackResponsesForSessionToSection() { ______TS("standard success case"); String courseId = fras.get("response1ForQ1S1C1").courseId; String feedbackSessionName = fras.get("response1ForQ1S1C1").feedbackSessionName; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesForSessionToSection(feedbackSessionName, courseId, "Section 1"); assertEquals(4, responses.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSessionToSection(null, courseId, "Section 1")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSessionToSection(feedbackSessionName, null, "Section 1")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback session"); assertTrue(frDb.getFeedbackResponsesForSessionToSection( "non-existent feedback session", courseId, "Section 1").isEmpty()); ______TS("non-existent course"); assertTrue(frDb.getFeedbackResponsesForSessionToSection( feedbackSessionName, "non-existent courseId", "Section 1").isEmpty()); ______TS("no responses for session"); assertTrue(frDb.getFeedbackResponsesForSessionToSection( "Empty feedback session", "idOfTypicalCourse1", "Section 1").isEmpty()); }
@Test public void testGetFeedbackResponsesForSessionFromSection() { ______TS("standard success case"); String courseId = fras.get("response1ForQ1S1C1").courseId; String feedbackSessionName = fras.get("response1ForQ1S1C1").feedbackSessionName; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesForSessionFromSection(feedbackSessionName, courseId, "Section 2"); assertEquals(1, responses.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSessionFromSection(null, courseId, "Section 1")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForSessionFromSection(feedbackSessionName, null, "Section 1")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback session"); assertTrue(frDb.getFeedbackResponsesForSessionFromSection( "non-existent feedback session", courseId, "Section 1").isEmpty()); ______TS("non-existent course"); assertTrue(frDb.getFeedbackResponsesForSessionFromSection( feedbackSessionName, "non-existent courseId", "Section 1").isEmpty()); ______TS("no responses for session"); assertTrue(frDb.getFeedbackResponsesForSessionFromSection( "Empty feedback session", "idOfTypicalCourse1", "Section 1").isEmpty()); }
private void testGetSoftDeletedFeedbackSessionsForCourse() { ______TS("standard success case"); List<FeedbackSessionAttributes> softDeletedSessions = fsDb .getSoftDeletedFeedbackSessionsForCourse("idOfTypicalCourse3"); String expected = dataBundle.feedbackSessions.get("session2InCourse3").toString() + System.lineSeparator(); for (FeedbackSessionAttributes session : softDeletedSessions) { AssertHelper.assertContains(session.toString(), expected); } assertEquals(1, softDeletedSessions.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> fsDb.getSoftDeletedFeedbackSessionsForCourse(null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existant course"); assertTrue(fsDb.getSoftDeletedFeedbackSessionsForCourse("non-existant course").isEmpty()); ______TS("no sessions in course"); assertTrue(fsDb.getSoftDeletedFeedbackSessionsForCourse("idOfCourseNoEvals").isEmpty()); }
() -> frDb.getFeedbackResponsesFromGiverForQuestionInSection( null, "student1InCourse1@gmail.tmt", "Section 1")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage());
@Test public void testGetFeedbackResponsesForQuestionInSection() { ______TS("standard success case"); String questionId = fras.get("response1ForQ2S1C1").feedbackQuestionId; List<FeedbackResponseAttributes> responses = frDb.getFeedbackResponsesForQuestionInSection(questionId, "Section 1", SectionDetail.EITHER); assertEquals(3, responses.size()); ______TS("show response after filtering by giver from section 1"); responses = frDb.getFeedbackResponsesForQuestionInSection(questionId, "Section 1", SectionDetail.GIVER); assertEquals(2, responses.size()); ______TS("show response after filtering by recipient from section 2"); responses = frDb.getFeedbackResponsesForQuestionInSection(questionId, "Section 2", SectionDetail.EVALUEE); assertEquals(1, responses.size()); ______TS("no responses as they are filtered by both giver and recipient from section 2"); responses = frDb.getFeedbackResponsesForQuestionInSection(questionId, "Section 2", SectionDetail.BOTH); assertEquals(0, responses.size()); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForQuestionInSection(null, "Section 1", SectionDetail.EITHER)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForQuestionInSection(questionId, null, SectionDetail.EITHER)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponsesForQuestionInSection(questionId, "Section 1", null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("non-existent feedback question"); assertTrue(frDb.getFeedbackResponsesForQuestionInSection("non-existent fq id", "Section 1", SectionDetail.EITHER).isEmpty()); }
private void testGetFeedbackSessions() { ______TS("standard success case"); FeedbackSessionAttributes expected = dataBundle.feedbackSessions.get("session1InCourse2"); FeedbackSessionAttributes actual = fsDb.getFeedbackSession("idOfTypicalCourse2", "Instructor feedback session"); assertEquals(expected.toString(), actual.toString()); ______TS("non-existant session"); assertNull(fsDb.getFeedbackSession("non-course", "Non-existant feedback session")); ______TS("soft-deleted session"); assertNotNull(fsDb.getSoftDeletedFeedbackSession("idOfTypicalCourse4", "First feedback session")); assertNull(fsDb.getFeedbackSession("idOfTypicalCourse4", "First feedback session")); ______TS("null fsName"); AssertionError ae = assertThrows(AssertionError.class, () -> fsDb.getFeedbackSession("idOfTypicalCourse1", null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("null courseId"); ae = assertThrows(AssertionError.class, () -> fsDb.getFeedbackSession(null, "First feedback session")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); }
@Test public void testCreateDeleteFeedbackSession() throws Exception { ______TS("standard success case"); FeedbackSessionAttributes fsa = getNewFeedbackSession(); fsDb.createEntity(fsa); verifyPresentInDatastore(fsa); ______TS("duplicate"); EntityAlreadyExistsException eaee = assertThrows(EntityAlreadyExistsException.class, () -> fsDb.createEntity(fsa)); AssertHelper.assertContains( String.format(FeedbackSessionsDb.ERROR_CREATE_ENTITY_ALREADY_EXISTS, fsa.getEntityTypeAsString()) + fsa.getIdentificationString(), eaee.getMessage()); fsDb.deleteEntity(fsa); verifyAbsentInDatastore(fsa); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> fsDb.createEntity(null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("invalid params"); fsa.setStartTime(Instant.now()); InvalidParametersException ipe = assertThrows(InvalidParametersException.class, () -> fsDb.createEntity(fsa)); AssertHelper.assertContains("start time", ipe.getLocalizedMessage()); }
@Test public void testGetFeedbackResponses() { ______TS("standard success case"); FeedbackResponseAttributes expected = getResponseAttributes("response1ForQ1S1C1"); FeedbackResponseAttributes actual = frDb.getFeedbackResponse(expected.feedbackQuestionId, expected.giver, expected.recipient); assertEquals(expected.toString(), actual.toString()); ______TS("non-existent response"); assertNull(frDb.getFeedbackResponse(expected.feedbackQuestionId, "student1InCourse1@gmail.tmt", "student3InCourse1@gmail.tmt")); ______TS("null fqId"); AssertionError ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponse(null, "student1InCourse1@gmail.tmt", "student1InCourse1@gmail.tmt")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("null giverEmail"); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponse(expected.feedbackQuestionId, null, "student1InCourse1@gmail.tmt")); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("null receiverEmail"); ae = assertThrows(AssertionError.class, () -> frDb.getFeedbackResponse(expected.feedbackQuestionId, "student1InCourse1@gmail.tmt", null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("get by id"); actual = frDb.getFeedbackResponse(actual.getId()); //Id from first success case assertEquals(expected.toString(), actual.toString()); ______TS("get non-existent response by id"); actual = frDb.getFeedbackResponse("non-existent id"); assertNull(actual); }
@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"); AssertionError ae = assertThrows(AssertionError.class, () -> fqDb.getFeedbackQuestion(null, expected.courseId, 1)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("null courseId"); ae = assertThrows(AssertionError.class, () -> fqDb.getFeedbackQuestion(expected.feedbackSessionName, null, 1)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.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); }
@Test public void testCreateDeleteFeedbackQuestion() throws Exception { ______TS("standard success case"); FeedbackQuestionAttributes fqa = getNewFeedbackQuestionAttributes(); // remove possibly conflicting entity from the database fqDb.deleteEntity(fqa); fqDb.createEntity(fqa); verifyPresentInDatastore(fqa); ______TS("duplicate - with same id."); EntityAlreadyExistsException eaee = assertThrows(EntityAlreadyExistsException.class, () -> fqDb.createEntity(fqa)); AssertHelper.assertContains( String.format(FeedbackQuestionsDb.ERROR_CREATE_ENTITY_ALREADY_EXISTS, fqa.getEntityTypeAsString()) + fqa.getIdentificationString(), eaee.getMessage()); ______TS("delete - with id specified"); fqDb.deleteEntity(fqa); verifyAbsentInDatastore(fqa); ______TS("null params"); AssertionError ae = assertThrows(AssertionError.class, () -> fqDb.createEntity(null)); AssertHelper.assertContains(Const.StatusCodes.DBLEVEL_NULL_INPUT, ae.getLocalizedMessage()); ______TS("invalid params"); fqa.courseId = "there is space"; InvalidParametersException ipe = assertThrows(InvalidParametersException.class, () -> fqDb.createEntity(fqa)); AssertHelper.assertContains( getPopulatedErrorMessage( FieldValidator.COURSE_ID_ERROR_MESSAGE, fqa.courseId, FieldValidator.COURSE_ID_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, FieldValidator.COURSE_ID_MAX_LENGTH), ipe.getMessage()); }