Questions tagged [equalsverifier]

Java tool that can be used in unit tests, to verify whether the contract for the equals and hashCode methods is met.

10 questions
9
votes
2 answers

Equals and hashCode contract with EqualsVerifier

I have some doubts about equals and hashCode contract in Java using EqualsVerifier library. Imagine we have something like this public abstract class Person { protected String name; @Override public boolean equals(Object obj) { …
Manuelarte
  • 1,658
  • 2
  • 28
  • 47
5
votes
1 answer

EqualsVerifier in SpringBoot

I am creating the tests for two classes that share a list of data. When I use EqualsVerifier I get an error because it is asking me for a list with data shared by these two classes. This is the error: Recursive datastructure. Add prefab values for…
sinfryd95
  • 175
  • 1
  • 2
  • 8
3
votes
1 answer

EqualsVerifier: Unsupported class file major version 61

Java/Maven novice here, I'm trying to integrate EqualsVerifier into my code but am getting the following error java.lang.AssertionError: EqualsVerifier found a problem in class com.me.MyClass. -> Unsupported class file major version 61 As I…
Madden
  • 1,024
  • 1
  • 9
  • 27
3
votes
1 answer

EqualsVerifier Assertion Error: Significant fields: equals does not use , or it is stateless

The setup, java 8 using lombok, meanbean and equalsverifier(huge fan of all 3, and also limited in what versions I can use per co. policy - on 2.3.3 of equalsverifier): @Data @NoArgsConstructor class A {...} @Data @NoArgsConstructor class B extends…
3
votes
1 answer

Why all fields used in equals should be also used in hashcode?

@Edit: I'm using this library http://jqno.nl/equalsverifier/ to check if equals and hashCode are written properly. Let's say we have this class: final class Why { private final int id; private final String name; Why(final int id, final…
MAGx2
  • 3,149
  • 7
  • 33
  • 63
3
votes
1 answer

How to use EqualsVerifier in a Spock test

I have been writing my tests using spock. But to test Equals Hashcode contracts, I am trying to use EqualsVerifier. So my test code looks like: def "test equals hashcode contract"() { EqualsVerifier.forClass(Content.class).verify(); } But this…
Neel
  • 2,100
  • 5
  • 24
  • 47
2
votes
1 answer

Equalsverifier fails when run with quarkus:dev

When running equalsverfier in quarkus dev mode, equalsverfier tests fail. I tried to test a class with equalsverifier. This works in my IDE. I tried to use it in quarkus dev mode (by running ./mvnw quarkus:dev), but then it fails with the following…
Talip
  • 23
  • 3
2
votes
2 answers

Nexus doesn't download the complete artifact content from the Central repository

In our project we use the artifact nl.jqno.equalsverifier equalsverifier 1.7.5 Everything works fine: Nexus downloads the same content as in…
andreasgk
  • 673
  • 1
  • 12
  • 30
1
vote
1 answer

Equals Verifier fails with error related to hashcode check for JPA entity

Given we have such class: @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Entity public class User { @Id private Long id; private String name; private Integer age; @Override public final boolean equals(Object o) { …
ColdDeath
  • 49
  • 6
1
vote
1 answer

How to change constructor arguments?

I have a record that performs a verification in its constructor as such : public record Configuration(URI url) { public Configuration(URI url) { Validate.httpValid(url, "url"); } } Where the httpValid method is : public static URI…