• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

leeonky / test-charm-java / 329

01 Oct 2025 04:21PM UTC coverage: 74.68% (+0.03%) from 74.648%
329

push

circleci

leeonky
depends on primitive default value sub property

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

13 existing lines in 4 files now uncovered.

8565 of 11469 relevant lines covered (74.68%)

0.75 hits per line

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

88.64
/jfactory/src/main/java/com/github/leeonky/jfactory/DefaultListConsistency.java
1
package com.github.leeonky.jfactory;
2

3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.function.Function;
6

7
import static com.github.leeonky.jfactory.DefaultConsistency.LINK_COMPOSER;
8
import static com.github.leeonky.jfactory.DefaultConsistency.LINK_DECOMPOSER;
9
import static com.github.leeonky.jfactory.PropertyChain.propertyChain;
10
import static java.util.Arrays.asList;
11
import static java.util.Collections.singletonList;
12
import static java.util.stream.IntStream.range;
13

14
class DefaultListConsistency<T> implements ListConsistency<T> {
15
    private final PropertyChain listProperty;
16
    private final Consistency<T> consistency;
17
    private final List<ListConsistencyItem<T>> items = new ArrayList<>();
1✔
18
    private final List<DefaultListConsistency<?>> list = new ArrayList<>();
1✔
19

20
    DefaultListConsistency(String listProperty, Consistency<T> consistency) {
1✔
21
        this.listProperty = propertyChain(listProperty);
1✔
22
        this.consistency = consistency;
1✔
23
    }
1✔
24

25
    @Override
26
    @SuppressWarnings("unchecked")
27
    public ListConsistency<T> direct(String property) {
28
        return property(property).read((Function<Object, T>) LINK_COMPOSER).write((Function<T, Object>) LINK_DECOMPOSER);
1✔
29
    }
30

31
    @Override
32
    public <P> ListConsistency.LC1<T, P> property(String property) {
33
        ListConsistencyItem<T> listConsistencyItem = new ListConsistencyItem<>(singletonList(property));
1✔
34
        items.add(listConsistencyItem);
1✔
35
        return new DefaultListConsistency.LC1<>(this, listConsistencyItem);
1✔
36
    }
37

38
    @Override
39
    public <P1, P2> ListConsistency.LC2<T, P1, P2> properties(String property1, String property2) {
40
        ListConsistencyItem<T> listConsistencyItem = new ListConsistencyItem<>(asList(property1, property2));
1✔
41
        items.add(listConsistencyItem);
1✔
42
        return new DefaultListConsistency.LC2<>(this, listConsistencyItem);
1✔
43
    }
44

45
    @Override
46
    public <P1, P2, P3> LC3<T, P1, P2, P3> properties(String property1, String property2, String property3) {
47
        ListConsistencyItem<T> listConsistencyItem = new ListConsistencyItem<>(asList(property1, property2, property3));
1✔
48
        items.add(listConsistencyItem);
1✔
49
        return new LC3<>(this, listConsistencyItem);
1✔
50
    }
51

52
    void populateConsistencies(ObjectProducer<?> producer, PropertyChain parentList) {
53
        PropertyChain listProperty = parentList.concat(this.listProperty);
1✔
54
        Producer<?> descendant = producer.descendantForUpdate(listProperty);
1✔
55
        if (!(descendant instanceof CollectionProducer))
1✔
UNCOV
56
            throw new IllegalStateException(listProperty + " is not List");
×
57
        range(0, ((CollectionProducer<?, ?>) descendant).childrenCount()).mapToObj(listProperty::concat)
1✔
58
                .forEach(elementProperty -> populateElementConsistency(producer, elementProperty));
1✔
59
    }
1✔
60

61
    private void populateElementConsistency(ObjectProducer<?> producer, PropertyChain elementProperty) {
62
        items.forEach(item -> item.populateConsistency(elementProperty, consistency));
1✔
63
        list.forEach(listConsistency -> listConsistency.populateConsistencies(producer, elementProperty));
1✔
64
    }
1✔
65

66
    @Override
67
    public NestedListConsistencyBuilder<T> list(String property) {
68
        DefaultListConsistency<T> listConsistency = new DefaultListConsistency<>(property, consistency);
1✔
69
        list.add(listConsistency);
1✔
70
        return new NestedListConsistencyBuilder<>(this, listConsistency);
1✔
71
    }
72
}
73

74
class DecorateListConsistency<T> implements ListConsistency<T> {
75
    private final ListConsistency<T> delegate;
76

77
    public DecorateListConsistency(ListConsistency<T> delegate) {
1✔
78
        this.delegate = delegate;
1✔
79
    }
1✔
80

81
    @Override
82
    public ListConsistency<T> direct(String property) {
83
        return delegate.direct(property);
1✔
84
    }
85

86
    @Override
87
    public <P> ListConsistency.LC1<T, P> property(String property) {
UNCOV
88
        return delegate.property(property);
×
89
    }
90

91
    @Override
92
    public <P1, P2> ListConsistency.LC2<T, P1, P2> properties(String property1, String property2) {
UNCOV
93
        return delegate.properties(property1, property2);
×
94
    }
95

96
    @Override
97
    public <P1, P2, P3> LC3<T, P1, P2, P3> properties(String property1, String property2, String property3) {
UNCOV
98
        return delegate.properties(property1, property2, property3);
×
99
    }
100

101
    @Override
102
    public NestedListConsistencyBuilder<T> list(String property) {
UNCOV
103
        return delegate.list(property);
×
104
    }
105
}
106

107
class MultiPropertyListConsistency<T, C extends MultiPropertyListConsistency<T, C>> extends DecorateListConsistency<T> {
108
    final ListConsistencyItem<T> last;
109

110
    MultiPropertyListConsistency(ListConsistency<T> delegate, ListConsistencyItem<T> last) {
111
        super(delegate);
1✔
112
        this.last = last;
1✔
113
    }
1✔
114

115
    @SuppressWarnings("unchecked")
116
    public C read(Function<Object[], T> composer) {
117
        last.setComposer(new ComposerWrapper<>(composer, composer));
1✔
118
        return (C) this;
1✔
119
    }
120

121
    @SuppressWarnings("unchecked")
122
    public C write(Function<T, Object[]> decomposer) {
123
        last.setDecomposer(new DecomposerWrapper<>(decomposer, decomposer));
1✔
124
        return (C) this;
1✔
125
    }
126
}
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