Adjust checkstyle rules. Make checkstyle fail the build when violations are found. Correct all current checkstyle violations.
This commit is contained in:
@ -39,8 +39,6 @@ public class AppConfig {
|
||||
|
||||
/**
|
||||
* Factory to create a especific instance of Entity Manager
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
@ -55,8 +53,6 @@ public class AppConfig {
|
||||
|
||||
/**
|
||||
* Properties for Jpa
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Properties jpaProperties() {
|
||||
Properties properties = new Properties();
|
||||
@ -65,6 +61,9 @@ public class AppConfig {
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get transaction manager
|
||||
*/
|
||||
@Bean
|
||||
public JpaTransactionManager transactionManager() throws SQLException {
|
||||
JpaTransactionManager transactionManager = new JpaTransactionManager();
|
||||
|
@ -23,6 +23,9 @@ public class Person {
|
||||
public Person() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Person(String name, String surname, int age) {
|
||||
this.name = name;
|
||||
this.surname = surname;
|
||||
@ -80,30 +83,40 @@ public class Person {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Person other = (Person) obj;
|
||||
if (age != other.age)
|
||||
if (age != other.age) {
|
||||
return false;
|
||||
}
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
if (other.id != null) {
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
}
|
||||
} else if (!id.equals(other.id)) {
|
||||
return false;
|
||||
}
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
if (other.name != null) {
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
}
|
||||
} else if (!name.equals(other.name)) {
|
||||
return false;
|
||||
}
|
||||
if (surname == null) {
|
||||
if (other.surname != null)
|
||||
if (other.surname != null) {
|
||||
return false;
|
||||
} else if (!surname.equals(other.surname))
|
||||
}
|
||||
} else if (!surname.equals(other.surname)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,10 @@ public class PersonSpecifications {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Name specification
|
||||
*
|
||||
*/
|
||||
public static class NameEqualSpec implements Specification<Person> {
|
||||
|
||||
public String name;
|
||||
@ -40,6 +44,9 @@ public class PersonSpecifications {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get predicate
|
||||
*/
|
||||
public Predicate toPredicate(Root<Person> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
||||
|
||||
return cb.equal(root.get("name"), this.name);
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<persistence version="1.0"
|
||||
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
|
||||
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
|
||||
|
||||
<persistence-unit name="jpaData" />
|
||||
<persistence-unit name="jpaData" />
|
||||
|
||||
</persistence>
|
||||
|
@ -1,39 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:security="http://www.springframework.org/schema/security"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
|
||||
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:security="http://www.springframework.org/schema/security" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
|
||||
|
||||
<jpa:repositories base-package="com.iluwatar" base-class="org.springframework.data.jpa.repository.support.SimpleJpaRepository" />
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<jpa:repositories base-package="com.iluwatar"
|
||||
base-class="org.springframework.data.jpa.repository.support.SimpleJpaRepository" />
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
destroy-method="close">
|
||||
<property name="driverClassName" value="org.h2.Driver" />
|
||||
<property name="url" value="jdbc:h2:~/databases/person" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="sa" />
|
||||
</bean>
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="entityManagerFactory"
|
||||
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="packagesToScan" value="com.iluwatar" />
|
||||
<property name="persistenceProvider">
|
||||
<bean class="org.hibernate.ejb.HibernatePersistence" />
|
||||
</property>
|
||||
<property name="jpaProperties">
|
||||
<map>
|
||||
<entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
|
||||
<entry key="hibernate.hbm2ddl.auto" value="create-drop" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
destroy-method="close">
|
||||
<property name="driverClassName" value="org.h2.Driver" />
|
||||
<property name="url" value="jdbc:h2:~/databases/person" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="sa" />
|
||||
</bean>
|
||||
|
||||
<bean id="entityManagerFactory"
|
||||
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
<property name="packagesToScan" value="com.iluwatar" />
|
||||
<property name="persistenceProvider">
|
||||
<bean class="org.hibernate.ejb.HibernatePersistence" />
|
||||
</property>
|
||||
<property name="jpaProperties">
|
||||
<map>
|
||||
<entry key="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
|
||||
<entry key="hibernate.hbm2ddl.auto" value="create-drop" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
|
@ -90,8 +90,8 @@ public class AnnotationBasedRepositoryTest {
|
||||
|
||||
assertEquals(3, persons.size());
|
||||
assertTrue(persons.stream().allMatch((item) -> {
|
||||
return item.getAge() > 20 && item.getAge() < 40;
|
||||
}));
|
||||
return item.getAge() > 20 && item.getAge() < 40;
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.iluwatar.repository;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -36,8 +37,6 @@ public class AppConfigTest {
|
||||
|
||||
/**
|
||||
* Test for correct query execution
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
|
@ -88,8 +88,8 @@ public class RepositoryTest {
|
||||
|
||||
assertEquals(3, persons.size());
|
||||
assertTrue(persons.stream().allMatch((item) -> {
|
||||
return item.getAge() > 20 && item.getAge() < 40;
|
||||
}));
|
||||
return item.getAge() > 20 && item.getAge() < 40;
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user