Skip to content

Commit

Permalink
Makes improvements suggested by PITest
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Sep 21, 2024
1 parent 673c82f commit d526128
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public <S> SingleTypeEqualsVerifierApi<T> withPrefabValuesForField(
S red,
S blue
) {
Validations.validateFieldNameExists(type, fieldName, actualFields);
PrefabValuesApi.addPrefabValuesForField(fieldCache, type, fieldName, red, blue);
withNonnullFields(fieldName);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public void gettersAreUsed() {
EqualsVerifier.forClass(CorrectJpaLazyFieldContainer.class).verify();
}

@Test
public void basicGetterAbsent() {
ExpectedException
.when(() -> EqualsVerifier.forClass(LazyFieldWithoutGetterContainer.class).verify())
.assertFailure();
}

@Test
public void basicGetterNotUsed_givenEagerLoading() {
EqualsVerifier.forClass(CorrectBasicJpaEagerFieldContainer.class).verify();
Expand Down Expand Up @@ -260,6 +267,27 @@ public int hashCode() {
}
}

@Entity
static class LazyFieldWithoutGetterContainer {

@OneToMany
private String basic;

@Override
public boolean equals(Object obj) {
if (!(obj instanceof LazyFieldWithoutGetterContainer)) {
return false;
}
LazyFieldWithoutGetterContainer other = (LazyFieldWithoutGetterContainer) obj;
return Objects.equals(basic, other.basic);
}

@Override
public int hashCode() {
return Objects.hash(basic);
}
}

@Entity
static class CorrectBasicJpaEagerFieldContainer {

Expand Down

0 comments on commit d526128

Please sign in to comment.