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

leeonky / test-charm-java / 150

07 Mar 2025 12:58AM UTC coverage: 74.287% (-0.08%) from 74.367%
150

push

circleci

leeonky
Try to fix ci

7919 of 10660 relevant lines covered (74.29%)

0.74 hits per line

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

96.0
/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.util.BeanClass;
6
import com.github.leeonky.util.NoSuchAccessorException;
7

8
import java.util.Set;
9

10
import static com.github.leeonky.dal.runtime.Order.BUILD_IN;
11
import static java.lang.String.format;
12

13
@Order(BUILD_IN)
14
public class MetaProperties implements Extension {
1✔
15
    private static Object size(MetaData metaData) {
16
        Data data = metaData.data();
1✔
17
        if (data.isList())
1✔
18
            return data.list().size();
1✔
19
        throw new IllegalStateException(format("Invalid meta property `size` for: %s", data.dumpAll()));
1✔
20
    }
21

22
    private static Object throw_(MetaData metaData) {
23
        Throwable error = metaData.catchError();
1✔
24
        if (error == null)
1✔
25
            throw new AssertionError("Expecting an error to be thrown, but nothing was thrown");
1✔
26
        return error;
1✔
27
    }
28

29
    private static Object object_(MetaData metaData) {
30
        return metaData.data().instance() == null ? null : new OriginalJavaObject(metaData.data());
1✔
31
    }
32

33
    private static Object keys(MetaData metaData) {
34
        return metaData.data().fieldNames();
1✔
35
    }
36

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

47
    static class OriginalJavaObject implements ProxyObject {
48
        private final Data data;
49

50
        public OriginalJavaObject(Data data) {
1✔
51
            this.data = data;
1✔
52
        }
1✔
53

54
        @Override
55
        public Object getValue(Object property) {
56
            try {
57
                Object instance = data.instance();
1✔
58
                return BeanClass.createFrom(instance).getPropertyValue(instance, property.toString());
1✔
59
            } catch (NoSuchAccessorException ignore) {
1✔
60
                return data.getValue(property).instance();
1✔
61
            }
62
        }
63

64
        @Override
65
        public Set<?> getPropertyNames() {
66
            return BeanClass.createFrom(data.instance()).getPropertyReaders().keySet();
×
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