@Test public void testValidateMissingObjectLinkAndTextLinkProducesError() { final ContentLinkInfo cli = new ContentLinkInfo(accessElement); cli.setApipLinkIdentifierRef(Identifier.parseString("hello")); cli.validate(context); Assert.assertEquals(1, recorder.getNotifications().size()); Assert.assertEquals( NotificationLevel.ERROR, recorder.getNotifications().get(0).getNotificationLevel()); Assert.assertEquals( NotificationType.MODEL_VALIDATION, recorder.getNotifications().get(0).getNotificationType()); Assert.assertEquals( "Not enough children: objectLinkOrTextLink. Expected at least: 1, but found: 0", recorder.getNotifications().get(0).getMessage()); }
@Test public void testValidateQtiRefButNoAssociatedQtiContentProducesError() { final ContentLinkInfo cli = new ContentLinkInfo(null); cli.setObjectLink(new ObjectLink(cli)); cli.setQtiLinkIdentifierRef("targetId"); cli.validate(context); Assert.assertEquals(1, recorder.getNotifications().size()); Assert.assertEquals( NotificationLevel.ERROR, recorder.getNotifications().get(0).getNotificationLevel()); Assert.assertEquals( NotificationType.MODEL_VALIDATION, recorder.getNotifications().get(0).getNotificationType()); Assert.assertEquals( "No QTI content container found associated with this accessibility metadata", recorder.getNotifications().get(0).getMessage()); }
public CandidateEvent recordCandidateItemEvent( final CandidateSession candidateSession, final CandidateItemEventType itemEventType, final ItemSessionState itemSessionState, final NotificationRecorder notificationRecorder) { /* Create event */ final CandidateEvent event = new CandidateEvent(); event.setCandidateSession(candidateSession); event.setItemEventType(itemEventType); event.setTimestamp(requestTimestampContext.getCurrentRequestTimestamp()); /* Store event */ candidateEventDao.persist(event); /* Save current ItemSessionState */ storeItemSessionState(event, itemSessionState); /* Now store processing notifications */ if (notificationRecorder != null) { for (final Notification notification : notificationRecorder.getNotifications()) { recordNotification(event, notification); } } return event; }
@Test public void testValidateQtiReferencesNoMatchingIdElementProducesError() { paragraph.setId(Identifier.parseString("wrongId")); final ContentLinkInfo cli = new ContentLinkInfo(accessElement); cli.setObjectLink(new ObjectLink(cli)); cli.setQtiLinkIdentifierRef("targetId"); cli.validate(context); Assert.assertEquals(1, recorder.getNotifications().size()); Assert.assertEquals( NotificationLevel.ERROR, recorder.getNotifications().get(0).getNotificationLevel()); Assert.assertEquals( NotificationType.MODEL_VALIDATION, recorder.getNotifications().get(0).getNotificationType()); Assert.assertEquals( "contentLinkInfo with qtiLinkIdentifierRef of 'targetId' does not point to an extant Qti content element.", recorder.getNotifications().get(0).getMessage()); }
@Test public void testValidateHavingBothIdRefsProducesError() { final String targetId = "hello"; paragraph.setId(Identifier.parseString(targetId)); final ContentLinkInfo cli = new ContentLinkInfo(accessElement); cli.setObjectLink(new ObjectLink(cli)); cli.setQtiLinkIdentifierRef(targetId); cli.setApipLinkIdentifierRef(Identifier.parseString("helloAgain")); cli.validate(context); Assert.assertEquals(1, recorder.getNotifications().size()); Assert.assertEquals( NotificationLevel.ERROR, recorder.getNotifications().get(0).getNotificationLevel()); Assert.assertEquals( NotificationType.MODEL_VALIDATION, recorder.getNotifications().get(0).getNotificationType()); Assert.assertEquals( "contentLinkInfo must only have either qtiLinkIdentifierRef or apipLinkIdentifierRef specified, but not both.", recorder.getNotifications().get(0).getMessage()); }
@Test public void testValidateHavingNeitherIdRefProducesError() { final ContentLinkInfo cli = new ContentLinkInfo(null); cli.setObjectLink(new ObjectLink(null)); cli.setQtiLinkIdentifierRef(null); cli.setApipLinkIdentifierRef(null); cli.validate(context); Assert.assertEquals(1, recorder.getNotifications().size()); Assert.assertEquals( NotificationLevel.ERROR, recorder.getNotifications().get(0).getNotificationLevel()); Assert.assertEquals( NotificationType.MODEL_VALIDATION, recorder.getNotifications().get(0).getNotificationType()); Assert.assertTrue( recorder .getNotifications() .get(0) .getMessage() .startsWith( "contentLinkInfo must have either the qtiLinkIdentifierRef or apipLinkIdentifierRef specified, but both are null.")); }
public CandidateEvent recordCandidateTestEvent( final CandidateSession candidateSession, final CandidateTestEventType testEventType, final CandidateItemEventType itemEventType, final TestPlanNodeKey itemKey, final TestSessionState testSessionState, final NotificationRecorder notificationRecorder) { Assert.notNull(candidateSession, "candidateSession"); Assert.notNull(testEventType, "testEventType"); Assert.notNull(testSessionState, "testSessionState"); /* Create event */ final CandidateEvent event = new CandidateEvent(); event.setCandidateSession(candidateSession); event.setTestEventType(testEventType); event.setItemEventType(itemEventType); if (itemKey != null) { event.setTestItemKey(itemKey.toString()); } event.setTimestamp(requestTimestampContext.getCurrentRequestTimestamp()); /* Store event */ candidateEventDao.persist(event); /* Store test session state */ storeTestSessionState(event, testSessionState); /* Now store processing notifications */ if (notificationRecorder != null) { for (final Notification notification : notificationRecorder.getNotifications()) { recordNotification(event, notification); } } return event; }
public void assertNoNotificationsRecorded() { Assert.assertEquals(0, recorder.getNotifications().size()); }