예제 #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 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());
 }
예제 #3
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());
 }
예제 #4
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());
 }
예제 #5
0
 @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."));
 }