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

leeonky / test-charm-java / 258

24 Aug 2025 09:55AM UTC coverage: 74.261% (-0.006%) from 74.267%
258

push

circleci

leeonky
Remove arg-range support of method

1 of 1 new or added line in 1 file covered. (100.0%)

3 existing lines in 3 files now uncovered.

8067 of 10863 relevant lines covered (74.26%)

0.74 hits per line

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

96.55
/DAL-java/src/main/java/com/github/leeonky/dal/extensions/MetaShould.java
1
package com.github.leeonky.dal.extensions;
2

3
import com.github.leeonky.dal.runtime.*;
4

5
import static java.lang.String.format;
6

7
public class MetaShould implements ProxyObject {
8
    private final MetaData<?> metaData;
9
    private final boolean negative;
10

11
    public MetaShould(MetaData<?> metaData) {
12
        this(metaData, false);
1✔
13
    }
1✔
14

15
    public MetaShould(MetaData<?> metaData, boolean negative) {
1✔
16
        this.metaData = metaData;
1✔
17
        this.negative = negative;
1✔
18
    }
1✔
19

20
    @Override
21
    public Object getValue(Object property) {
22
        return metaData.data().currying(property).map(curryingMethod -> new PredicateMethod(curryingMethod, property))
1✔
23
                .orElseThrow(() -> new DALRuntimeException(format("Predicate method %s not exist in %s",
1✔
24
                        property, metaData.data().dump())));
1✔
25
    }
26

27
    public MetaShould negative() {
28
        return new MetaShould(metaData, !negative);
1✔
29
    }
30

31
    public class PredicateMethod implements ProxyObject {
32
        private final CurryingMethodGroup curryingMethodGroup;
33
        private final Object method;
34

35
        public PredicateMethod(CurryingMethodGroup curryingMethodGroup, Object method) {
1✔
36
            this.curryingMethodGroup = curryingMethodGroup;
1✔
37
            this.method = method;
1✔
38
        }
1✔
39

40
        public boolean should(Object value) {
41
            Object result = curryingMethodGroup.call(value).resolve();
1✔
42
            if (result instanceof CurryingMethod)
1✔
43
                throw new DALRuntimeException(format("Failed to invoke predicate method `%s` of %s, " +
1✔
44
                        "maybe missing parameters", method, metaData.data().dump()));
1✔
45
            if (result instanceof Boolean) {
1✔
46
                if (negative)
1✔
47
                    return !(boolean) result;
1✔
48
                return (boolean) result;
1✔
49
            }
50
            throw new DALRuntimeException(format("Predicate method `%s` return type should boolean but %s", method,
1✔
51
                    metaData.runtimeContext().data(result).dump()));
1✔
52
        }
53

54
        public Data<?> instance() {
55
            return metaData.data();
1✔
56
        }
57

58
        public String errorMessage(Data<?> expected) {
59
            if (negative)
1✔
60
                return format("Expected: %s\nShould not %s: %s", instance().dump(), method, expected.dump());
1✔
61
            return format("Expected: %s\nShould %s: %s", instance().dump(), method, expected.dump());
1✔
62
        }
63

64
        @Override
65
        public Object getValue(Object property) {
UNCOV
66
            return new PredicateMethod(curryingMethodGroup.call(property), method);
×
67
        }
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc