Change Animal to Product#15
Conversation
| * This is the abstract interface for a {@link GenericEntity}. We are using {@link Long} for all {@link #getId() primary | ||
| * keys}. | ||
| */ | ||
| public abstract interface ApplicationEntity extends GenericEntity<Long> { |
There was a problem hiding this comment.
I think you don't need ApplicationEntity and GenericEntity. Just let your entity extend from ApplicationPersistenceEntity
| @Id | ||
| @GeneratedValue | ||
| private Long id; | ||
| // private Long id; |
There was a problem hiding this comment.
Remove the outcommented lines. You can also remove the @Id and @GeneratedValue as they are no longer needed in this class as they are now included in ApplicationPersistenceEntity.
| @@ -0,0 +1,87 @@ | |||
| package com.devonfw.quarkus.productmanagement; | |||
There was a problem hiding this comment.
This class does not belong to any entity, as it is a base class for all entities. Therefore it should not be located in com.devonfw.quarkus.productmanagement. Better name it com.devonfw.quarkus.general.domain.model
| @@ -1,4 +1,4 @@ | |||
| package com.devonfw.demoquarkus; | |||
| package com.devonfw.quarkus.productmanagement; | |||
There was a problem hiding this comment.
This class is also a general class, so do not move it to the productmanagement package
| if (dto.getTitle() != null && !dto.getTitle().isEmpty()) { | ||
| predicates.add(cb.like(root.get(ProductEntity_.TITLE), dto.getTitle())); | ||
| } | ||
| // if (dto.getNumberOfLegs() != null) { |
There was a problem hiding this comment.
Remove the outcommented lines
| // } | ||
|
|
||
| BigDecimal price, priceMin, priceMax, x; | ||
| if (dto.getPriceMin() != null | dto.getPriceMax() != null) { |
There was a problem hiding this comment.
For a logical or use two pipes ||
|
|
||
| BigDecimal price, priceMin, priceMax, x; | ||
| if (dto.getPriceMin() != null | dto.getPriceMax() != null) { | ||
| if (priceMin.compareTo(x) == 0 | priceMax.compareTo(x) == 0) { |
There was a problem hiding this comment.
There is no value assigned to priceMin, priceMax and x
|
|
||
| //In Quarkus all JAX-RS resources are treated as CDI beans | ||
| //default is Singleton scope | ||
| @Path("/Products") |
There was a problem hiding this comment.
Use lowercase letters for the paths
|
|
||
| ProductDto findProductByTitle(String title); | ||
|
|
||
| ProductDto sortProductByPrice(BigDecimal priceMin, BigDecimal priceMax); |
There was a problem hiding this comment.
You define this method in the interface but not in the implementing class
|
|
||
| private String description; | ||
|
|
||
| private BigDecimal price, priceMin, priceMax; |
There was a problem hiding this comment.
Why priceMin and Max attribute in the entity? here we should only define a property price
|
|
||
| // every primitive attribute on this class will be represented as column in animal table | ||
| // every primitive attribute on this class will be represented as column in Product table | ||
| private String basicInfo; |
There was a problem hiding this comment.
I think we do not need the basicInfo attribute anymore, because we have the descrption now. So you can remove it from here and the corresponding transfer objects
| @Override | ||
| public Page<ProductDto> findProducts(ProductSearchCriteriaDto dto) { | ||
|
|
||
| Iterable<ProductEntity> ProductsIterator = this.ProductRepository.findAll(); |
There was a problem hiding this comment.
Start variable names with a lowercase letter. Also change this in the other files
|
|
||
| @Getter | ||
| @Setter | ||
| public class NewProductDto { |
There was a problem hiding this comment.
The price is missing here
| animal.setBasicInfo("Live"); | ||
| animal.setNumberOfLegs(4); | ||
| ProductDto product = new ProductDto(); | ||
| product.setTitle("Dog"); |
There was a problem hiding this comment.
Use meaningful content for the test cases
| product.setPrice(BigDecimal.valueOf(1)); | ||
|
|
||
| Response response = given().when().body(animal).contentType(MediaType.APPLICATION_JSON).post("/animals").then() | ||
| // product.setNumberOfLegs(4); |
There was a problem hiding this comment.
Remove the comments not needed
|
|
||
| @Test | ||
| @WithDBData(value = "data/animal.xls", deleteBeforeInsert = true) | ||
| @WithDBData(value = "data/product.xls", deleteBeforeInsert = true) |
There was a problem hiding this comment.
You also have to change the name of the file in src/test/resources/data. Also change the content, so that it does match with the test cases
|
|
||
| private String title; | ||
|
|
||
| // every primitive attribute on this class will be represented as column in Product table |
There was a problem hiding this comment.
Remove this comment from here
| @Schema(description = "Product description", minLength = 3, maxLength = 500) | ||
| private String description; | ||
|
|
||
| @Schema(description = "Product price", minLength = 1) |
There was a problem hiding this comment.
Remove the minLength property, as this is only for strings (see here)
|
Hi @TugbaDalmaz. When you look into the xls files under |
|
@sobkowiak Ok thank you very much for the information. I have fixed it. |
|
Accepting this pull request although test case are broken, because they were broken before. Please implement #18 with high priority. |
Closes #9