mmnaseri / spring-data-mock

Mock facility for Spring Data repositories
MIT License
135 stars 44 forks source link

Primitive types and boxed types are not considered compatible #174

Closed zsadeghi closed 3 years ago

zsadeghi commented 4 years ago

Describe the bug

If a property type on the entity is non-primitive (e.g. Boolean) but the argument on the query method is primitive (e.g. boolean) Spring Data Mock complains.

To Reproduce

Code to reproduce:

public class MyEntity {
  private Integer id;
  private Boolean property;
  // getters and setters.
}
public interface MyEntityRepository<MyEntity, Integer> {
  List<MyEntity> findByProperty(boolean property);
}

Mock site:

builder().mock(MyEntityRepository.class);

Expected behavior The mock should be created without any issues.

zsadeghi commented 4 years ago

Workaround for now is to just use the same non-primitive type on the repository:

public interface MyEntityRepository<MyEntity, Integer> {
  List<MyEntity> findByProperty(Boolean property);
}