Merge remote-tracking branch 'eugenp/master'
This commit is contained in:
commit
cee1fafe95
|
@ -137,7 +137,7 @@
|
||||||
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
|
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
|
||||||
<gson.version>2.8.0</gson.version>
|
<gson.version>2.8.0</gson.version>
|
||||||
<aws-java-sdk.version>1.11.290</aws-java-sdk.version>
|
<aws-java-sdk.version>1.11.290</aws-java-sdk.version>
|
||||||
<mockito-core.version>2.8.9</mockito-core.version>
|
<mockito-core.version>2.21.0</mockito-core.version>
|
||||||
<assertj-core.version>3.8.0</assertj-core.version>
|
<assertj-core.version>3.8.0</assertj-core.version>
|
||||||
<dynamodblocal.version>1.11.86</dynamodblocal.version>
|
<dynamodblocal.version>1.11.86</dynamodblocal.version>
|
||||||
<dynamodblocal.repository.url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</dynamodblocal.repository.url>
|
<dynamodblocal.repository.url>https://s3-us-west-2.amazonaws.com/dynamodb-local/release</dynamodblocal.repository.url>
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class FilenameFilterManualTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setupClass() {
|
public static void setupClass() {
|
||||||
directory = new File(FilenameFilterManualTest.class.getClassLoader()
|
directory = new File(FilenameFilterManualTest.class.getClassLoader()
|
||||||
.getResource("testFolder")
|
.getResource("fileNameFilterManualTestFolder")
|
||||||
.getFile());
|
.getFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,16 @@
|
||||||
<artifactId>c3p0</artifactId>
|
<artifactId>c3p0</artifactId>
|
||||||
<version>${c3p0.version}</version>
|
<version>${c3p0.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-web</artifactId>
|
||||||
|
<version>${springframework.spring-web.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
<version>${springframework.boot.spring-boot-starter.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>core-java-persistence</finalName>
|
<finalName>core-java-persistence</finalName>
|
||||||
|
@ -55,5 +65,7 @@
|
||||||
<commons-dbcp2.version>2.4.0</commons-dbcp2.version>
|
<commons-dbcp2.version>2.4.0</commons-dbcp2.version>
|
||||||
<HikariCP.version>3.2.0</HikariCP.version>
|
<HikariCP.version>3.2.0</HikariCP.version>
|
||||||
<c3p0.version>0.9.5.2</c3p0.version>
|
<c3p0.version>0.9.5.2</c3p0.version>
|
||||||
|
<springframework.boot.spring-boot-starter.version>1.5.8.RELEASE</springframework.boot.spring-boot-starter.version>
|
||||||
|
<springframework.spring-web.version>4.3.4.RELEASE</springframework.spring-web.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -127,11 +127,6 @@
|
||||||
<artifactId>spring-web</artifactId>
|
<artifactId>spring-web</artifactId>
|
||||||
<version>${springframework.spring-web.version}</version>
|
<version>${springframework.spring-web.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
<version>${springframework.boot.spring-boot-starter.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
|
@ -532,7 +527,6 @@
|
||||||
<!-- maven plugins -->
|
<!-- maven plugins -->
|
||||||
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
|
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
|
||||||
<springframework.spring-web.version>4.3.4.RELEASE</springframework.spring-web.version>
|
<springframework.spring-web.version>4.3.4.RELEASE</springframework.spring-web.version>
|
||||||
<springframework.boot.spring-boot-starter.version>1.5.8.RELEASE</springframework.boot.spring-boot-starter.version>
|
|
||||||
|
|
||||||
<javamoney.moneta.version>1.1</javamoney.moneta.version>
|
<javamoney.moneta.version>1.1</javamoney.moneta.version>
|
||||||
<h2database.version>1.4.197</h2database.version>
|
<h2database.version>1.4.197</h2database.version>
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.baeldung.constructorsstaticfactorymethods.application;
|
||||||
|
|
||||||
|
import com.baeldung.constructorsstaticfactorymethods.entities.User;
|
||||||
|
|
||||||
|
public class Application {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
User user1 = User.createWithDefaultCountry("John", "john@domain.com");
|
||||||
|
User user2 = User.createWithLoggedInstantiationTime("John", "john@domain.com", "Argentina");
|
||||||
|
User user3 = User.getSingletonInstance("John", "john@domain.com", "Argentina");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.baeldung.constructorsstaticfactorymethods.entities;
|
||||||
|
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.logging.ConsoleHandler;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.logging.SimpleFormatter;
|
||||||
|
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
private static User instance = null;
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(User.class.getName());
|
||||||
|
private final String name;
|
||||||
|
private final String email;
|
||||||
|
private final String country;
|
||||||
|
|
||||||
|
public static User createWithDefaultCountry(String name, String email) {
|
||||||
|
return new User(name, email, "Argentina");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static User createWithLoggedInstantiationTime(String name, String email, String country) {
|
||||||
|
setLoggerProperties();
|
||||||
|
LOGGER.log(Level.INFO, "Creating User instance at : {0}", LocalTime.now());
|
||||||
|
return new User(name, email, country);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static User getSingletonInstance(String name, String email, String country) {
|
||||||
|
if (instance == null) {
|
||||||
|
synchronized (User.class) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new User(name, email, country);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private User(String name, String email, String country) {
|
||||||
|
this.name = name;
|
||||||
|
this.email = email;
|
||||||
|
this.country = country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCountry() {
|
||||||
|
return country;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setLoggerProperties() {
|
||||||
|
ConsoleHandler handler = new ConsoleHandler();
|
||||||
|
handler.setLevel(Level.INFO);
|
||||||
|
handler.setFormatter(new SimpleFormatter());
|
||||||
|
LOGGER.addHandler(handler);
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,11 +25,7 @@ public class Exceptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Player> loadAllPlayers(String playersFile) throws IOException{
|
public List<Player> loadAllPlayers(String playersFile) throws IOException{
|
||||||
try {
|
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
} catch(IOException ex) {
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerScoreThrows(String playerFile) throws FileNotFoundException {
|
public int getPlayerScoreThrows(String playerFile) throws FileNotFoundException {
|
||||||
|
@ -163,14 +159,8 @@ public class Exceptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void throwAsGotoAntiPattern() {
|
public void throwAsGotoAntiPattern() throws MyException {
|
||||||
try {
|
|
||||||
// bunch of code
|
|
||||||
throw new MyException();
|
throw new MyException();
|
||||||
// second bunch of code
|
|
||||||
} catch ( MyException e ) {
|
|
||||||
// third bunch of code
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerScoreSwallowingExceptionAntiPattern(String playerFile) {
|
public int getPlayerScoreSwallowingExceptionAntiPattern(String playerFile) {
|
||||||
|
|
|
@ -16,8 +16,11 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by madhumita.g on 01-08-2018.
|
* Created by madhumita.g on 01-08-2018.
|
||||||
*/
|
*/
|
||||||
|
@ -66,20 +69,18 @@ public class AnimalUnitTest {
|
||||||
int testValue = 3;
|
int testValue = 3;
|
||||||
animal.makeNoise(testValue);
|
animal.makeNoise(testValue);
|
||||||
|
|
||||||
verify(mockAppender).doAppend(captorLoggingEvent.capture());
|
verify(mockAppender,times(3)).doAppend(captorLoggingEvent.capture());
|
||||||
|
|
||||||
final LoggingEvent loggingEvent = captorLoggingEvent.getValue();
|
final List<LoggingEvent> loggingEvents = captorLoggingEvent.getAllValues();
|
||||||
|
|
||||||
while (testValue != 0) {
|
for(LoggingEvent loggingEvent : loggingEvents)
|
||||||
|
{
|
||||||
assertThat(loggingEvent.getLevel(), is(Level.INFO));
|
assertThat(loggingEvent.getLevel(), is(Level.INFO));
|
||||||
|
|
||||||
assertThat(loggingEvent.getFormattedMessage(),
|
assertThat(loggingEvent.getFormattedMessage(),
|
||||||
is("generic animal noise countdown 3\n"
|
is("generic animal noise countdown "+testValue));
|
||||||
+ "generic animal noise countdown 2\n"
|
|
||||||
+ "generic animal noise countdown 1\n"));
|
|
||||||
|
|
||||||
testValue-=1;
|
|
||||||
|
|
||||||
|
testValue--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.baeldung.constructorsstaticfactorymethods;
|
||||||
|
|
||||||
|
import com.baeldung.constructorsstaticfactorymethods.entities.User;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class UserUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenUserClass_whenCalledcreateWithDefaultCountry_thenCorrect() {
|
||||||
|
assertThat(User.createWithDefaultCountry("John", "john@domain.com")).isInstanceOf(User.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenUserIntanceCreatedWithcreateWithDefaultCountry_whenCalledgetName_thenCorrect() {
|
||||||
|
User user = User.createWithDefaultCountry("John", "john@domain.com");
|
||||||
|
assertThat(user.getName()).isEqualTo("John");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenUserIntanceCreatedWithcreateWithDefaultCountry_whenCalledgetEmail_thenCorrect() {
|
||||||
|
User user = User.createWithDefaultCountry("John", "john@domain.com");
|
||||||
|
assertThat(user.getEmail()).isEqualTo("john@domain.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenUserIntanceCreatedWithcreateWithDefaultCountry_whenCalledgetCountry_thenCorrect() {
|
||||||
|
User user = User.createWithDefaultCountry("John", "john@domain.com");
|
||||||
|
assertThat(user.getCountry()).isEqualTo("Argentina");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenUserInstanceCreatedWithcreateWithInstantiationTime_whenCalledcreateWithInstantiationTime_thenCorrect() {
|
||||||
|
assertThat(User.createWithLoggedInstantiationTime("John", "john@domain.com", "Argentina")).isInstanceOf(User.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenUserInstanceCreatedWithgetSingletonIntance_whenCalledgetSingletonInstance_thenCorrect() {
|
||||||
|
User user1 = User.getSingletonInstance("John", "john@domain.com", "Argentina");
|
||||||
|
User user2 = User.getSingletonInstance("John", "john@domain.com", "Argentina");
|
||||||
|
assertThat(user1).isEqualTo(user2);
|
||||||
|
}
|
||||||
|
}
|
|
@ -103,7 +103,7 @@ class CoroutinesTest {
|
||||||
//given
|
//given
|
||||||
val job = launch(CommonPool) {
|
val job = launch(CommonPool) {
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
println("is working")
|
//println("is working")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class BinaryTree {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(int value) {
|
public void delete(int value) {
|
||||||
deleteRecursive(root, value);
|
root = deleteRecursive(root, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Node deleteRecursive(Node current, int value) {
|
private Node deleteRecursive(Node current, int value) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BinaryTreeTest {
|
public class BinaryTreeUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenABinaryTree_WhenAddingElements_ThenTreeNotEmpty() {
|
public void givenABinaryTree_WhenAddingElements_ThenTreeNotEmpty() {
|
||||||
|
@ -70,6 +70,17 @@ public class BinaryTreeTest {
|
||||||
assertEquals(initialSize, bt.getSize());
|
assertEquals(initialSize, bt.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void it_deletes_the_root() {
|
||||||
|
int value = 12;
|
||||||
|
BinaryTree bt = new BinaryTree();
|
||||||
|
bt.add(value);
|
||||||
|
|
||||||
|
assertTrue(bt.containsNode(value));
|
||||||
|
bt.delete(value);
|
||||||
|
assertFalse(bt.containsNode(value));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenABinaryTree_WhenTraversingInOrder_ThenPrintValues() {
|
public void givenABinaryTree_WhenTraversingInOrder_ThenPrintValues() {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.junit.jupiter.api.Assertions;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class TrieTest {
|
public class TrieUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenEmptyTrie_thenNoElements() {
|
public void whenEmptyTrie_thenNoElements() {
|
|
@ -213,7 +213,7 @@
|
||||||
<web3j.core.version>3.3.1</web3j.core.version>
|
<web3j.core.version>3.3.1</web3j.core.version>
|
||||||
<springframework.version>5.0.5.RELEASE</springframework.version>
|
<springframework.version>5.0.5.RELEASE</springframework.version>
|
||||||
<spring.boot.version>1.5.6.RELEASE</spring.boot.version>
|
<spring.boot.version>1.5.6.RELEASE</spring.boot.version>
|
||||||
<mockito.version>1.10.19</mockito.version>
|
<mockito.version>2.21.0</mockito.version>
|
||||||
<jackson-databind.version>2.5.0</jackson-databind.version>
|
<jackson-databind.version>2.5.0</jackson-databind.version>
|
||||||
<hamcrest.version>1.3</hamcrest.version>
|
<hamcrest.version>1.3</hamcrest.version>
|
||||||
<jackson.version>2.9.3</jackson.version>
|
<jackson.version>2.9.3</jackson.version>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
/bin/
|
||||||
|
|
||||||
|
#ignore gradle
|
||||||
|
.gradle/
|
||||||
|
|
||||||
|
|
||||||
|
#ignore build and generated files
|
||||||
|
build/
|
||||||
|
node/
|
||||||
|
out/
|
||||||
|
|
||||||
|
#ignore installed node modules and package lock file
|
||||||
|
node_modules/
|
||||||
|
package-lock.json
|
|
@ -0,0 +1,199 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>core-kotlin</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<groupId>com.stackify</groupId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jcenter</id>
|
||||||
|
<url>http://jcenter.bintray.com</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.platform</groupId>
|
||||||
|
<artifactId>junit-platform-runner</artifactId>
|
||||||
|
<version>${junit.platform.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
|
<version>${kotlin-stdlib.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>${kotlin-stdlib.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test-junit</artifactId>
|
||||||
|
<version>${kotlin-test-junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-reflect</artifactId>
|
||||||
|
<version>${kotlin-reflect.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.spek</groupId>
|
||||||
|
<artifactId>spek-api</artifactId>
|
||||||
|
<version>1.1.5</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.spek</groupId>
|
||||||
|
<artifactId>spek-subject-extension</artifactId>
|
||||||
|
<version>1.1.5</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.spek</groupId>
|
||||||
|
<artifactId>spek-junit-platform-engine</artifactId>
|
||||||
|
<version>1.1.5</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.nhaarman</groupId>
|
||||||
|
<artifactId>mockito-kotlin</artifactId>
|
||||||
|
<version>${mockito-kotlin.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>${maven-failsafe-plugin.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${kotlin-maven-plugin.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${kotlin-maven-plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sourceDirs>
|
||||||
|
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
|
||||||
|
</sourceDirs>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sourceDirs>
|
||||||
|
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
|
||||||
|
</sourceDirs>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<!-- Replacing default-compile as it is treated specially
|
||||||
|
by maven -->
|
||||||
|
<execution>
|
||||||
|
<id>default-compile</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
<!-- Replacing default-testCompile as it is treated specially
|
||||||
|
by maven -->
|
||||||
|
<execution>
|
||||||
|
<id>default-testCompile</id>
|
||||||
|
<phase>none</phase>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>java-compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>${maven-failsafe-plugin.version}</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.platform</groupId>
|
||||||
|
<artifactId>junit-platform-surefire-provider</artifactId>
|
||||||
|
<version>${junit.platform.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>junit5</id>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<includes>
|
||||||
|
<include>**/*Test5.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven-failsafe-plugin.version>2.22.0</maven-failsafe-plugin.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<kotlin-maven-plugin.version>1.2.60</kotlin-maven-plugin.version>
|
||||||
|
<kotlin-test-junit.version>1.2.51</kotlin-test-junit.version>
|
||||||
|
<kotlin-stdlib.version>1.2.51</kotlin-stdlib.version>
|
||||||
|
<kotlin-reflect.version>1.2.51</kotlin-reflect.version>
|
||||||
|
<kotlinx.version>0.22.5</kotlinx.version>
|
||||||
|
<mockito-kotlin.version>1.5.0</mockito-kotlin.version>
|
||||||
|
<commons-math3.version>3.6.1</commons-math3.version>
|
||||||
|
<junit.platform.version>1.0.0</junit.platform.version>
|
||||||
|
<junit.vintage.version>5.2.0</junit.vintage.version>
|
||||||
|
<assertj.version>3.10.0</assertj.version>
|
||||||
|
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -24,7 +24,7 @@ class ExceptionsTest {
|
||||||
fun givenANullString_whenUsingElvisOperator_thenExceptionIsThrown() {
|
fun givenANullString_whenUsingElvisOperator_thenExceptionIsThrown() {
|
||||||
val sampleString: String? = null
|
val sampleString: String? = null
|
||||||
|
|
||||||
val length: Int = sampleString?.length ?: throw IllegalArgumentException("String must not be null")
|
sampleString?.length ?: throw IllegalArgumentException("String must not be null")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun funThrowingException(): Nothing {
|
private fun funThrowingException(): Nothing {
|
|
@ -84,7 +84,7 @@
|
||||||
<spring-test.version>5.0.5.RELEASE</spring-test.version>
|
<spring-test.version>5.0.5.RELEASE</spring-test.version>
|
||||||
<gson.version>2.8.2</gson.version>
|
<gson.version>2.8.2</gson.version>
|
||||||
<assertj.version>3.9.1</assertj.version>
|
<assertj.version>3.9.1</assertj.version>
|
||||||
<mockito.version>2.18.3</mockito.version>
|
<mockito.version>2.21.0</mockito.version>
|
||||||
<commons-fileupload.version>1.3.3</commons-fileupload.version>
|
<commons-fileupload.version>1.3.3</commons-fileupload.version>
|
||||||
<commons-io.version>2.6</commons-io.version>
|
<commons-io.version>2.6</commons-io.version>
|
||||||
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
|
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
|
||||||
|
|
|
@ -115,6 +115,30 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>default</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>DataTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
<includes>
|
||||||
|
<include>TestFail.java</include>
|
||||||
|
<include>DataCheck.java</include>
|
||||||
|
</includes>
|
||||||
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.resources.version>3.0.2</maven.resources.version>
|
<maven.resources.version>3.0.2</maven.resources.version>
|
||||||
<maven.failsafe.version>2.21.0</maven.failsafe.version>
|
<maven.failsafe.version>2.21.0</maven.failsafe.version>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -1238,7 +1238,7 @@
|
||||||
<!-- <gib.enabled>false</gib.enabled> -->
|
<!-- <gib.enabled>false</gib.enabled> -->
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
<org.hamcrest.version>1.3</org.hamcrest.version>
|
<org.hamcrest.version>1.3</org.hamcrest.version>
|
||||||
<mockito.version>2.8.9</mockito.version>
|
<mockito.version>2.21.0</mockito.version>
|
||||||
<!-- logging -->
|
<!-- logging -->
|
||||||
<org.slf4j.version>1.7.21</org.slf4j.version>
|
<org.slf4j.version>1.7.21</org.slf4j.version>
|
||||||
<logback.version>1.1.7</logback.version>
|
<logback.version>1.1.7</logback.version>
|
||||||
|
|
|
@ -16,11 +16,6 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-all</artifactId>
|
|
||||||
<version>${mockito.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>spring-test</artifactId>
|
||||||
|
@ -82,15 +77,7 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>java.net</id>
|
|
||||||
<url>https://maven.java.net/content/repositories/releases/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<mockito.version>1.10.19</mockito.version>
|
|
||||||
<mockito.spring.boot.version>1.4.4.RELEASE</mockito.spring.boot.version>
|
<mockito.spring.boot.version>1.4.4.RELEASE</mockito.spring.boot.version>
|
||||||
<javax.inject.version>1</javax.inject.version>
|
<javax.inject.version>1</javax.inject.version>
|
||||||
<guava.version>20.0</guava.version>
|
<guava.version>20.0</guava.version>
|
||||||
|
|
|
@ -24,13 +24,13 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-all</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>${mockito.version}</version>
|
<version>${mockito.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<mockito.version>1.10.19</mockito.version>
|
<mockito.version>2.21.0</mockito.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.baeldung.domain.util;
|
||||||
import com.baeldung.domain.model.Message;
|
import com.baeldung.domain.model.Message;
|
||||||
import org.mockito.ArgumentMatcher;
|
import org.mockito.ArgumentMatcher;
|
||||||
|
|
||||||
public class MessageMatcher extends ArgumentMatcher<Message> {
|
public class MessageMatcher implements ArgumentMatcher<Message> {
|
||||||
|
|
||||||
private Message left;
|
private Message left;
|
||||||
|
|
||||||
|
@ -12,16 +12,11 @@ public class MessageMatcher extends ArgumentMatcher<Message> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Object object) {
|
public boolean matches(Message right) {
|
||||||
if (object instanceof Message) {
|
|
||||||
Message right = (Message) object;
|
|
||||||
return left.getFrom().equals(right.getFrom()) &&
|
return left.getFrom().equals(right.getFrom()) &&
|
||||||
left.getTo().equals(right.getTo()) &&
|
left.getTo().equals(right.getTo()) &&
|
||||||
left.getText().equals(right.getText()) &&
|
left.getText().equals(right.getText()) &&
|
||||||
right.getDate() != null &&
|
right.getDate() != null &&
|
||||||
right.getId() != null;
|
right.getId() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -41,5 +41,5 @@ mysql -u root -p
|
||||||
### Use the REST Service
|
### Use the REST Service
|
||||||
|
|
||||||
```
|
```
|
||||||
curl http://localhost:8080/spring-rest-full/foos
|
curl http://localhost:8082/spring-rest-full/auth/foos
|
||||||
```
|
```
|
||||||
|
|
|
@ -15,6 +15,6 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<mockito.version>2.8.9</mockito.version>
|
<mockito.version>2.21.0</mockito.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<mockito.version>2.9.0</mockito.version>
|
<mockito.version>2.21.0</mockito.version>
|
||||||
<easymock.version>3.5.1</easymock.version>
|
<easymock.version>3.5.1</easymock.version>
|
||||||
<jmockit.version>1.34</jmockit.version>
|
<jmockit.version>1.34</jmockit.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
|
@ -104,7 +104,7 @@
|
||||||
<junit.vintage.version>4.12.1</junit.vintage.version>
|
<junit.vintage.version>4.12.1</junit.vintage.version>
|
||||||
<log4j2.version>2.8.2</log4j2.version>
|
<log4j2.version>2.8.2</log4j2.version>
|
||||||
<h2.version>1.4.196</h2.version>
|
<h2.version>1.4.196</h2.version>
|
||||||
<mockito.version>2.11.0</mockito.version>
|
<mockito.version>2.21.0</mockito.version>
|
||||||
<spring.version>5.0.1.RELEASE</spring.version>
|
<spring.version>5.0.1.RELEASE</spring.version>
|
||||||
<testcontainers.version>1.7.2</testcontainers.version>
|
<testcontainers.version>1.7.2</testcontainers.version>
|
||||||
<postgresql.version>42.2.2</postgresql.version>
|
<postgresql.version>42.2.2</postgresql.version>
|
||||||
|
|
Loading…
Reference in New Issue