88import java .nio .file .Files ;
99import java .nio .file .Path ;
1010import java .nio .file .Paths ;
11+ import java .util .AbstractMap .SimpleImmutableEntry ;
1112import java .util .ArrayList ;
1213import java .util .Arrays ;
1314import java .util .List ;
2526import gov .loc .repository .bagit .exceptions .InvalidManifestFormatException ;
2627import gov .loc .repository .bagit .exceptions .MaliciousPathException ;
2728import gov .loc .repository .bagit .exceptions .UnparsableVersionException ;
28- import javafx .util .Pair ;
2929
3030public class BagReaderTest extends Assert {
3131 private List <URL > urls ;
@@ -109,7 +109,7 @@ public void testReadVersion0_93() throws Exception{
109109 Path rootDir = Paths .get (getClass ().getClassLoader ().getResource ("bags/v0_93/bag" ).toURI ());
110110 Bag bag = sut .read (rootDir );
111111 assertEquals (new Version (0 , 93 ), bag .getVersion ());
112- for (Pair <String , String > keyValue : bag .getMetadata ()){
112+ for (SimpleImmutableEntry <String , String > keyValue : bag .getMetadata ()){
113113 if ("Payload-Oxum" .equals (keyValue .getKey ())){
114114 assertEquals ("25.5" , keyValue .getValue ());
115115 }
@@ -121,7 +121,7 @@ public void testReadVersion0_94() throws Exception{
121121 Path rootDir = Paths .get (getClass ().getClassLoader ().getResource ("bags/v0_94/bag" ).toURI ());
122122 Bag bag = sut .read (rootDir );
123123 assertEquals (new Version (0 , 94 ), bag .getVersion ());
124- for (Pair <String , String > keyValue : bag .getMetadata ()){
124+ for (SimpleImmutableEntry <String , String > keyValue : bag .getMetadata ()){
125125 if ("Payload-Oxum" .equals (keyValue .getKey ())){
126126 assertEquals ("25.5" , keyValue .getValue ());
127127 }
@@ -133,7 +133,7 @@ public void testReadVersion0_95() throws Exception{
133133 Path rootDir = Paths .get (getClass ().getClassLoader ().getResource ("bags/v0_95/bag" ).toURI ());
134134 Bag bag = sut .read (rootDir );
135135 assertEquals (new Version (0 , 95 ), bag .getVersion ());
136- for (Pair <String , String > keyValue : bag .getMetadata ()){
136+ for (SimpleImmutableEntry <String , String > keyValue : bag .getMetadata ()){
137137 if ("Package-Size" .equals (keyValue .getKey ())){
138138 assertEquals ("260 GB" , keyValue .getValue ());
139139 }
@@ -172,26 +172,26 @@ public void testReadFetchWithSizeSpecified() throws Exception{
172172
173173 @ Test
174174 public void testReadBagMetadata () throws Exception {
175- List <Pair <String , String >> expectedValues = new ArrayList <>();
176- expectedValues .add (new Pair <>("Source-Organization" , "Spengler University" ));
177- expectedValues .add (new Pair <>("Organization-Address" , "1400 Elm St., Cupertino, California, 95014" ));
178- expectedValues .add (new Pair <>("Contact-Name" , "Edna Janssen" ));
179- expectedValues .add (new Pair <>("Contact-Phone" , "+1 408-555-1212" ));
180- expectedValues .add (new Pair <>("Contact-Email" , "ej@spengler.edu" ));
181- expectedValues .add (new Pair <>("External-Description" , "Uncompressed greyscale TIFF images from the" + System .lineSeparator () +
175+ List <SimpleImmutableEntry <String , String >> expectedValues = new ArrayList <>();
176+ expectedValues .add (new SimpleImmutableEntry <>("Source-Organization" , "Spengler University" ));
177+ expectedValues .add (new SimpleImmutableEntry <>("Organization-Address" , "1400 Elm St., Cupertino, California, 95014" ));
178+ expectedValues .add (new SimpleImmutableEntry <>("Contact-Name" , "Edna Janssen" ));
179+ expectedValues .add (new SimpleImmutableEntry <>("Contact-Phone" , "+1 408-555-1212" ));
180+ expectedValues .add (new SimpleImmutableEntry <>("Contact-Email" , "ej@spengler.edu" ));
181+ expectedValues .add (new SimpleImmutableEntry <>("External-Description" , "Uncompressed greyscale TIFF images from the" + System .lineSeparator () +
182182 " Yoshimuri papers collection." ));
183- expectedValues .add (new Pair <>("Bagging-Date" , "2008-01-15" ));
184- expectedValues .add (new Pair <>("External-Identifier" , "spengler_yoshimuri_001" ));
185- expectedValues .add (new Pair <>("Bag-Size" , "260 GB" ));
186- expectedValues .add (new Pair <>("Bag-Group-Identifier" , "spengler_yoshimuri" ));
187- expectedValues .add (new Pair <>("Bag-Count" , "1 of 15" ));
188- expectedValues .add (new Pair <>("Internal-Sender-Identifier" , "/storage/images/yoshimuri" ));
189- expectedValues .add (new Pair <>("Internal-Sender-Description" , "Uncompressed greyscale TIFFs created from" + System .lineSeparator () +
183+ expectedValues .add (new SimpleImmutableEntry <>("Bagging-Date" , "2008-01-15" ));
184+ expectedValues .add (new SimpleImmutableEntry <>("External-Identifier" , "spengler_yoshimuri_001" ));
185+ expectedValues .add (new SimpleImmutableEntry <>("Bag-Size" , "260 GB" ));
186+ expectedValues .add (new SimpleImmutableEntry <>("Bag-Group-Identifier" , "spengler_yoshimuri" ));
187+ expectedValues .add (new SimpleImmutableEntry <>("Bag-Count" , "1 of 15" ));
188+ expectedValues .add (new SimpleImmutableEntry <>("Internal-Sender-Identifier" , "/storage/images/yoshimuri" ));
189+ expectedValues .add (new SimpleImmutableEntry <>("Internal-Sender-Description" , "Uncompressed greyscale TIFFs created from" + System .lineSeparator () +
190190 " microfilm." ));
191- expectedValues .add (new Pair <>("Bag-Count" , "1 of 15" )); //test duplicate
191+ expectedValues .add (new SimpleImmutableEntry <>("Bag-Count" , "1 of 15" )); //test duplicate
192192
193193 Path bagInfoFile = Paths .get (getClass ().getClassLoader ().getResource ("baginfoFiles" ).toURI ());
194- List <Pair <String , String >> actualMetadata = sut .readBagMetadata (bagInfoFile , StandardCharsets .UTF_8 );
194+ List <SimpleImmutableEntry <String , String >> actualMetadata = sut .readBagMetadata (bagInfoFile , StandardCharsets .UTF_8 );
195195
196196 assertEquals (expectedValues , actualMetadata );
197197 }
@@ -208,12 +208,12 @@ public void testReadAllManifests() throws Exception{
208208
209209 @ Test
210210 public void testReadISO_8859_1Encoding () throws Exception {
211- List <Pair <String , String >> expectedMetaData = new ArrayList <>();
212- expectedMetaData .add (new Pair <String , String >("Bag-Software-Agent" ,"bagit.py <http://github.com/libraryofcongress/bagit-python>" ));
213- expectedMetaData .add (new Pair <String , String >("Bagging-Date" ,"2016-02-26" ));
214- expectedMetaData .add (new Pair <String , String >("Contact-Email" ,"cadams@loc.gov" ));
215- expectedMetaData .add (new Pair <String , String >("Contact-Name" ,"Chris Adams" ));
216- expectedMetaData .add (new Pair <String , String >("Payload-Oxum" ,"58.2" ));
211+ List <SimpleImmutableEntry <String , String >> expectedMetaData = new ArrayList <>();
212+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Bag-Software-Agent" ,"bagit.py <http://github.com/libraryofcongress/bagit-python>" ));
213+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Bagging-Date" ,"2016-02-26" ));
214+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Contact-Email" ,"cadams@loc.gov" ));
215+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Contact-Name" ,"Chris Adams" ));
216+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Payload-Oxum" ,"58.2" ));
217217
218218 Path bagPath = Paths .get (new File ("src/test/resources/ISO-8859-1-encodedBag" ).toURI ());
219219 Bag bag = sut .read (bagPath );
@@ -224,12 +224,12 @@ public void testReadISO_8859_1Encoding() throws Exception{
224224
225225 @ Test
226226 public void testReadUTF_16_Encoding () throws Exception {
227- List <Pair <String , String >> expectedMetaData = new ArrayList <>();
228- expectedMetaData .add (new Pair <String , String >("Bag-Software-Agent" ,"bagit.py <http://github.com/libraryofcongress/bagit-python>" ));
229- expectedMetaData .add (new Pair <String , String >("Bagging-Date" ,"2016-02-26" ));
230- expectedMetaData .add (new Pair <String , String >("Contact-Email" ,"cadams@loc.gov" ));
231- expectedMetaData .add (new Pair <String , String >("Contact-Name" ,"Chris Adams" ));
232- expectedMetaData .add (new Pair <String , String >("Payload-Oxum" ,"58.2" ));
227+ List <SimpleImmutableEntry <String , String >> expectedMetaData = new ArrayList <>();
228+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Bag-Software-Agent" ,"bagit.py <http://github.com/libraryofcongress/bagit-python>" ));
229+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Bagging-Date" ,"2016-02-26" ));
230+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Contact-Email" ,"cadams@loc.gov" ));
231+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Contact-Name" ,"Chris Adams" ));
232+ expectedMetaData .add (new SimpleImmutableEntry <String , String >("Payload-Oxum" ,"58.2" ));
233233
234234 List <FetchItem > expectedFetchItems = new ArrayList <>();
235235 expectedFetchItems .add (new FetchItem (new URL ("http://localhost/foo/data/dir1/test3.txt" ), -1l , "data/dir1/test3.txt" ));
@@ -245,7 +245,7 @@ public void testReadUTF_16_Encoding() throws Exception{
245245 @ Test
246246 public void testReadBagitFile ()throws Exception {
247247 Path bagitFile = Paths .get (getClass ().getClassLoader ().getResource ("bagitFiles/bagit-0.97.txt" ).toURI ());
248- Pair <Version , Charset > actualBagitInfo = sut .readBagitTextFile (bagitFile );
248+ SimpleImmutableEntry <Version , Charset > actualBagitInfo = sut .readBagitTextFile (bagitFile );
249249 assertEquals (new Version (0 , 97 ), actualBagitInfo .getKey ());
250250 assertEquals (StandardCharsets .UTF_8 , actualBagitInfo .getValue ());
251251 }
0 commit comments