I have:
List<SlaveEntityDTO> result = Jsoner.JsonToSlaveEntityDTO(json);
List<SlaveEntityDTO> result1 = entitiesDTOList;
The result and result1 has the same values for their fields:
When I run Assert.assertEquals(result, result1);
I am getting the following message:
java.lang.AssertionError:
Expected :[core.dto.SlaveEntityDTO@6be46e8f, core.dto.SlaveEntityDTO@3567135c]
Actual :[core.dto.SlaveEntityDTO@327471b5, core.dto.SlaveEntityDTO@4157f54e]
So how can I compare the values of the fields inside result and result1, instead of comparing if an object is that object?
The SlaveEntityDTO is like this:
public class SlaveEntityDTO extends BaseEntityDTO<SlaveEntity> {
private String ip;
private String macAddress;
private String status;
private List<PositionEntity> positions;
@Override
public SlaveEntity convertToEntity() {
return new ModelMapper().map(this, SlaveEntity.class);
}
}
And the BaseEntityDTO is like this:
public abstract class BaseEntityDTO<T> implements Serializable{
private long id;
public abstract T convertToEntity();
}