Code review comment: This kind of thing is exactly why I LOVE AssertJ :)

Code before review:
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir)
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json"))
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml"));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("kubernetes.yml"));
assertThat(kubernetesList).filteredOn(h -> "Role".equals(h.getKind())).hasSize(1);
assertThat(kubernetesList).anySatisfy(res -> {
assertThat(res).isInstanceOfSatisfying(Role.class, role -> {
assertThat(role.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("view-secrets");
});
assertThat(role.getRules()).hasOnlyOneElementSatisfying(r -> {
assertThat(r).isInstanceOfSatisfying(PolicyRule.class, rule -> {
assertThat(rule.getApiGroups()).containsExactly("");
assertThat(rule.getResources()).containsExactly("secrets");
assertThat(rule.getVerbs()).containsExactly("get", "list", "watch");
});
});
});
});
assertThat(kubernetesList).filteredOn(h -> "RoleBinding".equals(h.getKind())).hasSize(2);
assertThat(kubernetesList).anySatisfy(res -> {
assertThat(res).isInstanceOfSatisfying(RoleBinding.class, roleBinding -> {
assertThat(roleBinding.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("kubernetes-config-with-secrets:view-secrets");
});
assertThat(roleBinding.getRoleRef().getKind()).isEqualTo("Role");
assertThat(roleBinding.getRoleRef().getName()).isEqualTo("view-secrets");
assertThat(roleBinding.getSubjects()).hasOnlyOneElementSatisfying(subject -> {
assertThat(subject.getKind()).isEqualTo("ServiceAccount");
assertThat(subject.getName()).isEqualTo("kubernetes-config-with-secrets");
});
});
});
assertThat(kubernetesList).anySatisfy(res -> {
assertThat(res).isInstanceOfSatisfying(RoleBinding.class, roleBinding -> {
assertThat(roleBinding.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("kubernetes-config-with-secrets:view");
});
assertThat(roleBinding.getRoleRef().getKind()).isEqualTo("ClusterRole");
assertThat(roleBinding.getRoleRef().getName()).isEqualTo("view");
assertThat(roleBinding.getSubjects()).hasOnlyOneElementSatisfying(subject -> {
assertThat(subject.getKind()).isEqualTo("ServiceAccount");
assertThat(subject.getName()).isEqualTo("kubernetes-config-with-secrets");
});
});
});
}

Line under review: assertThat(rule.getVerbs()).containsExactly("get", "list", "watch");

Code after addressing the review:
public void assertGeneratedResources() throws IOException {
Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir)
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json"))
.isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml"));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("kubernetes.yml"));
assertThat(kubernetesList).filteredOn(h -> "Role".equals(h.getKind())).hasSize(1);
assertThat(kubernetesList).anySatisfy(res -> {
assertThat(res).isInstanceOfSatisfying(Role.class, role -> {
assertThat(role.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("view-secrets");
});
assertThat(role.getRules()).hasOnlyOneElementSatisfying(r -> {
assertThat(r).isInstanceOfSatisfying(PolicyRule.class, rule -> {
assertThat(rule.getApiGroups()).containsExactly("");
assertThat(rule.getResources()).containsExactly("secrets");
assertThat(rule.getVerbs()).containsExactly("get", "list", "watch");
});
});
});
});
assertThat(kubernetesList).filteredOn(h -> "RoleBinding".equals(h.getKind())).hasSize(2);
assertThat(kubernetesList).anySatisfy(res -> {
assertThat(res).isInstanceOfSatisfying(RoleBinding.class, roleBinding -> {
assertThat(roleBinding.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("kubernetes-config-with-secrets:view-secrets");
});
assertThat(roleBinding.getRoleRef().getKind()).isEqualTo("Role");
assertThat(roleBinding.getRoleRef().getName()).isEqualTo("view-secrets");
assertThat(roleBinding.getSubjects()).hasOnlyOneElementSatisfying(subject -> {
assertThat(subject.getKind()).isEqualTo("ServiceAccount");
assertThat(subject.getName()).isEqualTo("kubernetes-config-with-secrets");
});
});
});
assertThat(kubernetesList).anySatisfy(res -> {
assertThat(res).isInstanceOfSatisfying(RoleBinding.class, roleBinding -> {
assertThat(roleBinding.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("kubernetes-config-with-secrets:view");
});
assertThat(roleBinding.getRoleRef().getKind()).isEqualTo("ClusterRole");
assertThat(roleBinding.getRoleRef().getName()).isEqualTo("view");
assertThat(roleBinding.getSubjects()).hasOnlyOneElementSatisfying(subject -> {
assertThat(subject.getKind()).isEqualTo("ServiceAccount");
assertThat(subject.getName()).isEqualTo("kubernetes-config-with-secrets");
});
});
});
}