Steps
This commit is contained in:
parent
623ec11e3b
commit
ceb51e5351
|
@ -17,12 +17,13 @@ public class ReceipeEntity {
|
|||
private String author;
|
||||
private ReceipeYieldEntity receipeYield;
|
||||
private List<ReceipeIngredientEntity> ingredients;
|
||||
private List<ReceipeStepEntity> steps;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReceipeEntity [id=" + id + ", name=" + name + ", description=" + description + ", cookTime=" + cookTime
|
||||
+ ", prepTime=" + prepTime + ", author=" + author + ", receipeYield=" + receipeYield + ", ingredients="
|
||||
+ ingredients + "]";
|
||||
+ ingredients + ", steps=" + steps + "]";
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -71,6 +72,12 @@ public class ReceipeEntity {
|
|||
}
|
||||
public void setIngredients(List<ReceipeIngredientEntity> ingredients) {
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
public List<ReceipeStepEntity> getSteps() {
|
||||
return steps;
|
||||
}
|
||||
public void setSteps(List<ReceipeStepEntity> steps) {
|
||||
this.steps = steps;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,26 +1,23 @@
|
|||
package net.meutel.recettes.api.entity;
|
||||
|
||||
import org.springframework.data.mongodb.core.mapping.DocumentReference;
|
||||
|
||||
public class ReceipeIngredientEntity {
|
||||
|
||||
private QuantityEntity quantity;
|
||||
|
||||
private String text;
|
||||
|
||||
@DocumentReference(collection = "parameters")
|
||||
private RecetteParamEntity ref;
|
||||
private String ref;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReceipeIngredientEntity [quantity=" + quantity + ", text=" + text + ", ref=" + ref + "]";
|
||||
}
|
||||
|
||||
public RecetteParamEntity getRef() {
|
||||
public String getRef() {
|
||||
return ref;
|
||||
}
|
||||
|
||||
public void setRef(RecetteParamEntity ref) {
|
||||
public void setRef(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package net.meutel.recettes.api.entity;
|
||||
|
||||
public class ReceipeStepEntity {
|
||||
|
||||
private Integer position;
|
||||
|
||||
private String text;
|
||||
|
||||
private String hint;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReceipeStepEntity [position=" + position + ", text=" + text + ", hint=" + hint + "]";
|
||||
}
|
||||
|
||||
public Integer getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setPosition(Integer position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getHint() {
|
||||
return hint;
|
||||
}
|
||||
|
||||
public void setHint(String hint) {
|
||||
this.hint = hint;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ import org.mapstruct.Mapping;
|
|||
import net.meutel.recettes.api.entity.ReceipeIngredientEntity;
|
||||
import net.meutel.recettes.api.model.Ingredient;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = {RecetteParamRefMapper.class})
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface IngredientMapper {
|
||||
|
||||
Ingredient fromEntity(ReceipeIngredientEntity entity);
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.mapstruct.Mapper;
|
|||
import net.meutel.recettes.api.entity.ReceipeEntity;
|
||||
import net.meutel.recettes.api.model.Receipe;
|
||||
|
||||
@Mapper(componentModel = "spring", uses = {IngredientMapper.class})
|
||||
@Mapper(componentModel = "spring", uses = {IngredientMapper.class, StepMapper.class})
|
||||
public interface ReceipeFullMapper {
|
||||
|
||||
Receipe fromEntity(ReceipeEntity entity);
|
||||
|
|
|
@ -11,9 +11,11 @@ public interface ReceipeSimplifiedMapper {
|
|||
|
||||
@Mapping(target = "ingredients", ignore = true)
|
||||
@Mapping(target = "receipeYield", ignore = true)
|
||||
@Mapping(target = "steps", ignore = true)
|
||||
Receipe fromEntity(ReceipeEntity entity);
|
||||
|
||||
@Mapping(target = "ingredients", ignore = true)
|
||||
@Mapping(target = "steps", ignore = true)
|
||||
ReceipeEntity toEntity(Receipe model);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package net.meutel.recettes.api.mapper;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import net.meutel.recettes.api.entity.RecetteParamEntity;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface RecetteParamRefMapper {
|
||||
|
||||
default String fromEntity(RecetteParamEntity entity) {
|
||||
return entity.getId();
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package net.meutel.recettes.api.mapper;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import net.meutel.recettes.api.entity.ReceipeStepEntity;
|
||||
import net.meutel.recettes.api.model.Step;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface StepMapper {
|
||||
|
||||
Step fromEntity(ReceipeStepEntity entity);
|
||||
|
||||
ReceipeStepEntity toEntity(Step model);
|
||||
}
|
|
@ -16,11 +16,13 @@ import org.springframework.boot.test.mock.mockito.MockBean;
|
|||
import net.meutel.recettes.api.entity.QuantityEntity;
|
||||
import net.meutel.recettes.api.entity.ReceipeEntity;
|
||||
import net.meutel.recettes.api.entity.ReceipeIngredientEntity;
|
||||
import net.meutel.recettes.api.entity.ReceipeStepEntity;
|
||||
import net.meutel.recettes.api.entity.ReceipeYieldEntity;
|
||||
import net.meutel.recettes.api.exception.ItemNotFoundException;
|
||||
import net.meutel.recettes.api.model.Ingredient;
|
||||
import net.meutel.recettes.api.model.Receipe;
|
||||
import net.meutel.recettes.api.model.ReceipeReceipeYield;
|
||||
import net.meutel.recettes.api.model.Step;
|
||||
import net.meutel.recettes.api.repository.ReceipeRepository;
|
||||
|
||||
@SpringBootTest
|
||||
|
@ -66,6 +68,12 @@ public class ReceipeServiceImplTest {
|
|||
.singleElement()
|
||||
.extracting(Ingredient::getText)
|
||||
.isEqualTo("Parmesan");
|
||||
assertThat(result.getSteps())
|
||||
.isNotNull();
|
||||
assertThat(result.getSteps())
|
||||
.singleElement()
|
||||
.extracting(Step::getPosition, Step::getText, Step::getHint)
|
||||
.contains(1, "Faire bouillir de l'eau", "attention aux explosions");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -114,6 +122,10 @@ public class ReceipeServiceImplTest {
|
|||
i1.setQuantity(i1qty);
|
||||
i1.setText("Parmesan");
|
||||
r1.setIngredients(List.of(i1));
|
||||
var step1 = new ReceipeStepEntity();
|
||||
step1.setPosition(1);
|
||||
step1.setText("Faire bouillir de l'eau");
|
||||
step1.setHint("attention aux explosions");
|
||||
return r1;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,8 +108,9 @@ components:
|
|||
type: object
|
||||
required:
|
||||
- id
|
||||
- ingredients
|
||||
- name
|
||||
- ingredients
|
||||
- steps
|
||||
properties:
|
||||
id:
|
||||
description: Receipe unique id
|
||||
|
@ -137,6 +138,10 @@ components:
|
|||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Ingredient'
|
||||
steps:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Step'
|
||||
receipeYield:
|
||||
description: Quantity produced by receipe
|
||||
type: object
|
||||
|
@ -162,6 +167,19 @@ components:
|
|||
description: Link to ingredient parameter
|
||||
type: string
|
||||
format: url
|
||||
Step:
|
||||
description: Step in receipe
|
||||
type: object
|
||||
properties:
|
||||
position:
|
||||
description: position of step in receipe
|
||||
type: integer
|
||||
text:
|
||||
description: step instruction
|
||||
type: string
|
||||
hint:
|
||||
description: step hint
|
||||
type: string
|
||||
Quantity:
|
||||
type: object
|
||||
required:
|
||||
|
|
Loading…
Reference in New Issue