lombok
This commit is contained in:
parent
ceb51e5351
commit
f49301f200
18
api/pom.xml
18
api/pom.xml
|
@ -21,6 +21,8 @@
|
|||
<mapstruct.version>1.5.5.Final</mapstruct.version>
|
||||
<openapi-generator.version>6.2.1</openapi-generator.version>
|
||||
<findbugs.version>3.0.2</findbugs.version>
|
||||
<lombok.version>1.18.30</lombok.version>
|
||||
<lombok.mapstruct.version>0.2.0</lombok.mapstruct.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -86,6 +88,12 @@
|
|||
<artifactId>mapstruct</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -104,6 +112,16 @@
|
|||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>${lombok.mapstruct.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
|
|
@ -7,13 +7,14 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.meutel.recettes.api.ParametersApi;
|
||||
import net.meutel.recettes.api.model.RecetteParam;
|
||||
import net.meutel.recettes.api.service.ParametersService;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class ParameterController implements ParametersApi {
|
||||
private final Logger LOG = LoggerFactory.getLogger(ParameterController.class);
|
||||
|
||||
private final ParametersService service;
|
||||
|
||||
|
@ -23,7 +24,7 @@ public class ParameterController implements ParametersApi {
|
|||
|
||||
@Override
|
||||
public ResponseEntity<List<RecetteParam>> listRecetteParamsByType(String paramType) {
|
||||
LOG.info("list params: " + paramType);
|
||||
log.info("list params: " + paramType);
|
||||
return ResponseEntity.ok(service.loadAllParameters(paramType));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,33 +2,15 @@ package net.meutel.recettes.api.entity;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class QuantityEntity {
|
||||
|
||||
private BigDecimal value;
|
||||
|
||||
private String unit;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "QuantityEntity [value=" + value + ", unit=" + unit + "]";
|
||||
}
|
||||
|
||||
public BigDecimal getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(BigDecimal value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,11 @@ import java.util.List;
|
|||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@Document("receipes")
|
||||
public class ReceipeEntity {
|
||||
|
||||
|
@ -19,65 +24,4 @@ public class ReceipeEntity {
|
|||
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 + ", steps=" + steps + "]";
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public String getCookTime() {
|
||||
return cookTime;
|
||||
}
|
||||
public void setCookTime(String cookTime) {
|
||||
this.cookTime = cookTime;
|
||||
}
|
||||
public String getPrepTime() {
|
||||
return prepTime;
|
||||
}
|
||||
public void setPrepTime(String prepTime) {
|
||||
this.prepTime = prepTime;
|
||||
}
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
public ReceipeYieldEntity getReceipeYield() {
|
||||
return receipeYield;
|
||||
}
|
||||
public void setReceipeYield(ReceipeYieldEntity receipeYield) {
|
||||
this.receipeYield = receipeYield;
|
||||
}
|
||||
public List<ReceipeIngredientEntity> getIngredients() {
|
||||
return ingredients;
|
||||
}
|
||||
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,5 +1,10 @@
|
|||
package net.meutel.recettes.api.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ReceipeIngredientEntity {
|
||||
|
||||
private QuantityEntity quantity;
|
||||
|
@ -8,33 +13,4 @@ public class ReceipeIngredientEntity {
|
|||
|
||||
private String ref;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReceipeIngredientEntity [quantity=" + quantity + ", text=" + text + ", ref=" + ref + "]";
|
||||
}
|
||||
|
||||
public String getRef() {
|
||||
return ref;
|
||||
}
|
||||
|
||||
public void setRef(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
public QuantityEntity getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(QuantityEntity quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package net.meutel.recettes.api.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ReceipeStepEntity {
|
||||
|
||||
private Integer position;
|
||||
|
@ -8,33 +13,4 @@ public class ReceipeStepEntity {
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,32 +1,14 @@
|
|||
package net.meutel.recettes.api.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ReceipeYieldEntity {
|
||||
|
||||
private QuantityEntity quantity;
|
||||
|
||||
private String of;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReceipeYieldEntity [quantity=" + quantity + ", of=" + of + "]";
|
||||
}
|
||||
|
||||
public QuantityEntity getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(QuantityEntity quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public String getOf() {
|
||||
return of;
|
||||
}
|
||||
|
||||
public void setOf(String of) {
|
||||
this.of = of;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,11 @@ package net.meutel.recettes.api.entity;
|
|||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Document(collection = "parameters")
|
||||
public class RecetteParamEntity {
|
||||
@Id
|
||||
|
@ -11,45 +16,5 @@ public class RecetteParamEntity {
|
|||
public String _type;
|
||||
|
||||
public String name;
|
||||
|
||||
public RecetteParamEntity() {
|
||||
}
|
||||
|
||||
public RecetteParamEntity(String id, String _type, String name) {
|
||||
this.id = id;
|
||||
this._type = _type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RecetteParamEntity [id=" + id + ", _type=" + _type + ", name=" + name + "]";
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String get_type() {
|
||||
return _type;
|
||||
}
|
||||
|
||||
public void set_type(String _type) {
|
||||
this._type = _type;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,40 +17,46 @@ import net.meutel.recettes.api.repository.RecetteParamRepository;
|
|||
@SpringBootTest
|
||||
public class ParametersServiceImplTest {
|
||||
|
||||
@MockBean
|
||||
RecetteParamRepository repo;
|
||||
@MockBean
|
||||
RecetteParamRepository repo;
|
||||
|
||||
@Autowired
|
||||
ParametersService tested;
|
||||
@Autowired
|
||||
ParametersService tested;
|
||||
|
||||
@Test
|
||||
void loadAllParameters_exists_list() {
|
||||
var p1 = new RecetteParamEntity("1", "TEST", "p1");
|
||||
var p2 = new RecetteParamEntity("2", "TEST", "p2");
|
||||
@Test
|
||||
void loadAllParameters_exists_list() {
|
||||
var p1 = new RecetteParamEntity();
|
||||
p1.setId("1");
|
||||
p1.set_type("TEST");
|
||||
p1.setName("p1");
|
||||
var p2 = new RecetteParamEntity();
|
||||
p2.setId("2");
|
||||
p2.set_type("TEST");
|
||||
p2.setName("p2");
|
||||
|
||||
when(repo.findBy_type("TEST"))
|
||||
.thenReturn(List.of(p1, p2).stream());
|
||||
when(repo.findBy_type("TEST"))
|
||||
.thenReturn(List.of(p1, p2).stream());
|
||||
|
||||
var result = tested.loadAllParameters("TEST");
|
||||
var result = tested.loadAllParameters("TEST");
|
||||
|
||||
assertThat(result)
|
||||
.isNotNull()
|
||||
.hasSize(2);
|
||||
assertThat(result).element(0)
|
||||
.returns("TEST", RecetteParam::getAtType)
|
||||
.returns("p1", RecetteParam::getName);
|
||||
assertThat(result).element(1)
|
||||
.returns("TEST", RecetteParam::getAtType)
|
||||
.returns("p2", RecetteParam::getName);
|
||||
}
|
||||
assertThat(result)
|
||||
.isNotNull()
|
||||
.hasSize(2);
|
||||
assertThat(result).element(0)
|
||||
.returns("TEST", RecetteParam::getAtType)
|
||||
.returns("p1", RecetteParam::getName);
|
||||
assertThat(result).element(1)
|
||||
.returns("TEST", RecetteParam::getAtType)
|
||||
.returns("p2", RecetteParam::getName);
|
||||
}
|
||||
|
||||
@Test
|
||||
void loadAllParameters_notExists_empty() {
|
||||
var result = tested.loadAllParameters("TEST");
|
||||
@Test
|
||||
void loadAllParameters_notExists_empty() {
|
||||
var result = tested.loadAllParameters("TEST");
|
||||
|
||||
assertThat(result)
|
||||
.isNotNull()
|
||||
.isEmpty();
|
||||
}
|
||||
assertThat(result)
|
||||
.isNotNull()
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ public class ReceipeServiceImplTest {
|
|||
step1.setPosition(1);
|
||||
step1.setText("Faire bouillir de l'eau");
|
||||
step1.setHint("attention aux explosions");
|
||||
r1.setSteps(List.of(step1));
|
||||
return r1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue