1
2
3
4
5 package com.qulice.maven;
6
7 import com.qulice.spi.ResourceValidator;
8 import com.qulice.spi.Validator;
9 import java.util.Collection;
10 import java.util.HashSet;
11 import java.util.Set;
12
13
14
15
16
17 final class ValidatorsProviderMocker {
18
19
20
21
22 private final Set<Validator> external = new HashSet<>();
23
24
25
26
27 private final transient Set<ResourceValidator> rexternal = new HashSet<>();
28
29
30
31
32 private final Set<MavenValidator> internal = new HashSet<>();
33
34
35
36
37
38
39 public ValidatorsProviderMocker withExternal(final Validator validator) {
40 this.external.add(validator);
41 return this;
42 }
43
44
45
46
47
48
49 public ValidatorsProviderMocker withExternalResource(
50 final ResourceValidator validator) {
51 this.rexternal.add(validator);
52 return this;
53 }
54
55
56
57
58
59
60 public ValidatorsProviderMocker withInternal(
61 final MavenValidator validator) {
62 this.internal.add(validator);
63 return this;
64 }
65
66
67
68
69
70 public ValidatorsProvider mock() {
71 return new FakeValidatorsProvider(
72 this.internal,
73 this.external,
74 this.rexternal
75 );
76 }
77
78
79
80
81
82
83
84 private static class FakeValidatorsProvider implements ValidatorsProvider {
85
86
87
88 private final Set<MavenValidator> intern;
89
90
91
92
93 private final Set<Validator> extern;
94
95
96
97
98 private final Set<ResourceValidator> rextern;
99
100 FakeValidatorsProvider(
101 final Set<MavenValidator> inter,
102 final Set<Validator> exter,
103 final Set<ResourceValidator> rexter
104 ) {
105 this.intern = inter;
106 this.extern = exter;
107 this.rextern = rexter;
108 }
109
110 @Override
111 public Set<MavenValidator> internal() {
112 return this.intern;
113 }
114
115 @Override
116 public Set<Validator> external() {
117 return this.extern;
118 }
119
120 @Override
121 public Collection<ResourceValidator> externalResource() {
122 return this.rextern;
123 }
124 }
125 }