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

leeonky / test-charm-java / 252

02 Aug 2025 11:17AM UTC coverage: 74.246% (-0.01%) from 74.26%
252

push

circleci

leeonky
Update exception output

4 of 6 new or added lines in 3 files covered. (66.67%)

8075 of 10876 relevant lines covered (74.25%)

0.74 hits per line

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

87.5
/DAL-java/src/main/java/com/github/leeonky/dal/Assertions.java
1
package com.github.leeonky.dal;
2

3
import com.github.leeonky.dal.ast.node.ConstValueNode;
4
import com.github.leeonky.dal.ast.node.InputNode;
5
import com.github.leeonky.dal.ast.opt.Factory;
6
import com.github.leeonky.dal.runtime.Data;
7
import com.github.leeonky.dal.runtime.IllegalTypeException;
8
import com.github.leeonky.dal.runtime.RuntimeContextBuilder;
9
import com.github.leeonky.dal.runtime.schema.Expect;
10
import com.github.leeonky.dal.runtime.schema.Verification;
11
import com.github.leeonky.dal.type.InputCode;
12
import com.github.leeonky.interpreter.InterpreterException;
13
import com.github.leeonky.util.ThrowingSupplier;
14

15
import java.lang.reflect.Array;
16
import java.util.function.Supplier;
17

18
import static com.github.leeonky.dal.ast.node.DALExpression.expression;
19
import static com.github.leeonky.dal.runtime.schema.Actual.actual;
20
import static com.github.leeonky.util.BeanClass.create;
21

22
public class Assertions {
23
    private final InputCode<Object> inputCode;
24
    public static boolean dumpInput = true;
1✔
25
    private DAL dal;
26
    private static Supplier<DAL> dalFactory = () -> DAL.dal("AssertD");
1✔
27
    private Class<?> schema;
28

29
    public static void setDALFactory(Supplier<DAL> dalFactory) {
30
        Assertions.dalFactory = dalFactory;
×
31
    }
×
32

33
    public static void dumpInput(boolean enable) {
34
        dumpInput = enable;
1✔
35
    }
1✔
36

37
    private Assertions(InputCode<Object> input) {
1✔
38
        inputCode = input;
1✔
39
    }
1✔
40

41
    public Assertions use(DAL dal) {
42
        this.dal = dal;
1✔
43
        return this;
1✔
44
    }
45

46
    public static Assertions expect(Object input) {
47
        return new Assertions(() -> input);
1✔
48
    }
49

50
    public static Assertions expectRun(ThrowingSupplier<Object> supplier) {
51
        return new Assertions(supplier::get);
1✔
52
    }
53

54
    public Assertions should(String dalExpression) {
55
        return should("", dalExpression);
1✔
56
    }
57

58
    public Assertions should(String prefix, String verification) {
59
        String fullCode = prefix + verification;
1✔
60
        try {
61
            getDAL().evaluate(inputCode, fullCode, schema);
1✔
62
            return this;
1✔
63
        } catch (InterpreterException e) {
1✔
64
            String detailMessage = e.show(fullCode, prefix.length()) + "\n\n" + e.getMessage();
1✔
65
            if (dumpInput)
1✔
66
                detailMessage += "\n\nThe root value was: " + getDAL().getRuntimeContextBuilder().build(inputCode).getThis().dump();
1✔
67
            throw new AssertionError(detailMessage) {
1✔
68
                @Override
69
                public String toString() {
NEW
70
                    return AssertionError.class.getName() + ":\n" + getMessage();
×
71
                }
72
            };
73
        }
74
    }
75

76
    private DAL getDAL() {
77
        if (dal == null)
1✔
78
            dal = dalFactory.get();
1✔
79
        return dal;
1✔
80
    }
81

82
    public void exact(String verification) {
83
        should("=", verification);
1✔
84
    }
1✔
85

86
    public void match(String verification) {
87
        should(":", verification);
1✔
88
    }
1✔
89

90
    @SuppressWarnings("unchecked")
91
    public Assertions is(Class<?> schema) {
92
        RuntimeContextBuilder.DALRuntimeContext context = getDAL().getRuntimeContextBuilder().build(inputCode, schema);
1✔
93
        Data<?> input = context.getThis();
1✔
94
        try {
95
            this.schema = schema;
1✔
96
            Verification.expect(new Expect(create((Class) schema), null))
1✔
97
                    .verify(context, actual(context.getThis()));
1✔
98
            return this;
1✔
99
        } catch (IllegalTypeException e) {
1✔
100
            String detailMessage = "\n" + e.getMessage();
1✔
101
            if (dumpInput)
1✔
102
                detailMessage += "\n\nThe root value was: " + input.dump();
1✔
103
            throw new AssertionError(detailMessage);
1✔
104
        }
105
    }
106

107
    public Assertions is(String schema) {
108
        if (schema.startsWith("[") && schema.endsWith("]"))
1✔
109
            return is(Array.newInstance(getDAL().getRuntimeContextBuilder().schemaType(
1✔
110
                    schema.replace('[', ' ').replace(']', ' ').trim()).getType(), 0).getClass());
1✔
111
        return is(getDAL().getRuntimeContextBuilder().schemaType(schema).getType());
1✔
112
    }
113

114
    public Assertions isEqualTo(Object expect) {
115
        expression(InputNode.INPUT_NODE, Factory.equal(), new ConstValueNode(expect))
×
116
                .evaluate(getDAL().getRuntimeContextBuilder().build(inputCode));
×
117
        return this;
×
118
    }
119
}
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