Skip to content

Commit d4e8bf5

Browse files
committed
Slight refactor from comments
1 parent 566367b commit d4e8bf5

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

multiapps-controller-core/src/test/java/org/cloudfoundry/multiapps/controller/core/model/SupportedParameterTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import org.junit.jupiter.api.Test;
1212

13-
import static org.junit.jupiter.api.Assertions.fail;
13+
import static org.junit.jupiter.api.Assertions.assertTrue;
1414

1515
public class SupportedParameterTest {
1616

@@ -36,16 +36,15 @@ public class SupportedParameterTest {
3636
@Test
3737
public void allFieldsShouldBeWhitelisted() throws IllegalAccessException {
3838
Set<String> supportedParameters = getSupportedParameters();
39-
Collection<String> strings = getClassStringFieldsFromClass();
39+
Collection<String> strings = discoverAllParameterConstants();
4040

4141
Set<String> missing = strings.stream()
4242
.filter(f -> !supportedParameters.contains(f))
4343
.collect(Collectors.toSet());
4444

45-
if (!missing.isEmpty()) {
46-
fail("The following parameters are defined, but are not added to any structure: " + missing +
47-
".\nTo resolve this, add the missing parameters to the appropriate collection in the SupportedParameters class.");
48-
}
45+
assertTrue(missing.isEmpty(),
46+
() -> "The following parameters are defined, but are not added to any structure: " + missing +
47+
".\nTo resolve this, add the missing parameters to the appropriate collection in the SupportedParameters class.");
4948
}
5049

5150
private Set<String> getSupportedParameters() {
@@ -73,7 +72,7 @@ private void fillWithNonEntitySpecificSupportedParameters(Set<String> supportedP
7372
supportedParameters.addAll(NESTED_PARAMETERS);
7473
}
7574

76-
private Collection<String> getClassStringFieldsFromClass() throws IllegalAccessException {
75+
private Collection<String> discoverAllParameterConstants() throws IllegalAccessException {
7776
Collection<String> strings = new ArrayList<>();
7877
Class<?> clazz = SupportedParameters.class;
7978
for (Field field : clazz.getDeclaredFields()) {

0 commit comments

Comments
 (0)