• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanopub-registry / 30893238389

04 Aug 2026 08:44AM UTC coverage: 83.415% (+51.1%) from 32.285%
30893238389

Pull #123

github

web-flow
Merge 84fad06c1 into e5ed6d462
Pull Request #123: Add unit tests for existing functionality

865 of 1112 branches covered (77.79%)

Branch coverage included in aggregate %.

2706 of 3169 relevant lines covered (85.39%)

12.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
src/main/java/com/knowledgepixels/registry/ResourcePage.java
1
package com.knowledgepixels.registry;
2

3
import com.mongodb.client.ClientSession;
4
import io.vertx.ext.web.RoutingContext;
5
import org.apache.commons.io.IOUtils;
6
import org.slf4j.Logger;
7
import org.slf4j.LoggerFactory;
8

9
import java.io.IOException;
10
import java.io.InputStream;
11
import java.util.Objects;
12

13
public class ResourcePage extends Page {
14

15
    private static final Logger logger = LoggerFactory.getLogger(ResourcePage.class);
12✔
16

17
    public static void show(RoutingContext context, String resourceName, String resourceType) {
18
        ResourcePage page;
19
        try (ClientSession s = RegistryDB.getClient().startSession()) {
9✔
20
            s.startTransaction();
6✔
21
            page = new ResourcePage(s, context, resourceName, resourceType);
24✔
22
            page.show();
6✔
23
        } catch (IOException ex) {
×
24
            logger.warn("Failed to show resource {} (type={}): {} ({})", resourceName, resourceType, ex.getMessage(), ex.getClass().getSimpleName(), ex);
×
25
        } finally {
26
            logger.debug("Ending response for resource {} (type={})", resourceName, resourceType);
15✔
27
            context.response().end();
12✔
28
            // TODO Clean-up here?
29
        }
30
    }
3✔
31

32
    private final String resourceName;
33
    private final String resourceType;
34

35
    public ResourcePage(ClientSession mongoSession, RoutingContext context, String resourceName, String resourceType) {
36
        super(mongoSession, context);
12✔
37
        this.resourceName = resourceName;
9✔
38
        this.resourceType = resourceType;
9✔
39
    }
3✔
40

41
    @Override
42
    public void show() throws IOException {
43
        setRespContentType(resourceType);
12✔
44
        logger.debug("Preparing to serve resource {} (type={})", resourceName, resourceType);
21✔
45
        try (InputStream in = MainVerticle.class.getResourceAsStream(resourceName);
15✔
46
             BufferOutputStream out = new BufferOutputStream()) {
12✔
47
            IOUtils.copy(Objects.requireNonNull(in), out);
18✔
48
            getContext().response().write(out.getBuffer());
21✔
49
            logger.info("Served resource {} (type={})", resourceName, resourceType);
21✔
50
        }
51
    }
3✔
52

53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc