Minor refactorings and code style changes (#807)

* Made minor changes in some patterns such as removed throws clause where not needed, changed incorrect order of arguments in assertEquals

* Minor refactorings and code style changes. 1) Removed several use of raw types 2) Removed unnecessary throws clauses 3) Used lambda expressions wherever applicable 4) Used apt assertion methods for readability 5) Use of try with resources wherever applicable 6) Corrected incorrect order of assertXXX arguments

* Removed unused import from Promise

* Addressed review comments

* Addressed checkstyle issue
This commit is contained in:
Narendra Pathai
2018-10-23 13:45:41 +05:30
committed by GitHub
parent 25ed7c09c5
commit 2aa9e78ddd
112 changed files with 312 additions and 463 deletions

View File

@ -70,18 +70,18 @@ public class App {
List<Creature> walkingCreatures =
creatures.stream().filter(new MovementSelector(Movement.WALKING))
.collect(Collectors.toList());
walkingCreatures.stream().forEach(c -> LOGGER.info(c.toString()));
walkingCreatures.forEach(c -> LOGGER.info(c.toString()));
// find all dark creatures
LOGGER.info("Find all dark creatures");
List<Creature> darkCreatures =
creatures.stream().filter(new ColorSelector(Color.DARK)).collect(Collectors.toList());
darkCreatures.stream().forEach(c -> LOGGER.info(c.toString()));
darkCreatures.forEach(c -> LOGGER.info(c.toString()));
// find all red and flying creatures
LOGGER.info("Find all red and flying creatures");
List<Creature> redAndFlyingCreatures =
creatures.stream()
.filter(new ColorSelector(Color.RED).and(new MovementSelector(Movement.FLYING)))
.collect(Collectors.toList());
redAndFlyingCreatures.stream().forEach(c -> LOGGER.info(c.toString()));
redAndFlyingCreatures.forEach(c -> LOGGER.info(c.toString()));
}
}

View File

@ -57,33 +57,33 @@ public class CreatureTest {
@ParameterizedTest
@MethodSource("dataProvider")
public void testGetName(Creature testedCreature, String name) throws Exception {
public void testGetName(Creature testedCreature, String name) {
assertEquals(name, testedCreature.getName());
}
@ParameterizedTest
@MethodSource("dataProvider")
public void testGetSize(Creature testedCreature, String name, Size size) throws Exception {
public void testGetSize(Creature testedCreature, String name, Size size) {
assertEquals(size, testedCreature.getSize());
}
@ParameterizedTest
@MethodSource("dataProvider")
public void testGetMovement(Creature testedCreature, String name, Size size, Movement movement) throws Exception {
public void testGetMovement(Creature testedCreature, String name, Size size, Movement movement) {
assertEquals(movement, testedCreature.getMovement());
}
@ParameterizedTest
@MethodSource("dataProvider")
public void testGetColor(Creature testedCreature, String name, Size size, Movement movement,
Color color) throws Exception {
Color color) {
assertEquals(color, testedCreature.getColor());
}
@ParameterizedTest
@MethodSource("dataProvider")
public void testToString(Creature testedCreature, String name, Size size, Movement movement,
Color color) throws Exception {
Color color) {
final String toString = testedCreature.toString();
assertNotNull(toString);
assertEquals(