This test verifies the correctness of the method that transport planes receive from the list of military planes. As in the test not to use "for" and "if", and to use an assertTrue. Also can not use FLAG and lambda. Next to all this should be one Assert.
@Test
public void testGetTransportMilitaryPlanes() {
Airport airport = new Airport(planes);
List<MilitaryPlane> transportMilitaryPlanes = airport.getTransportMilitaryPlanes();
boolean flag = false;
for (MilitaryPlane militaryPlane : transportMilitaryPlanes) {
if ((militaryPlane.getType() == MilitaryType.TRANSPORT)) {
flag = true;
break;
}
}
Assert.assertEquals(flag, true);
}
I did so:
@Test
public void testGetTransportMilitaryPlanes() {
Airport airport = new Airport(planes);
List<MilitaryPlane> transportMilitaryPlanes = airport.getTransportMilitaryPlanes();
Assert.assertTrue(transportMilitaryPlanes.stream().anyMatch(p -> p.getMilitaryType() == MilitaryType.TRANSPORT));
}
But in the test can not use the lambda. How to do it without lambda?
Aucun commentaire:
Enregistrer un commentaire