Project

General

Profile

Download (2.54 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2020 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.api.service;
10

    
11
import static org.junit.Assert.assertEquals;
12
import static org.junit.Assert.assertNotNull;
13
import static org.junit.Assert.assertTrue;
14

    
15
import java.io.FileNotFoundException;
16
import java.io.IOException;
17
import java.net.URISyntaxException;
18
import java.net.URL;
19
import java.util.Map;
20

    
21
import org.apache.http.HttpException;
22
import org.junit.BeforeClass;
23
import org.junit.Test;
24
import org.unitils.spring.annotation.SpringBeanByType;
25

    
26
import eu.etaxonomy.cdm.model.media.ImageFile;
27
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
28
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
29
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
30

    
31
/**
32
 * @author a.kohlbecker
33
 * @since Jul 13, 2020
34
 */
35
public class MediaServiceImplTest extends CdmTransactionalIntegrationTest {
36

    
37
    @SpringBeanByType
38
    private IMediaService mediaService;
39

    
40
    static final private String imageFileName1 = "IPTC-PhotometadataRef-Std2019.1.jpg";
41
    static private MediaRepresentation repr1;
42
    static private MediaRepresentationPart part1;
43

    
44
    @BeforeClass
45
    static public void makeMedia() throws URISyntaxException {
46
        URL mediaURL = MediaServiceImplTest.class.getResource(imageFileName1);
47
        part1 = ImageFile.NewInstance(mediaURL.toURI(), null);
48
        repr1 = MediaRepresentation.NewInstance("image/jpeg", "jpg");
49
        repr1.addRepresentationPart(part1);
50
    }
51

    
52

    
53
    @Test
54
    public void testReadResourceMetadataFiltered() throws IOException, HttpException {
55
         //Logger.getLogger(IdentifiableServiceBase.class).setLevel(Level.DEBUG);
56
        Map<String, String> mediaData = mediaService.readResourceMetadataFiltered(repr1);
57
        assertNotNull(mediaData);
58
        assertTrue("IPCT data in the positive list of the includes", mediaData.containsKey("Copyright"));
59
        assertTrue("IPCT data in the positive list of the includes", mediaData.containsKey("Artist"));
60
        assertTrue("IPCT data not in includes", !mediaData.containsKey("Writer"));
61
        assertEquals("Copyright (Notice) 2019.1 IPTC - www.iptc.org  (ref2019.1)", mediaData.get("Copyright"));
62
        assertEquals("Creator1 (ref2019.1)", mediaData.get("Artist"));
63
    }
64

    
65
    @Override
66
    public void createTestDataSet() throws FileNotFoundException {
67
        // no test data needed so far
68
    }
69

    
70
}
(13-13/40)