45
45
import java .util .stream .Collectors ;
46
46
47
47
import static edu .unc .lib .boxc .indexing .solr .test .MockRepositoryObjectHelpers .makeFileObject ;
48
+ import static edu .unc .lib .boxc .model .api .DatastreamType .AUDIO_ACCESS_COPY ;
48
49
import static edu .unc .lib .boxc .model .api .DatastreamType .JP2_ACCESS_COPY ;
49
50
import static edu .unc .lib .boxc .model .api .DatastreamType .ORIGINAL_FILE ;
50
51
import static edu .unc .lib .boxc .model .api .DatastreamType .TECHNICAL_METADATA ;
@@ -118,6 +119,7 @@ public class SetDatastreamFilterTest {
118
119
private static final long PREMIS_SIZE = 893l ;
119
120
120
121
private static final long JP2_SIZE = 11 ;
122
+ private static final long AUDIO_SIZE = 11 ;
121
123
122
124
private AutoCloseable closeable ;
123
125
@@ -255,6 +257,8 @@ public void fileObjectAudioOnlyBinaryTest() throws Exception {
255
257
fileResource (TECHNICAL_METADATA .getId (), FILE2_SIZE , FILE2_MIMETYPE , FILE2_NAME , FILE2_DIGEST ));
256
258
when (binObj2 .getBinaryStream ()).thenReturn (getClass ().getResourceAsStream ("/datastream/techmd_mp3.xml" ));
257
259
when (fileObj .getBinaryObjects ()).thenReturn (Arrays .asList (binObj , binObj2 ));
260
+ List <Derivative > derivs = makeAudioDerivative ();
261
+ when (derivativeService .getDerivatives (pid )).thenReturn (derivs );
258
262
dip .setContentObject (fileObj );
259
263
260
264
filter .filter (dip );
@@ -263,6 +267,8 @@ public void fileObjectAudioOnlyBinaryTest() throws Exception {
263
267
FILE_MP3_SIZE , FILE_MP3_MIMETYPE , FILE_MP3_NAME , FILE_MP3_DIGEST , null , FILE_MP3_EXTENT );
264
268
assertContainsDatastream (idb .getDatastream (), TECHNICAL_METADATA .getId (),
265
269
FILE2_SIZE , FILE2_MIMETYPE , FILE2_NAME , FILE2_DIGEST , null , null );
270
+ assertContainsDatastream (idb .getDatastream (), AUDIO_ACCESS_COPY .getId (),
271
+ AUDIO_SIZE , AUDIO_ACCESS_COPY .getMimetype (), "access.m4a" , null , null , null );
266
272
}
267
273
268
274
@ Test
@@ -297,6 +303,8 @@ public void fileObjectAudioOnlyBinaryWithDotMillisecondsSeperatorTest() throws E
297
303
fileResource (TECHNICAL_METADATA .getId (), FILE2_SIZE , FILE2_MIMETYPE , FILE2_NAME , FILE2_DIGEST ));
298
304
when (binObj2 .getBinaryStream ()).thenReturn (getClass ().getResourceAsStream ("/datastream/techmd_dot_separated_milliseconds.xml" ));
299
305
when (fileObj .getBinaryObjects ()).thenReturn (Arrays .asList (binObj , binObj2 ));
306
+ List <Derivative > derivs = makeAudioDerivative ();
307
+ when (derivativeService .getDerivatives (pid )).thenReturn (derivs );
300
308
dip .setContentObject (fileObj );
301
309
302
310
filter .filter (dip );
@@ -305,6 +313,8 @@ public void fileObjectAudioOnlyBinaryWithDotMillisecondsSeperatorTest() throws E
305
313
FILE_MP3_SIZE , FILE_MP3_MIMETYPE , FILE_MP3_NAME , FILE_MP3_DIGEST , null , FILE_MP3_EXTENT );
306
314
assertContainsDatastream (idb .getDatastream (), TECHNICAL_METADATA .getId (),
307
315
FILE2_SIZE , FILE2_MIMETYPE , FILE2_NAME , FILE2_DIGEST , null , null );
316
+ assertContainsDatastream (idb .getDatastream (), AUDIO_ACCESS_COPY .getId (),
317
+ AUDIO_SIZE , AUDIO_ACCESS_COPY .getMimetype (), "access.m4a" , null , null , null );
308
318
}
309
319
310
320
@ Test
@@ -768,4 +778,11 @@ private List<Derivative> makeJP2Derivative() throws IOException {
768
778
769
779
return List .of (new Derivative (JP2_ACCESS_COPY , jp2File ));
770
780
}
781
+
782
+ private List <Derivative > makeAudioDerivative () throws IOException {
783
+ File m4aFile = derivDir .resolve ("access.m4a" ).toFile ();
784
+ FileUtils .write (m4aFile , "m4a content" , "UTF-8" );
785
+
786
+ return List .of (new Derivative (AUDIO_ACCESS_COPY , m4aFile ));
787
+ }
771
788
}
0 commit comments