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

trydofor / professional-wings / #125

31 Aug 2024 04:46AM UTC coverage: 63.579% (+0.7%) from 62.919%
#125

push

web-flow
Merge pull request #290 from trydofor/develop

3.2.130

1428 of 2191 new or added lines in 106 files covered. (65.18%)

41 existing lines in 24 files now uncovered.

12923 of 20326 relevant lines covered (63.58%)

0.64 hits per line

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

18.75
/radiant/tiny-mail/src/main/java/pro/fessional/wings/tiny/mail/sender/MailConfigProvider.java
1
package pro.fessional.wings.tiny.mail.sender;
2

3
import lombok.Getter;
4
import lombok.RequiredArgsConstructor;
5
import lombok.Setter;
6
import org.jetbrains.annotations.Contract;
7
import org.jetbrains.annotations.NotNull;
8
import org.jetbrains.annotations.Nullable;
9
import org.springframework.beans.factory.annotation.Autowired;
10
import pro.fessional.wings.tiny.mail.spring.prop.TinyMailConfigProp;
11

12
import java.util.Collections;
13
import java.util.List;
14

15
/**
16
 * @author trydofor
17
 * @since 2022-12-31
18
 */
19
@RequiredArgsConstructor
20
public class MailConfigProvider {
21

22
    @NotNull
23
    private final TinyMailConfigProp configProp;
24

25
    @Setter(onMethod_ = { @Autowired(required = false) })
26
    @Getter
27
    private List<TinyMailConfig.Loader> configLoader = Collections.emptyList();
28

29
    @NotNull
30
    public TinyMailConfig defaultConfig() {
31
        return configProp.getDefault();
1✔
32
    }
33

34
    @Nullable
35
    public TinyMailConfig bynamedConfig(String name) {
36
        if (name == null || name.isEmpty()) {
1✔
37
            return defaultConfig();
1✔
38
        }
39

40
        TinyMailConfig conf = configProp.get(name);
×
41
        if (conf == null && configLoader != null) {
×
42
            for (TinyMailConfig.Loader ld : configLoader) {
×
43
                final TinyMailConfig cf = ld.load(name);
×
44
                if (cf != null) {
×
45
                    conf = cf;
×
46
                    break;
×
47
                }
48
            }
×
49
        }
50

51
        return conf;
×
52
    }
53

54
    @Contract("_->new")
55
    public TinyMailConfig combineConfig(@Nullable TinyMailConfig that) {
56
        final TinyMailConfig newConf = new TinyMailConfig();
×
NEW
57
        TinyMailConfig.ConfSetter.toAny(newConf, that);
×
NEW
58
        TinyMailConfig.ConfSetter.toInvalid(newConf, configProp.getDefault());
×
UNCOV
59
        return newConf;
×
60
    }
61
}
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

© 2025 Coveralls, Inc