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

leeonky / test-charm-java / 236

26 Apr 2025 09:05AM UTC coverage: 74.134% (+0.08%) from 74.053%
236

push

circleci

leeonky
Update version

8048 of 10856 relevant lines covered (74.13%)

0.74 hits per line

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

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

3
import com.github.leeonky.dal.DAL;
4
import com.github.leeonky.dal.runtime.*;
5
import com.github.leeonky.dal.runtime.checker.Checker;
6
import com.github.leeonky.dal.runtime.checker.CheckingContext;
7
import com.github.leeonky.util.BeanClass;
8
import com.github.leeonky.util.NoSuchAccessorException;
9
import com.github.leeonky.util.Sneaky;
10

11
import java.util.Set;
12

13
import static com.github.leeonky.dal.runtime.DalException.extractException;
14
import static com.github.leeonky.dal.runtime.Order.BUILD_IN;
15

16
@Order(BUILD_IN)
17
public class MetaProperties implements Extension {
1✔
18
    private static Object size(MetaData<?> metaData) {
19
        return metaData.data().list().size();
1✔
20
    }
21

22
    private static Object throw_(MetaData<?> metaData) {
23
        try {
24
            metaData.data().value();
1✔
25
            throw new AssertionError("Expecting an error to be thrown, but nothing was thrown");
1✔
26
        } catch (Exception e) {
1✔
27
            return Sneaky.get(() -> extractException(e).orElseThrow(() -> e));
1✔
28
        }
29
    }
30

31
    private static Object object_(MetaData<?> metaData) {
32
        return metaData.data().value() == null ? null : new OriginalJavaObject(metaData.data());
1✔
33
    }
34

35
    private static Object keys(MetaData<?> metaData) {
36
        return metaData.data().fieldNames();
1✔
37
    }
38

39
    @Override
40
    public void extend(DAL dal) {
41
        dal.getRuntimeContextBuilder()
1✔
42
                .registerMetaProperty("size", MetaProperties::size)
1✔
43
                .registerMetaProperty("throw", MetaProperties::throw_)
1✔
44
                .registerMetaProperty("object", MetaProperties::object_)
1✔
45
                .registerMetaProperty("keys", MetaProperties::keys)
1✔
46
                .registerMetaProperty("should", MetaShould::new)
1✔
47
        ;
48

49
        dal.getRuntimeContextBuilder().checkerSetForMatching()
1✔
50
                .register((expected, actual) -> actual.cast(MetaShould.PredicateMethod.class)
1✔
51
                        .map(curryingMethod -> new Checker() {
1✔
52
                            @Override
53
                            public boolean failed(CheckingContext checkingContext) {
54
                                return !curryingMethod.should(expected.value());
1✔
55
                            }
56

57
                            @Override
58
                            public String message(CheckingContext checkingContext) {
59
                                return curryingMethod.errorMessage(expected);
1✔
60
                            }
61
                        }));
62
    }
1✔
63

64
    static class OriginalJavaObject implements ProxyObject {
65
        private final Data<?> data;
66

67
        public OriginalJavaObject(Data<?> data) {
1✔
68
            this.data = data;
1✔
69
        }
1✔
70

71
        @Override
72
        public Object getValue(Object property) {
73
            try {
74
                Object instance = data.value();
1✔
75
                return BeanClass.createFrom(instance).getPropertyValue(instance, property.toString());
1✔
76
            } catch (NoSuchAccessorException ignore) {
1✔
77
                return data.property(property).value();
1✔
78
            }
79
        }
80

81
        @Override
82
        public Set<?> getPropertyNames() {
83
            return BeanClass.createFrom(data.value()).getPropertyReaders().keySet();
×
84
        }
85
    }
86
}
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