Upgrade of maven plugins (#951)

* Upgrade maven plugins

* Upgrade maven plugins

Some general code cleanup was necessary due to upgrade of PMD and checkstyle.

Also needed to add Junit 4 as a dependency due to Mockito.timout issue found here:
https://github.com/mockito/mockito/issues/152
This commit is contained in:
Per Wramdemark 2019-10-05 13:23:20 +02:00 committed by Ilkka Seppälä
parent 05d0f0babf
commit 218ba44dbf
19 changed files with 63 additions and 84 deletions

View File

@ -43,5 +43,10 @@
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -29,7 +29,7 @@ public enum Instruction {
LITERAL(1), LITERAL(1),
SET_HEALTH(2), SET_HEALTH(2),
SET_WISDOM (3), SET_WISDOM(3),
SET_AGILITY(4), SET_AGILITY(4),
PLAY_SOUND(5), PLAY_SOUND(5),
SPAWN_PARTICLES(6), SPAWN_PARTICLES(6),
@ -37,7 +37,7 @@ public enum Instruction {
GET_AGILITY(8), GET_AGILITY(8),
GET_WISDOM(9), GET_WISDOM(9),
ADD(10), ADD(10),
DIVIDE (11); DIVIDE(11);
private int value; private int value;

View File

@ -65,7 +65,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration> <configuration>
<skipTests>false</skipTests> <skipTests>false</skipTests>
</configuration> </configuration>

View File

@ -32,7 +32,7 @@ public enum CachingPolicy {
private String policy; private String policy;
private CachingPolicy(String policy) { CachingPolicy(String policy) {
this.policy = policy; this.policy = policy;
} }

View File

@ -239,12 +239,12 @@ public class Commander {
//since payment time is lesser than queuetime it would have already failed..additional check not needed //since payment time is lesser than queuetime it would have already failed..additional check not needed
LOG.trace("Order " + qt.order.id + ": Queue time for order over, failed.."); LOG.trace("Order " + qt.order.id + ": Queue time for order over, failed..");
return; return;
} else if ((qt.taskType.equals(TaskType.Payment) && !qt.order.paid.equals(PaymentStatus.Trying)) } else if (qt.taskType.equals(TaskType.Payment) && !qt.order.paid.equals(PaymentStatus.Trying)
|| (qt.taskType.equals(TaskType.Messaging) && ((qt.messageType == 1 || qt.taskType.equals(TaskType.Messaging) && (qt.messageType == 1
&& !qt.order.messageSent.equals(MessageSent.NoneSent)) && !qt.order.messageSent.equals(MessageSent.NoneSent)
|| qt.order.messageSent.equals(MessageSent.PaymentFail) || qt.order.messageSent.equals(MessageSent.PaymentFail)
|| qt.order.messageSent.equals(MessageSent.PaymentSuccessful))) || qt.order.messageSent.equals(MessageSent.PaymentSuccessful))
|| (qt.taskType.equals(TaskType.EmployeeDb) && qt.order.addedToEmployeeHandle)) { || qt.taskType.equals(TaskType.EmployeeDb) && qt.order.addedToEmployeeHandle) {
LOG.trace("Order " + qt.order.id + ": Not queueing task since task already done.."); LOG.trace("Order " + qt.order.id + ": Not queueing task since task already done..");
return; return;
} }
@ -576,8 +576,8 @@ public class Commander {
|| qt.order.messageSent.equals(MessageSent.PaymentSuccessful)) { || qt.order.messageSent.equals(MessageSent.PaymentSuccessful)) {
tryDequeue(); tryDequeue();
LOG.trace("Order " + qt.order.id + ": This messaging task already done, dequeue.."); LOG.trace("Order " + qt.order.id + ": This messaging task already done, dequeue..");
} else if ((qt.messageType == 1 && (!qt.order.messageSent.equals(MessageSent.NoneSent) } else if (qt.messageType == 1 && (!qt.order.messageSent.equals(MessageSent.NoneSent)
|| !qt.order.paid.equals(PaymentStatus.Trying)))) { || !qt.order.paid.equals(PaymentStatus.Trying))) {
tryDequeue(); tryDequeue();
LOG.trace("Order " + qt.order.id + ": This messaging task does not need to be done, dequeue.."); LOG.trace("Order " + qt.order.id + ": This messaging task does not need to be done, dequeue..");
} else if (qt.messageType == 0) { } else if (qt.messageType == 0) {
@ -606,8 +606,7 @@ public class Commander {
} else { } else {
Thread.sleep(queueTaskTime / 3); Thread.sleep(queueTaskTime / 3);
tryDoingTasksInQueue(); tryDoingTasksInQueue();
} }
return;
} }
} }

View File

@ -83,7 +83,7 @@ public class Queue<T> {
Node temp = front; Node temp = front;
front = front.next; front = front.next;
size = size - 1; size = size - 1;
return ((T) temp.value); return (T) temp.value;
} }
} }
@ -91,7 +91,7 @@ public class Queue<T> {
if (isEmpty()) { if (isEmpty()) {
throw new IsEmptyException(); throw new IsEmptyException();
} else { } else {
return ((T)front.value); return (T)front.value;
} }
} }
} }

View File

@ -55,7 +55,9 @@ public class App {
ExecutorService executorService = Executors.newFixedThreadPool(3); ExecutorService executorService = Executors.newFixedThreadPool(3);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
executorService.execute(() -> { executorService.execute(() -> {
while (inventory.addItem(new Item())) {}; while (inventory.addItem(new Item())) {
LOGGER.info("Adding another item");
}
}); });
} }

View File

@ -97,7 +97,7 @@ public class Event implements IEvent, Runnable {
this.eventListener = null; this.eventListener = null;
} }
private final void completed() { private void completed() {
if (eventListener != null) { if (eventListener != null) {
eventListener.completedEventHandler(eventId); eventListener.completedEventHandler(eventId);
} }

View File

@ -24,3 +24,4 @@
com.iluwatar.servicelayer.common.BaseEntity=UnusedPrivateField com.iluwatar.servicelayer.common.BaseEntity=UnusedPrivateField
com.iluwatar.doublechecked.locking.App=EmptyStatementNotInLoop,EmptyWhileStmt com.iluwatar.doublechecked.locking.App=EmptyStatementNotInLoop,EmptyWhileStmt
com.iluwatar.doublechecked.locking.InventoryTest=EmptyStatementNotInLoop,EmptyWhileStmt com.iluwatar.doublechecked.locking.InventoryTest=EmptyStatementNotInLoop,EmptyWhileStmt
domainapp.dom.modules.simple.QSimpleObject=UnusedFormalParameter

View File

@ -34,7 +34,7 @@ public enum Content {
private String title; private String title;
private Content(String title) { Content(String title) {
this.title = title; this.title = title;
} }

View File

@ -43,5 +43,10 @@
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -48,7 +48,7 @@ public class ConsoleLottery {
Injector injector = Guice.createInjector(new LotteryModule()); Injector injector = Guice.createInjector(new LotteryModule());
LotteryService service = injector.getInstance( LotteryService.class); LotteryService service = injector.getInstance( LotteryService.class);
WireTransfers bank = injector.getInstance(WireTransfers.class); WireTransfers bank = injector.getInstance(WireTransfers.class);
try (final Scanner scanner = new Scanner(System.in)) { try (Scanner scanner = new Scanner(System.in)) {
boolean exit = false; boolean exit = false;
while (!exit) { while (!exit) {
printMainMenu(); printMainMenu();

View File

@ -90,31 +90,9 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
<executions>
<execution>
<id>source</id>
<phase>compile</phase>
</execution>
<execution>
<id>test</id>
<phase>test-compile</phase>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration> <configuration>
<includes> <includes>
<include>**/*Test.java</include> <include>**/*Test.java</include>

View File

@ -66,7 +66,7 @@ public interface Message {
/** /**
* Enumeration of Type of Headers * Enumeration of Type of Headers
*/ */
public enum Headers { enum Headers {
DATE, SENDER DATE, SENDER
} }

56
pom.xml
View File

@ -36,10 +36,9 @@
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
<junit-jupiter.version>5.0.2</junit-jupiter.version> <junit-jupiter.version>5.0.2</junit-jupiter.version>
<junit-vintage.version>${junit.version}.2</junit-vintage.version> <junit-vintage.version>${junit.version}.2</junit-vintage.version>
<junit-platform.version>1.0.2</junit-platform.version>
<sping-test-junit5.version>1.0.2</sping-test-junit5.version> <sping-test-junit5.version>1.0.2</sping-test-junit5.version>
<compiler.version>3.0</compiler.version> <compiler.version>3.8.1</compiler.version>
<jacoco.version>0.7.2.201409121644</jacoco.version> <jacoco.version>0.8.4</jacoco.version>
<commons-dbcp.version>1.4</commons-dbcp.version> <commons-dbcp.version>1.4</commons-dbcp.version>
<camel.version>2.16.1</camel.version> <camel.version>2.16.1</camel.version>
<guava.version>19.0</guava.version> <guava.version>19.0</guava.version>
@ -55,6 +54,7 @@
<aws-lambda-log4j.version>1.0.0</aws-lambda-log4j.version> <aws-lambda-log4j.version>1.0.0</aws-lambda-log4j.version>
<aws-lambda-java-events.version>2.0.1</aws-lambda-java-events.version> <aws-lambda-java-events.version>2.0.1</aws-lambda-java-events.version>
<jackson.version>2.8.5</jackson.version> <jackson.version>2.8.5</jackson.version>
<pmd.version>3.12.0</pmd.version>
</properties> </properties>
<modules> <modules>
<module>abstract-factory</module> <module>abstract-factory</module>
@ -353,20 +353,27 @@
</lifecycleMappingMetadata> </lifecycleMappingMetadata>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<argLine>-Xmx1024M ${argLine}</argLine>
</configuration>
</plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
<plugins> <plugins>
<!-- Tell maven to compile using Java 8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
@ -387,7 +394,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version> <version>3.1.0</version>
<executions> <executions>
<execution> <execution>
<id>validate</id> <id>validate</id>
@ -406,25 +413,10 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit-platform.version}</version>
</dependency>
</dependencies>
<configuration>
<argLine>-Xmx1024M ${argLine}</argLine>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId> <artifactId>maven-pmd-plugin</artifactId>
<version>3.6</version> <version>${pmd.version}</version>
<configuration> <configuration>
<failOnViolation>true</failOnViolation> <failOnViolation>true</failOnViolation>
<failurePriority>5</failurePriority> <failurePriority>5</failurePriority>
@ -445,7 +437,7 @@
<plugin> <plugin>
<groupId>com.mycila</groupId> <groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId> <artifactId>license-maven-plugin</artifactId>
<version>2.11</version> <version>3.0</version>
<configuration> <configuration>
<header>com/mycila/maven/plugin/license/templates/MIT.txt</header> <header>com/mycila/maven/plugin/license/templates/MIT.txt</header>
<properties> <properties>
@ -471,7 +463,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId> <artifactId>maven-pmd-plugin</artifactId>
<version>3.6</version> <version>${pmd.version}</version>
</plugin> </plugin>
</plugins> </plugins>
</reporting> </reporting>

View File

@ -43,7 +43,8 @@ public class RetryTest {
public void errors() { public void errors() {
final BusinessException e = new BusinessException("unhandled"); final BusinessException e = new BusinessException("unhandled");
final Retry<String> retry = new Retry<>( final Retry<String> retry = new Retry<>(
() -> { throw e; }, () -> {
throw e; },
2, 2,
0 0
); );
@ -67,7 +68,8 @@ public class RetryTest {
public void attempts() { public void attempts() {
final BusinessException e = new BusinessException("unhandled"); final BusinessException e = new BusinessException("unhandled");
final Retry<String> retry = new Retry<>( final Retry<String> retry = new Retry<>(
() -> { throw e; }, () -> {
throw e; },
2, 2,
0 0
); );
@ -91,7 +93,8 @@ public class RetryTest {
public void ignore() throws Exception { public void ignore() throws Exception {
final BusinessException e = new CustomerNotFoundException("customer not found"); final BusinessException e = new CustomerNotFoundException("customer not found");
final Retry<String> retry = new Retry<>( final Retry<String> retry = new Retry<>(
() -> { throw e; }, () -> {
throw e; },
2, 2,
0, 0,
ex -> CustomerNotFoundException.class.isAssignableFrom(ex.getClass()) ex -> CustomerNotFoundException.class.isAssignableFrom(ex.getClass())

View File

@ -30,7 +30,7 @@ public class Fruit {
/** /**
* Enumeration of Fruit Types * Enumeration of Fruit Types
*/ */
public static enum FruitType { public enum FruitType {
ORANGE, APPLE, LEMON ORANGE, APPLE, LEMON
} }

View File

@ -25,10 +25,9 @@ package com.iluwatar.servicelayer.common;
import javax.persistence.Inheritance; import javax.persistence.Inheritance;
import javax.persistence.InheritanceType; import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
/** /**
* *
* Base class for entities. * Base class for entities.
* *
*/ */
@ -36,9 +35,6 @@ import javax.persistence.Version;
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class BaseEntity { public abstract class BaseEntity {
@Version
private Long version;
/** /**
* Indicates the unique id of this entity * Indicates the unique id of this entity
* *

View File

@ -62,7 +62,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration> <configuration>
<skipTests>false</skipTests> <skipTests>false</skipTests>
</configuration> </configuration>