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

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

29 Jul 2025 01:16PM UTC coverage: 77.908% (+5.2%) from 72.712%
#552

Pull #264

github

web-flow
Merge 0f68003b1 into 201395eb2
Pull Request #264: Development branch for v3.0.0

654 of 791 new or added lines in 25 files covered. (82.68%)

3 existing lines in 2 files now uncovered.

1065 of 1367 relevant lines covered (77.91%)

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
    public void validateAttributes(
17
            PIDRecord pidRecord,
18
            boolean alwaysAllowAdditionalAttributes
19
    ) throws RecordValidationException
20
    {
21
        Set<String> attributesNotDefinedInProfile = pidRecord.getPropertyIdentifiers().stream()
1✔
22
                .filter(recordKey -> attributes.items().stream().noneMatch(
1✔
23
                        profileAttribute -> Objects.equals(profileAttribute.pid(), recordKey)))
1✔
24
                .collect(Collectors.toSet());
1✔
25

26

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

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