aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble/mammoth/tests/docx/BodyXmlReaderMakers.java
blob: bb77b013eb99911d051e38f5a2d62104c2ad37b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.zwobble.mammoth.tests.docx;

import com.natpryce.makeiteasy.Instantiator;
import com.natpryce.makeiteasy.Property;
import org.zwobble.mammoth.docx.*;

import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;

import static com.natpryce.makeiteasy.Property.newProperty;

public class BodyXmlReaderMakers {
    public static final Property<BodyXmlReader, Styles> STYLES = newProperty();
    public static final Property<BodyXmlReader, Numbering> NUMBERING = newProperty();
    public static final Property<BodyXmlReader, Relationships> RELATIONSHIPS = newProperty();
    public static final Property<BodyXmlReader, ContentTypes> CONTENT_TYPES = newProperty();
    public static final Property<BodyXmlReader, DocxFile> DOCX_FILE = newProperty();
    public static final Property<BodyXmlReader, FileReader> FILE_READER = newProperty();

    public static final Instantiator<BodyXmlReader> bodyReader =
        propertyLookup -> new BodyXmlReader(
            propertyLookup.valueOf(STYLES, Styles.EMPTY),
            propertyLookup.valueOf(NUMBERING, Numbering.EMPTY),
            propertyLookup.valueOf(RELATIONSHIPS, Relationships.EMPTY),
            propertyLookup.valueOf(CONTENT_TYPES, ContentTypes.DEFAULT),
            propertyLookup.valueOf(DOCX_FILE, new DocxFile() {
                @Override
                public Optional<InputStream> tryGetInputStream(String name) throws IOException {
                    throw new UnsupportedOperationException();
                }

                @Override
                public void close() throws IOException {
                }
            }),
            propertyLookup.valueOf(FILE_READER, new FileReader() {
                @Override
                public InputStream getInputStream(String uri) throws IOException {
                    throw new UnsupportedOperationException();
                }
            }));
}