Commit 63efb5ef authored by Antoine Hazebrouck's avatar Antoine Hazebrouck

les concours de tel chefs

parent c5fd52a4
package imt;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.stream.Stream;
public class FileConcours {
private final Queue<Concours> concours;
public FileConcours(Concours... concours) {
this.concours = new LinkedList<Concours>(Stream.of(concours).toList());
}
public List<Concours> concoursAuquelParticipe(Chef chef) {
return concours.stream()
.filter(concoursLoop -> concoursLoop.getPropositions().stream().map(prop -> prop.getChef()).toList()
.contains(chef))
.toList();
}
}
package imt; package imt;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -74,4 +78,26 @@ public class ConcoursTest { ...@@ -74,4 +78,26 @@ public class ConcoursTest {
assertEquals(true, concours.estTermine()); assertEquals(true, concours.estTermine());
} }
@Test
void classement_actuel() {
Concours concours1 = new Concours(jury1, jury2, jury3, propositions);
List<Proposition> expected = new ArrayList<>();
expected.add(proposition1);
expected.add(proposition2);
expected.add(proposition3);
expected.add(proposition4);
expected.add(proposition5);
proposition1.setNote(Optional.of(1));
proposition2.setNote(Optional.of(2));
proposition3.setNote(Optional.of(3));
proposition4.setNote(Optional.of(4));
// proposition5.setNote(Optional.of(100));
assertThat(concours1.classement()).isEqualTo(expected);
System.out.println(concours1.classement());
}
} }
package imt; package imt;
import static imt.ConcoursTest.jury1; import static imt.ConcoursTest.*;
import static imt.ConcoursTest.jury2;
import static imt.ConcoursTest.jury3;
import static imt.ConcoursTest.proposition1;
import static imt.ConcoursTest.proposition2;
import static imt.ConcoursTest.proposition3;
import static imt.ConcoursTest.proposition4;
import static imt.ConcoursTest.proposition5;
import static imt.ConcoursTest.propositions;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Set;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import imt.ingredients.Ingredient;
public class FileConcoursTest { public class FileConcoursTest {
@Test @Test
void fileDeConcours_passage_au_suivant() { void fileDeConcours_tout_les_concours_du_chef() {
Concours concours1 = new Concours(jury1, jury2, jury3, propositions); Set<Proposition> propositionsSansTelChef = new HashSet<>(propositions);
} propositionsSansTelChef.remove(proposition1);
propositionsSansTelChef.add(
new Proposition(new Plat(99, "plat99", new Ingredient[] {}), new Chef(99, "nom99", "prenom99", "QSD",
Genre.HOMME, 4, Specialite.CUISINIER, Set.of(new Plat(99, "plat99", new Ingredient[] {})))));
@Test
void fileDeConcours_classement_actuel() {
Concours concours1 = new Concours(jury1, jury2, jury3, propositions); Concours concours1 = new Concours(jury1, jury2, jury3, propositions);
Concours concours2 = new Concours(jury1, jury2, jury3, propositionsSansTelChef);
Concours concours3 = new Concours(jury1, jury2, jury3, new HashSet<>(propositions));
List<Proposition> expected = new ArrayList<>(); FileConcours fileConcours = new FileConcours(concours1, concours2, concours3);
expected.add(proposition1);
expected.add(proposition2);
expected.add(proposition3);
expected.add(proposition4);
expected.add(proposition5);
proposition1.setNote(Optional.of(1));
proposition2.setNote(Optional.of(2));
proposition3.setNote(Optional.of(3));
proposition4.setNote(Optional.of(4));
// proposition5.setNote(Optional.of(100));
assertThat(concours1.classement()).isEqualTo(expected);
System.out.println(concours1.classement()); assertThat(fileConcours.concoursAuquelParticipe(chef1)).isEqualTo(List.of(concours1, concours3));
} }
} }
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