Commit 3dd8e673 authored by Antoine Hazebrouck's avatar Antoine Hazebrouck

plat 100% bios

parent 46d9a61d
package imt.ingredients;
import java.util.stream.Stream;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode
......@@ -47,4 +49,9 @@ public class Plat {
return "Plat [idPlat=" + idPlat + ", nomPlat=" + nomPlat + ", ingredients=" + ingredientStr.toString() + "]";
}
public boolean isBio() {
return Stream.of(ingredients)
.allMatch(ingredient -> ingredient.isBio());
}
}
package imt.ingredients;
import static imt.ingredients.IngredientTest.AUTRE;
import static imt.ingredients.IngredientTest.OIGNON;
import static imt.ingredients.IngredientTest.STEAK;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
public class PlatTest {
@Test
void plat_entierement_bio() {
Plat platBio = new Plat(1, "plat1", new Ingredient[] {
STEAK, OIGNON
});
assertThat(platBio.isBio()).isTrue();
Plat platNonBio = new Plat(2, "plat2", new Ingredient[] {
STEAK, OIGNON, AUTRE
});
assertThat(platNonBio.isBio()).isFalse();
}
}
package imt.personnes;
import org.junit.jupiter.api.Test;
import imt.ingredients.Ingredient;
import imt.ingredients.Legume;
import imt.ingredients.Plat;
public class ChefTest {
// @Test
// void plat_connus_d_un_chef_par_calories() {
// Plat plat1 = new Plat(1, "plat1", new Ingredient[] {
// new Legume(1, "poivron", 10, true);
// });
// }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment