-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,899 additions
and
59 deletions.
There are no files selected for viewing
136 changes: 136 additions & 0 deletions
136
src/test/java/info/freelibrary/iiif/presentation/v3/annotations/AssessingAnnotationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
|
||
package info.freelibrary.iiif.presentation.v3.annotations; | ||
|
||
import static info.freelibrary.iiif.presentation.v3.utils.TestUtils.getRandom; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import info.freelibrary.iiif.presentation.v3.Canvas; | ||
import info.freelibrary.iiif.presentation.v3.CanvasResource; | ||
import info.freelibrary.iiif.presentation.v3.Manifest; | ||
import info.freelibrary.iiif.presentation.v3.ids.Minter; | ||
import info.freelibrary.iiif.presentation.v3.ids.MinterFactory; | ||
import info.freelibrary.iiif.presentation.v3.properties.Label; | ||
import info.freelibrary.iiif.presentation.v3.properties.selectors.MediaFragmentSelector; | ||
|
||
/** | ||
* Tests {@code AssesssingAnnotation}. | ||
*/ | ||
public class AssessingAnnotationTest { | ||
|
||
/** A persistent ID to use in testing. */ | ||
private static final String ID = "https://example.com/asdf"; | ||
|
||
/** A pattern to use when testing IDs. */ | ||
private static final String ID_PATTERN = "https://example.com/asdf/annotations/anno-"; | ||
|
||
/** A minter to use in testing. */ | ||
private Minter myMinter; | ||
|
||
/** | ||
* Sets up the test environment. | ||
*/ | ||
@Before | ||
public final void setUp() { | ||
myMinter = MinterFactory.getMinter(new Manifest(ID, new Label("A label"))); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#AssessingAnnotation(Minter)}. | ||
*/ | ||
@Test | ||
public final void testAssessingAnnotationMinter() { | ||
assertTrue(new AssessingAnnotation(myMinter).getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#AssessingAnnotation(Minter, CanvasResource)}. | ||
*/ | ||
@Test | ||
public final void testAssessingAnnotationMinterCanvasResourceOfC() { | ||
assertTrue(new AssessingAnnotation(myMinter, new Canvas(myMinter)).getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#AssessingAnnotation(Minter, CanvasResource, MediaFragmentSelector)}. | ||
*/ | ||
@Test | ||
public final void testAssessingAnnotationMinterCanvasResourceOfCMediaFragmentSelector() { | ||
assertTrue(new AssessingAnnotation(myMinter, new Canvas(myMinter), new MediaFragmentSelector(0, 0, 100, 100)) | ||
.getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#AssessingAnnotation(Minter, CanvasResource, String)}. | ||
*/ | ||
@Test | ||
public final void testAssessingAnnotationMinterCanvasResourceOfCString() { | ||
assertTrue(new AssessingAnnotation(myMinter, new Canvas(myMinter), "xywh=0,0,100,100").getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#AssessingAnnotation(String, CanvasResource)}. | ||
*/ | ||
@Test | ||
public final void testAssessingAnnotationStringCanvasResourceOfC() { | ||
assertTrue( | ||
new AssessingAnnotation(ID_PATTERN + getRandom(), new Canvas(myMinter)).getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#AssessingAnnotation(String, CanvasResource, MediaFragmentSelector)}. | ||
*/ | ||
@Test | ||
public final void testAssessingAnnotationStringCanvasResourceOfCMediaFragmentSelector() { | ||
assertTrue(new AssessingAnnotation(ID_PATTERN + getRandom(), new Canvas(myMinter), | ||
new MediaFragmentSelector("xywh=0,0,200,200")).getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#AssessingAnnotation(String, CanvasResource, String)}. | ||
*/ | ||
@Test | ||
public final void testAssessingAnnotationStringCanvasResourceOfCString() { | ||
assertTrue(new AssessingAnnotation(ID_PATTERN + getRandom(), new Canvas(myMinter), "xywh=0,0,150,150").getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#AssessingAnnotation(String, Manifest)}. | ||
*/ | ||
@Test | ||
public final void testAssessingAnnotationStringManifest() { | ||
assertTrue(new AssessingAnnotation(ID_PATTERN + getRandom(), | ||
new Manifest(ID_PATTERN + getRandom(), new Label("Label"))).getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#AssessingAnnotation(String, Target)}. | ||
*/ | ||
@Test | ||
public final void testAssessingAnnotationStringTarget() { | ||
assertTrue(new AssessingAnnotation(ID_PATTERN + getRandom(), new Target(new Canvas(myMinter))).getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link AssessingAnnotation#setMotivation(Motivation)}. | ||
*/ | ||
@Test | ||
public final void testSetMotivationMotivation() { | ||
assertTrue(new AssessingAnnotation(myMinter).setMotivation(Motivation.fromLabel(Purpose.ASSESSING)).getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#setMotivation(Motivation)}. | ||
*/ | ||
@Test(expected = IllegalArgumentException.class) | ||
public final void testSetMotivationMotivationBad() { | ||
assertTrue(new AssessingAnnotation(myMinter).setMotivation(Motivation.fromLabel(Purpose.BOOKMARKING)).getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
} |
138 changes: 138 additions & 0 deletions
138
...est/java/info/freelibrary/iiif/presentation/v3/annotations/BookmarkingAnnotationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
|
||
package info.freelibrary.iiif.presentation.v3.annotations; | ||
|
||
import static info.freelibrary.iiif.presentation.v3.utils.TestUtils.getRandom; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import info.freelibrary.iiif.presentation.v3.Canvas; | ||
import info.freelibrary.iiif.presentation.v3.CanvasResource; | ||
import info.freelibrary.iiif.presentation.v3.Manifest; | ||
import info.freelibrary.iiif.presentation.v3.ids.Minter; | ||
import info.freelibrary.iiif.presentation.v3.ids.MinterFactory; | ||
import info.freelibrary.iiif.presentation.v3.properties.Label; | ||
import info.freelibrary.iiif.presentation.v3.properties.selectors.MediaFragmentSelector; | ||
|
||
/** | ||
* Tests {@code BookmarkingAnnotation}. | ||
*/ | ||
public class BookmarkingAnnotationTest { | ||
|
||
/** A persistent ID to use in testing. */ | ||
private static final String ID = "https://example.com/asdf"; | ||
|
||
/** A pattern to use when testing IDs. */ | ||
private static final String ID_PATTERN = "https://example.com/asdf/annotations/anno-"; | ||
|
||
/** A minter to use in testing. */ | ||
private Minter myMinter; | ||
|
||
/** | ||
* Sets up the test environment. | ||
*/ | ||
@Before | ||
public final void setUp() { | ||
myMinter = MinterFactory.getMinter(new Manifest(ID, new Label("A label"))); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#BookmarkingAnnotation(Minter)}. | ||
*/ | ||
@Test | ||
public final void testBookmarkingAnnotationMinter() { | ||
assertTrue(new BookmarkingAnnotation(myMinter).getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#BookmarkingAnnotation(Minter, CanvasResource)}. | ||
*/ | ||
@Test | ||
public final void testBookmarkingAnnotationMinterCanvasResourceOfC() { | ||
assertTrue(new BookmarkingAnnotation(myMinter, new Canvas(myMinter)).getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for | ||
* {@link BookmarkingAnnotation#BookmarkingAnnotation(Minter, CanvasResource, MediaFragmentSelector)}. | ||
*/ | ||
@Test | ||
public final void testBookmarkingAnnotationMinterCanvasResourceOfCMediaFragmentSelector() { | ||
assertTrue(new BookmarkingAnnotation(myMinter, new Canvas(myMinter), new MediaFragmentSelector(0, 0, 100, 100)) | ||
.getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#BookmarkingAnnotation(Minter, CanvasResource, String)}. | ||
*/ | ||
@Test | ||
public final void testBookmarkingAnnotationMinterCanvasResourceOfCString() { | ||
assertTrue(new BookmarkingAnnotation(myMinter, new Canvas(myMinter), "xywh=0,0,100,100").getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#BookmarkingAnnotation(String, CanvasResource)}. | ||
*/ | ||
@Test | ||
public final void testBookmarkingAnnotationStringCanvasResourceOfC() { | ||
assertTrue(new BookmarkingAnnotation(ID_PATTERN + getRandom(), new Canvas(myMinter)).getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for | ||
* {@link BookmarkingAnnotation#BookmarkingAnnotation(String, CanvasResource, MediaFragmentSelector)}. | ||
*/ | ||
@Test | ||
public final void testBookmarkingAnnotationStringCanvasResourceOfCMediaFragmentSelector() { | ||
assertTrue(new BookmarkingAnnotation(ID_PATTERN + getRandom(), new Canvas(myMinter), | ||
new MediaFragmentSelector("xywh=0,0,200,200")).getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#BookmarkingAnnotation(String, CanvasResource, String)}. | ||
*/ | ||
@Test | ||
public final void testBookmarkingAnnotationStringCanvasResourceOfCString() { | ||
assertTrue(new BookmarkingAnnotation(ID_PATTERN + getRandom(), new Canvas(myMinter), "xywh=0,0,150,150").getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#BookmarkingAnnotation(String, Manifest)}. | ||
*/ | ||
@Test | ||
public final void testBookmarkingAnnotationStringManifest() { | ||
assertTrue(new BookmarkingAnnotation(ID_PATTERN + getRandom(), | ||
new Manifest(ID_PATTERN + getRandom(), new Label("Label"))).getID().startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#BookmarkingAnnotation(String, Target)}. | ||
*/ | ||
@Test | ||
public final void testBookmarkingAnnotationStringTarget() { | ||
assertTrue(new BookmarkingAnnotation(ID_PATTERN + getRandom(), new Target(new Canvas(myMinter))).getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#setMotivation(Motivation)}. | ||
*/ | ||
@Test | ||
public final void testSetMotivationMotivation() { | ||
assertTrue(new BookmarkingAnnotation(myMinter).setMotivation(Motivation.fromLabel(Purpose.BOOKMARKING)).getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
|
||
/** | ||
* Test method for {@link BookmarkingAnnotation#setMotivation(Motivation)}. | ||
*/ | ||
@Test(expected = IllegalArgumentException.class) | ||
public final void testSetMotivationMotivationBad() { | ||
assertTrue(new BookmarkingAnnotation(myMinter).setMotivation(Motivation.fromLabel(Purpose.ASSESSING)).getID() | ||
.startsWith(ID_PATTERN)); | ||
} | ||
} |
Oops, something went wrong.