mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 08:58:26 +00:00
dependencies: Refactor unit tests without depending on Guava (#2181)
* Refactor unit tests without depending on Guava * Remove redundant casts. * Move import up * Update repository/src/test/java/com/iluwatar/repository/RepositoryTest.java Co-authored-by: Robert Volkmann <20912167+robertvolkmann@users.noreply.github.com> * Update repository/src/test/java/com/iluwatar/repository/AnnotationBasedRepositoryTest.java Co-authored-by: Robert Volkmann <20912167+robertvolkmann@users.noreply.github.com> Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> Co-authored-by: Robert Volkmann <20912167+robertvolkmann@users.noreply.github.com>
This commit is contained in:
@@ -39,10 +39,6 @@
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -34,10 +34,6 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>filterer</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
<version>1.26.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<zk.version>9.0.0</zk.version>
|
||||
<guava.version>19.0</guava.version>
|
||||
<jetty-maven-plugin.version>9.4.28.v20200408</jetty-maven-plugin.version>
|
||||
<maven-war-plugin.version>3.3.2</maven-war-plugin.version>
|
||||
<maven-assembly-plugin.version>2.2</maven-assembly-plugin.version>
|
||||
@@ -84,12 +83,6 @@
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava-testlib</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
|
||||
@@ -24,18 +24,15 @@
|
||||
*/
|
||||
package com.iluwatar.model.view.viewmodel;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import com.google.common.testing.EqualsTester;
|
||||
|
||||
class BookTest {
|
||||
|
||||
@@ -67,13 +64,13 @@ class BookTest {
|
||||
|
||||
@Test
|
||||
void testEquals() {
|
||||
new EqualsTester().addEqualityGroup(testBook, testBookTwo).testEquals();
|
||||
assertEquals(testBook, testBookTwo);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToString() {
|
||||
assertThat(testBook.toString(), is(testBookTwo.toString()));
|
||||
assertThat(testBook.toString(), is(not(testBookThree.toString())));
|
||||
assertEquals(testBook.toString(), testBookTwo.toString());
|
||||
assertNotEquals(testBook.toString(), testBookThree.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
<spring-boot.version>2.7.5</spring-boot.version>
|
||||
<jacoco.version>0.8.8</jacoco.version>
|
||||
<commons-dbcp.version>1.4</commons-dbcp.version>
|
||||
<guava.version>19.0</guava.version>
|
||||
<htmlunit.version>2.66.0</htmlunit.version>
|
||||
<guice.version>4.0</guice.version>
|
||||
<system-lambda.version>1.1.0</system-lambda.version>
|
||||
@@ -223,11 +222,6 @@
|
||||
<artifactId>commons-dbcp</artifactId>
|
||||
<version>${commons-dbcp.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.htmlunit</groupId>
|
||||
<artifactId>htmlunit</artifactId>
|
||||
|
||||
@@ -55,10 +55,6 @@
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.repository;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -36,4 +37,6 @@ public interface PersonRepository
|
||||
extends CrudRepository<Person, Long>, JpaSpecificationExecutor<Person> {
|
||||
|
||||
Person findByName(String name);
|
||||
|
||||
List<Person> findAll();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@@ -66,7 +65,7 @@ class AnnotationBasedRepositoryTest {
|
||||
|
||||
@Test
|
||||
void testFindAll() {
|
||||
var actuals = Lists.newArrayList(repository.findAll());
|
||||
var actuals = repository.findAll();
|
||||
assertTrue(actuals.containsAll(persons) && persons.containsAll(actuals));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@@ -66,7 +65,7 @@ class RepositoryTest {
|
||||
|
||||
@Test
|
||||
void testFindAll() {
|
||||
var actuals = Lists.newArrayList(repository.findAll());
|
||||
var actuals = repository.findAll();
|
||||
assertTrue(actuals.containsAll(persons) && persons.containsAll(actuals));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,6 @@
|
||||
</parent>
|
||||
<artifactId>value-object</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava-testlib</artifactId>
|
||||
<version>23.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
|
||||
@@ -24,11 +24,9 @@
|
||||
*/
|
||||
package com.iluwatar.value.object;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
|
||||
import com.google.common.testing.EqualsTester;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
@@ -47,7 +45,7 @@ class HeroStatTest {
|
||||
void testEquals() {
|
||||
var heroStatA = HeroStat.valueOf(3, 9, 2);
|
||||
var heroStatB = HeroStat.valueOf(3, 9, 2);
|
||||
new EqualsTester().addEqualityGroup(heroStatA, heroStatB).testEquals();
|
||||
assertEquals(heroStatA, heroStatB);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,9 +57,8 @@ class HeroStatTest {
|
||||
var heroStatA = HeroStat.valueOf(3, 9, 2);
|
||||
var heroStatB = HeroStat.valueOf(3, 9, 2);
|
||||
var heroStatC = HeroStat.valueOf(3, 9, 8);
|
||||
|
||||
assertThat(heroStatA.toString(), is(heroStatB.toString()));
|
||||
assertThat(heroStatA.toString(), is(not(heroStatC.toString())));
|
||||
assertEquals(heroStatA.toString(), heroStatB.toString());
|
||||
assertNotEquals(heroStatA.toString(), heroStatC.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user