Guide to Lock Interface in Java
The use of
synchronized
methods or statements provides access to the implicit monitor lock associated with every object, but requires all lock acquisitions and releases to proceed in a block-structured way.
Guide to Lock Interface in Java
The use of
synchronized
methods or statements provides access to the implicit monitor lock associated with every object, but requires all lock acquisitions and releases to proceed in a block-structured way.
Make sure you know and Use AssertJ, it’s Magic!
https://assertj.github.io/doc/#basic-usage
assertThat(studentA_).isEqualTo(studentA);
Fails because even though Address
object is equal in value, it is not equal in reference
But assertion assertThat(studentA_).usingRecursiveComparison().isEqualTo(studentA);
passes because it will compare recursively the Address fields
Let’s say that You have a Student and an Address Entity
public class Student {
private Integer id;
private String name;
private LocalDate joinDate;
private Address address;
}
public class Address {
private String street;
private int streetNo;
/*JPA ForeignKey*/
// @OneToOne()
// @JoinColumn(name = "student_id", referencedColumnName = "id", nullable
@ToString.Exclude
@EqualsAndHashCode.Exclude
private Student student;
private List<Inhabitant> inhabitants;
}
You can instruct AssertJ, to compare all the fields EXCPET some fields
assertThat(studentA_).usingRecursiveComparison()
.ignoringFields("address.student")
.ignoringFields("address.inhabitants.address")
.isEqualTo(studentA);
Please see this Git Repo for Details
https://github.com/razvangvr/openapi.server/blob/master/src/test/java/org/example/StudentMapperTest.java
I enjoyed reading this , Reactive programming: principles, standards, implementation in Java