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

kit-data-manager / pit-service / #486

04 Mar 2025 01:58PM UTC coverage: 77.85% (+5.5%) from 72.4%
#486

Pull #264

github

web-flow
Merge 2aba06f55 into 534c1d4a6
Pull Request #264: Development branch for v3.0.0

370 of 466 new or added lines in 22 files covered. (79.4%)

2 existing lines in 1 file now uncovered.

956 of 1228 relevant lines covered (77.85%)

0.78 hits per line

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

72.73
/src/main/java/edu/kit/datamanager/pit/typeregistry/RegisteredProfile.java
1
package edu.kit.datamanager.pit.typeregistry;
2

3
import edu.kit.datamanager.pit.common.RecordValidationException;
4
import edu.kit.datamanager.pit.domain.ImmutableList;
5
import edu.kit.datamanager.pit.domain.PIDRecord;
6

7
import java.util.Objects;
8
import java.util.Set;
9
import java.util.stream.Collectors;
10

11
public record RegisteredProfile(
1✔
12
        String pid,
13
        boolean allowAdditionalAttributes,
14
        ImmutableList<RegisteredProfileAttribute> attributes
15
) {
16

17
    public void validateAttributes(PIDRecord pidRecord, boolean alwaysAllowAdditionalAttributes) {
18
        Set<String> attributesNotDefinedInProfile = pidRecord.getPropertyIdentifiers().stream()
1✔
19
                .filter(recordKey -> attributes.items().stream().anyMatch(
1✔
20
                        profileAttribute -> Objects.equals(profileAttribute.pid(), recordKey)))
1✔
21
                .collect(Collectors.toSet());
1✔
22

23

24
        boolean additionalAttributesForbidden = !this.allowAdditionalAttributes && !alwaysAllowAdditionalAttributes;
1✔
25
        boolean violatesAdditionalAttributes = additionalAttributesForbidden && !attributesNotDefinedInProfile.isEmpty();
1✔
26
        if (violatesAdditionalAttributes) {
1✔
NEW
27
            throw new RecordValidationException(
×
28
                    pidRecord,
NEW
29
                    String.format("Attributes %s are not allowed in profile %s",
×
NEW
30
                            String.join(", ", attributesNotDefinedInProfile),
×
31
                            this.pid)
32
            );
33
        }
34

35
        for (RegisteredProfileAttribute profileAttribute : this.attributes.items()) {
1✔
36
            if (profileAttribute.violatesMandatoryProperty(pidRecord)) {
1✔
37
                throw new RecordValidationException(
1✔
38
                        pidRecord,
39
                        String.format("Attribute %s missing, but is mandatory in profile %s",
1✔
40
                                profileAttribute.pid(),
1✔
41
                                this.pid)
42
                );
43
            }
44
            if (profileAttribute.violatesRepeatableProperty(pidRecord)) {
1✔
NEW
45
                throw new RecordValidationException(
×
46
                        pidRecord,
NEW
47
                        String.format("Attribute %s is not repeatable in profile %s, but has multiple values",
×
NEW
48
                                profileAttribute.pid(),
×
49
                                this.pid)
50
                );
51
            }
52
        }
1✔
53
    }
1✔
54
}
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