📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code * Fix merge conflicts and some sonar issues Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
@ -40,8 +40,7 @@ import com.iluwatar.specification.selector.MovementSelector;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* <p>The central idea of the Specification pattern is to separate the statement of how to match a
|
||||
@ -54,10 +53,9 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
* <p>http://martinfowler.com/apsupp/spec.pdf</p>
|
||||
*/
|
||||
@Slf4j
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Program entry point.
|
||||
*/
|
||||
|
@ -23,9 +23,12 @@
|
||||
|
||||
package com.iluwatar.specification.property;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* Mass property.
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
public class Mass {
|
||||
|
||||
private final double value;
|
||||
@ -57,11 +60,4 @@ public class Mass {
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
if (!(obj instanceof Mass)) {
|
||||
return false;
|
||||
}
|
||||
return ((Mass) obj).value == this.value;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public class CreatureTest {
|
||||
class CreatureTest {
|
||||
|
||||
/**
|
||||
* @return The tested {@link Creature} instance and its expected specs
|
||||
@ -64,40 +64,40 @@ public class CreatureTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testGetName(Creature testedCreature, String name) {
|
||||
void testGetName(Creature testedCreature, String name) {
|
||||
assertEquals(name, testedCreature.getName());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testGetSize(Creature testedCreature, String name, Size size) {
|
||||
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) {
|
||||
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) {
|
||||
void testGetColor(Creature testedCreature, String name, Size size, Movement movement,
|
||||
Color color) {
|
||||
assertEquals(color, testedCreature.getColor());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testGetMass(Creature testedCreature, String name, Size size, Movement movement,
|
||||
Color color, Mass mass) {
|
||||
void testGetMass(Creature testedCreature, String name, Size size, Movement movement,
|
||||
Color color, Mass mass) {
|
||||
assertEquals(mass, testedCreature.getMass());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testToString(Creature testedCreature, String name, Size size, Movement movement,
|
||||
Color color, Mass mass) {
|
||||
void testToString(Creature testedCreature, String name, Size size, Movement movement,
|
||||
Color color, Mass mass) {
|
||||
final var toString = testedCreature.toString();
|
||||
assertNotNull(toString);
|
||||
assertEquals(String
|
||||
|
@ -37,13 +37,13 @@ import org.junit.jupiter.api.Test;
|
||||
*
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public class ColorSelectorTest {
|
||||
class ColorSelectorTest {
|
||||
|
||||
/**
|
||||
* Verify if the color selector gives the correct results
|
||||
*/
|
||||
@Test
|
||||
public void testColor() {
|
||||
void testColor() {
|
||||
final var greenCreature = mock(Creature.class);
|
||||
when(greenCreature.getColor()).thenReturn(Color.GREEN);
|
||||
|
||||
|
@ -33,13 +33,13 @@ import com.iluwatar.specification.property.Mass;
|
||||
import com.iluwatar.specification.property.Movement;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class CompositeSelectorsTest {
|
||||
class CompositeSelectorsTest {
|
||||
|
||||
/**
|
||||
* Verify if the conjunction selector gives the correct results.
|
||||
*/
|
||||
@Test
|
||||
public void testAndComposition() {
|
||||
void testAndComposition() {
|
||||
final var swimmingHeavyCreature = mock(Creature.class);
|
||||
when(swimmingHeavyCreature.getMovement()).thenReturn(Movement.SWIMMING);
|
||||
when(swimmingHeavyCreature.getMass()).thenReturn(new Mass(100.0));
|
||||
@ -58,7 +58,7 @@ public class CompositeSelectorsTest {
|
||||
* Verify if the disjunction selector gives the correct results.
|
||||
*/
|
||||
@Test
|
||||
public void testOrComposition() {
|
||||
void testOrComposition() {
|
||||
final var swimmingHeavyCreature = mock(Creature.class);
|
||||
when(swimmingHeavyCreature.getMovement()).thenReturn(Movement.SWIMMING);
|
||||
when(swimmingHeavyCreature.getMass()).thenReturn(new Mass(100.0));
|
||||
@ -77,7 +77,7 @@ public class CompositeSelectorsTest {
|
||||
* Verify if the negation selector gives the correct results.
|
||||
*/
|
||||
@Test
|
||||
public void testNotComposition() {
|
||||
void testNotComposition() {
|
||||
final var swimmingHeavyCreature = mock(Creature.class);
|
||||
when(swimmingHeavyCreature.getMovement()).thenReturn(Movement.SWIMMING);
|
||||
when(swimmingHeavyCreature.getMass()).thenReturn(new Mass(100.0));
|
||||
|
@ -38,7 +38,7 @@ public class MassSelectorTest {
|
||||
* Verify if the mass selector gives the correct results.
|
||||
*/
|
||||
@Test
|
||||
public void testMass() {
|
||||
void testMass() {
|
||||
final var lightCreature = mock(Creature.class);
|
||||
when(lightCreature.getMass()).thenReturn(new Mass(50.0));
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class MovementSelectorTest {
|
||||
* Verify if the movement selector gives the correct results.
|
||||
*/
|
||||
@Test
|
||||
public void testMovement() {
|
||||
void testMovement() {
|
||||
final var swimmingCreature = mock(Creature.class);
|
||||
when(swimmingCreature.getMovement()).thenReturn(Movement.SWIMMING);
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class SizeSelectorTest {
|
||||
* Verify if the size selector gives the correct results
|
||||
*/
|
||||
@Test
|
||||
public void testMovement() {
|
||||
void testMovement() {
|
||||
final var normalCreature = mock(Creature.class);
|
||||
when(normalCreature.getSize()).thenReturn(Size.NORMAL);
|
||||
|
||||
|
Reference in New Issue
Block a user