Project

General

Profile

Download (2.58 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.common.URI;
27
import eu.etaxonomy.cdm.model.media.ImageFile;
28
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
29
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
30
import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
31

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

    
38
    @SpringBeanByType
39
    private IMediaService mediaService;
40

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

    
45
    @BeforeClass
46
    static public void makeMedia() throws URISyntaxException {
47
        URL mediaURL = MediaServiceImplTest.class.getResource(imageFileName1);
48
        part1 = ImageFile.NewInstance(URI.fromUrl(mediaURL), null);
49
        repr1 = MediaRepresentation.NewInstance("image/jpeg", "jpg");
50
        repr1.addRepresentationPart(part1);
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
}
(12-12/37)