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

leeonky / test-charm-java / 284

03 Sep 2025 03:51PM UTC coverage: 74.307% (-0.01%) from 74.317%
284

push

circleci

leeonky
Refator

30 of 30 new or added lines in 2 files covered. (100.0%)

9 existing lines in 3 files now uncovered.

8098 of 10898 relevant lines covered (74.31%)

0.74 hits per line

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

96.97
/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.CurryingMethod;
4
import com.github.leeonky.dal.runtime.DALRuntimeException;
5
import com.github.leeonky.dal.runtime.MetaData;
6
import com.github.leeonky.dal.runtime.ProxyObject;
7

8
import static com.github.leeonky.dal.runtime.inspector.DumpingBuffer.rootContext;
9
import static java.lang.String.format;
10

11
public class MetaShould implements ProxyObject {
12
    private final MetaData<?> metaData;
13
    private final boolean negative;
14

15
    public MetaShould(MetaData<?> metaData) {
16
        this(metaData, false);
1✔
17
    }
1✔
18

19
    public MetaShould(MetaData<?> metaData, boolean negative) {
1✔
20
        this.metaData = metaData;
1✔
21
        this.negative = negative;
1✔
22
    }
1✔
23

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

31
    public MetaShould negative() {
32
        return new MetaShould(metaData, !negative);
1✔
33
    }
34

35
    public class PredicateMethod implements ProxyObject {
36
        private final CurryingMethod curryingMethod;
37
        private final Object methodName;
38

39
        public PredicateMethod(CurryingMethod curryingMethod, Object methodName) {
1✔
40
            this.curryingMethod = curryingMethod;
1✔
41
            this.methodName = methodName;
1✔
42
        }
1✔
43

44
        public boolean should() {
45
            Object result = curryingMethod.resolve();
1✔
46
            if (result instanceof CurryingMethod)
1✔
47
                throw new DALRuntimeException(rootContext(metaData.runtimeContext())
1✔
48
                        .append("Failed to invoke predicate method `").append(methodName.toString())
1✔
49
                        .append("`, maybe missing parameters, all candidate methods are:")
1✔
50
                        .indent(curryingMethod::dumpCandidates).content());
1✔
51
            if (result instanceof Boolean)
1✔
52
                return negative != (boolean) result;
1✔
53
            throw new DALRuntimeException(rootContext(metaData.runtimeContext())
1✔
54
                    .append("Predicate method `").append(methodName.toString()).append("` should return boolean but ")
1✔
55
                    .dump(metaData.runtimeContext().data(result)).newLine()
1✔
56
                    .append("all candidate methods are:")
1✔
57
                    .indent(curryingMethod::dumpCandidates).content());
1✔
58
        }
59

60
        public String errorMessage() {
61
            return rootContext(metaData.runtimeContext())
1✔
62
                    .append("Expected: ").dump(metaData.data()).newLine()
1✔
63
                    .append("Should").append(negative ? " not" : "").append(" ").append(methodName.toString()).append(":")
1✔
64
                    .indent(curryingMethod.getResolvedMethod()::dumpArguments).content();
1✔
65
        }
66

67
        public CurryingMethod curryingMethodGroup() {
UNCOV
68
            return curryingMethod;
×
69
        }
70

71
        @Override
72
        public Object getValue(Object property) {
73
            return new PredicateMethod(curryingMethod.call(property), methodName);
1✔
74
        }
75
    }
76
}
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