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

leeonky / test-charm-java / 156

20 Mar 2025 01:53PM UTC coverage: 74.243% (-0.2%) from 74.475%
156

push

circleci

leeonky
Refactor

14 of 15 new or added lines in 12 files covered. (93.33%)

126 existing lines in 29 files now uncovered.

7947 of 10704 relevant lines covered (74.24%)

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
import com.github.leeonky.util.Sneaky;
8

9
import java.util.Set;
10

11
import static com.github.leeonky.dal.runtime.DalException.extractException;
12
import static com.github.leeonky.dal.runtime.Order.BUILD_IN;
13
import static java.lang.String.format;
14

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

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

33
    private static Object object_(MetaData metaData) {
34
        return metaData.data().instance() == null ? null : new OriginalJavaObject(metaData.data());
1✔
35
    }
36

37
    private static Object keys(MetaData metaData) {
38
        return metaData.data().resolved().fieldNames();
1✔
39
    }
40

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

51
    static class OriginalJavaObject implements ProxyObject {
52
        private final Data data;
53

54
        public OriginalJavaObject(Data data) {
1✔
55
            this.data = data;
1✔
56
        }
1✔
57

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

68
        @Override
69
        public Set<?> getPropertyNames() {
UNCOV
70
            return BeanClass.createFrom(data.instance()).getPropertyReaders().keySet();
×
71
        }
72
    }
73
}
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