예제 #1
0
 @Test
 public void testValidateCorrectObjectLinkToQtiProducesNoErrors() {
   final String targetId = "hello";
   paragraph.setId(Identifier.parseString(targetId));
   final ContentLinkInfo cli = new ContentLinkInfo(accessElement);
   cli.setObjectLink(new ObjectLink(null));
   cli.setQtiLinkIdentifierRef(targetId);
   cli.validate(context);
   assertNoNotificationsRecorded();
 }
예제 #2
0
 @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());
 }
예제 #3
0
 @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());
 }