Merge branch 'master' of https://github.com/eugenp/tutorials into BAEL-4461-3
This commit is contained in:
commit
06b4145353
|
@ -94,6 +94,11 @@
|
|||
<artifactId>streamex</artifactId>
|
||||
<version>${streamex.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${joda.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -233,6 +238,7 @@
|
|||
<vavr.version>0.9.0</vavr.version>
|
||||
<protonpack.version>1.13</protonpack.version>
|
||||
<streamex.version>0.6.5</streamex.version>
|
||||
<joda.version>2.10</joda.version>
|
||||
<!-- testing -->
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
<avaitility.version>1.7.0</avaitility.version>
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package com.baeldung.datetime.modify;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DateIncrementer {
|
||||
private static final Logger log = Logger.getLogger(DateIncrementer.class.getName());
|
||||
private static final int INCREMENT_BY_IN_DAYS = 1;
|
||||
|
||||
public static String addOneDay(String date) {
|
||||
return LocalDate
|
||||
.parse(date)
|
||||
.plusDays(INCREMENT_BY_IN_DAYS)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static String addOneDayJodaTime(String date) {
|
||||
DateTime dateTime = new DateTime(date);
|
||||
return dateTime
|
||||
.plusDays(INCREMENT_BY_IN_DAYS)
|
||||
.toString("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public static String addOneDayCalendar(String date) throws ParseException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(sdf.parse(date));
|
||||
c.add(Calendar.DATE, 1);
|
||||
return sdf.format(c.getTime());
|
||||
}
|
||||
|
||||
public static String addOneDayApacheCommons(String date) throws ParseException {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date incrementedDate = DateUtils.addDays(sdf.parse(date), 1);
|
||||
return sdf.format(incrementedDate);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ParseException {
|
||||
String date = LocalDate
|
||||
.now()
|
||||
.toString();
|
||||
log.info("Current date = " + date);
|
||||
|
||||
String incrementedDateJava8 = DateIncrementer.addOneDay(date);
|
||||
log.info("Date incremented by one day using (Java 8): " + incrementedDateJava8);
|
||||
|
||||
String incrementedDateJodaTime = DateIncrementer.addOneDayJodaTime(date);
|
||||
log.info("Date incremented by one day using (Joda-Time): " + incrementedDateJodaTime);
|
||||
|
||||
String incrementedDateCalendar = addOneDayCalendar(date);
|
||||
log.info("Date incremented by one day using (java.util.Calendar): " + incrementedDateCalendar);
|
||||
|
||||
String incrementedDateApacheCommons = addOneDayApacheCommons(date);
|
||||
log.info("Date incremented by one day using (Apache Commons DateUtils): " + incrementedDateApacheCommons);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.baeldung.datetime.modify;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DateIncrementerUnitTest {
|
||||
private final static String DATE_TO_INCREMENT = "2018-07-03";
|
||||
private final static String EXPECTED_DATE = "2018-07-04";
|
||||
|
||||
@Test
|
||||
public void givenDate_whenUsingJava8_thenAddOneDay() throws Exception {
|
||||
String incrementedDate = DateIncrementer.addOneDay(DATE_TO_INCREMENT);
|
||||
assertEquals(EXPECTED_DATE, incrementedDate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDate_whenUsingJodaTime_thenAddOneDay() throws Exception {
|
||||
String incrementedDate = DateIncrementer.addOneDayJodaTime(DATE_TO_INCREMENT);
|
||||
assertEquals(EXPECTED_DATE, incrementedDate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDate_whenUsingCalendar_thenAddOneDay() throws Exception {
|
||||
String incrementedDate = DateIncrementer.addOneDayCalendar(DATE_TO_INCREMENT);
|
||||
assertEquals(EXPECTED_DATE, incrementedDate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenDate_whenUsingApacheCommons_thenAddOneDay() throws Exception {
|
||||
String incrementedDate = DateIncrementer.addOneDayApacheCommons(DATE_TO_INCREMENT);
|
||||
assertEquals(EXPECTED_DATE, incrementedDate);
|
||||
}
|
||||
}
|
|
@ -167,3 +167,5 @@
|
|||
- [How to Get the File Extension of a File in Java](http://www.baeldung.com/java-file-extension)
|
||||
- [Immutable Objects in Java](http://www.baeldung.com/java-immutable-object)
|
||||
- [Console I/O in Java](http://www.baeldung.com/java-console-input-output)
|
||||
- [Guide to the java.util.Arrays Class](http://www.baeldung.com/java-util-arrays)
|
||||
- [Create a Custom Exception in Java](http://www.baeldung.com/java-new-custom-exception)
|
||||
|
|
|
@ -33,3 +33,4 @@
|
|||
- [Kotlin String Templates](http://www.baeldung.com/kotlin-string-template)
|
||||
- [Java EE 8 Security API](http://www.baeldung.com/java-ee-8-security)
|
||||
- [Kotlin with Ktor](http://www.baeldung.com/kotlin-ktor)
|
||||
- [Working with Enums in Kotlin](http://www.baeldung.com/kotlin-enum)
|
||||
|
|
|
@ -14,9 +14,13 @@
|
|||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<id>jcenter</id>
|
||||
<url>http://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>kotlin-ktor</id>
|
||||
<url>https://dl.bintray.com/kotlin/ktor/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
|
@ -103,6 +107,22 @@
|
|||
<artifactId>klaxon</artifactId>
|
||||
<version>${klaxon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.ktor</groupId>
|
||||
<artifactId>ktor-server-netty</artifactId>
|
||||
<version>${ktor.io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.ktor</groupId>
|
||||
<artifactId>ktor-gson</artifactId>
|
||||
<version>${ktor.io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -209,12 +229,13 @@
|
|||
<kotlin-stdlib.version>1.2.41</kotlin-stdlib.version>
|
||||
<kotlin-reflect.version>1.2.41</kotlin-reflect.version>
|
||||
<kotlinx.version>0.22.5</kotlinx.version>
|
||||
<ktor.io.version>0.9.2</ktor.io.version>
|
||||
<mockito-kotlin.version>1.5.0</mockito-kotlin.version>
|
||||
<kodein.version>4.1.0</kodein.version>
|
||||
<klaxon.version>3.0.4</klaxon.version>
|
||||
<khttp.version>0.1.0</khttp.version>
|
||||
<commons-math3.version>3.6.1</commons-math3.version>
|
||||
<junit.platform.version>1.2.0</junit.platform.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>
|
||||
</properties>
|
||||
|
|
|
@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
/**
|
||||
* Created by Paul Jervis on 24/04/2018.
|
||||
*/
|
||||
class LambdaKotlinTest {
|
||||
class LambdaKotlinUnitTest {
|
||||
|
||||
@Test
|
||||
void givenJava6_whenUsingAnonnymousClass_thenReturnLambdaResult() {
|
|
@ -40,9 +40,9 @@ class LazyUnitTest {
|
|||
countDownLatch.countDown()
|
||||
|
||||
//then
|
||||
executorService.awaitTermination(1, TimeUnit.SECONDS)
|
||||
executorService.shutdown()
|
||||
assertEquals(numberOfInitializations.get(), 2)
|
||||
executorService.awaitTermination(5, TimeUnit.SECONDS)
|
||||
//assertEquals(numberOfInitializations.get(), 2)
|
||||
}
|
||||
|
||||
class ClassWithHeavyInitialization {
|
||||
|
|
|
@ -12,7 +12,7 @@ import kotlin.test.assertEquals
|
|||
import kotlin.test.assertTrue
|
||||
import kotlin.test.fail
|
||||
|
||||
class KhttpTest {
|
||||
class KhttpLiveTest {
|
||||
|
||||
@Test
|
||||
fun whenHttpGetRequestIsMade_thenArgsAreReturned() {
|
|
@ -24,20 +24,4 @@
|
|||
<type>ejb</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*EJBSetupTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -8,7 +8,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.PrintStream;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TextApplicationTest {
|
||||
public class TextApplicationIntegrationTest {
|
||||
|
||||
private static ByteArrayOutputStream outContent;
|
||||
|
|
@ -17,7 +17,7 @@ import javax.inject.Inject;
|
|||
|
||||
|
||||
@RunWith(Arquillian.class)
|
||||
public class StatefulEJBTest {
|
||||
public class StatefulEJBIntegrationTest {
|
||||
|
||||
@Inject
|
||||
private EJBClient1 ejbClient1;
|
|
@ -17,7 +17,7 @@ import javax.inject.Inject;
|
|||
|
||||
|
||||
@RunWith(Arquillian.class)
|
||||
public class StatelessEJBTest {
|
||||
public class StatelessEJBIntegrationTest {
|
||||
|
||||
@Inject
|
||||
private EJBClient1 ejbClient1;
|
|
@ -73,7 +73,7 @@ public class GuavaMemoizerUnitTest {
|
|||
// then
|
||||
assertSupplierGetExecutionResultAndDuration(memoizedSupplier, expectedValue, 0D);
|
||||
// add one more second until memoized Supplier is evicted from memory
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
TimeUnit.SECONDS.sleep(3);
|
||||
assertSupplierGetExecutionResultAndDuration(memoizedSupplier, expectedValue, 2000D);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,10 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<hibernate.version>5.2.12.Final</hibernate.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- Maven plugins -->
|
||||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
|
||||
<hibernate.version>5.3.2.Final</hibernate.version>
|
||||
<mysql.version>6.0.6</mysql.version>
|
||||
<mariaDB4j.version>2.2.3</mariaDB4j.version>
|
||||
<h2database.version>1.4.196</h2database.version>
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
package com.baeldung.hibernate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.hibernate.pojo.PointEntity;
|
||||
import com.baeldung.hibernate.pojo.PolygonEntity;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
@ -9,22 +23,8 @@ import com.vividsolutions.jts.geom.Polygon;
|
|||
import com.vividsolutions.jts.io.ParseException;
|
||||
import com.vividsolutions.jts.io.WKTReader;
|
||||
import com.vividsolutions.jts.util.GeometricShapeFactory;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.persistence.Query;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class HibernateSpatialTest {
|
||||
public class HibernateSpatialIntegrationTest {
|
||||
|
||||
private Session session;
|
||||
private Transaction transaction;
|
|
@ -15,7 +15,7 @@ import java.util.TimeZone;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TemporalValuesTest {
|
||||
public class TemporalValuesUnitTest {
|
||||
|
||||
private Session session;
|
||||
|
||||
|
@ -103,6 +103,8 @@ public class TemporalValuesTest {
|
|||
temporalValues.setLocalDate(LocalDate.parse("2017-11-15"));
|
||||
temporalValues.setLocalTime(LocalTime.parse("15:30:18"));
|
||||
temporalValues.setOffsetTime(OffsetTime.parse("08:22:12+01:00"));
|
||||
|
||||
System.out.println("********"+OffsetTime.parse("08:22:12+01:00").toString());
|
||||
temporalValues.setInstant(Instant.parse("2017-11-15T08:22:12Z"));
|
||||
temporalValues.setLocalDateTime(LocalDateTime.parse("2017-11-15T08:22:12"));
|
||||
temporalValues.setOffsetDateTime(OffsetDateTime.parse("2017-11-15T08:22:12+01:00"));
|
||||
|
@ -115,10 +117,10 @@ public class TemporalValuesTest {
|
|||
temporalValues = session.get(TemporalValues.class, temporalValues.getId());
|
||||
assertThat(temporalValues.getLocalDate()).isEqualTo(LocalDate.parse("2017-11-15"));
|
||||
assertThat(temporalValues.getLocalTime()).isEqualTo(LocalTime.parse("15:30:18"));
|
||||
assertThat(temporalValues.getOffsetTime()).isEqualTo(OffsetTime.parse("08:22:12+01:00"));
|
||||
//assertThat(temporalValues.getOffsetTime()).isEqualTo(OffsetTime.parse("08:22:12+01:00"));
|
||||
assertThat(temporalValues.getInstant()).isEqualTo(Instant.parse("2017-11-15T08:22:12Z"));
|
||||
assertThat(temporalValues.getLocalDateTime()).isEqualTo(LocalDateTime.parse("2017-11-15T08:22:12"));
|
||||
assertThat(temporalValues.getOffsetDateTime()).isEqualTo(OffsetDateTime.parse("2017-11-15T08:22:12+01:00"));
|
||||
//assertThat(temporalValues.getOffsetDateTime()).isEqualTo(OffsetDateTime.parse("2017-11-15T08:22:12+01:00"));
|
||||
assertThat(temporalValues.getZonedDateTime()).isEqualTo(ZonedDateTime.parse("2017-11-15T08:22:12+01:00[Europe/Paris]"));
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ import com.baeldung.hibernate.pojo.PersonName;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class PersonNameConverterTest {
|
||||
public class PersonNameConverterUnitTest {
|
||||
|
||||
private Session session;
|
||||
private Transaction transaction;
|
|
@ -13,7 +13,7 @@ import org.junit.Test;
|
|||
|
||||
import com.baeldung.hibernate.interceptors.entity.User;
|
||||
|
||||
public class HibernateInterceptorTest {
|
||||
public class HibernateInterceptorUnitTest {
|
||||
private static SessionFactory sessionFactory;
|
||||
private static Serializable userId;
|
||||
|
|
@ -18,7 +18,7 @@ import org.junit.Test;
|
|||
|
||||
import com.baeldung.hibernate.lob.model.User;
|
||||
|
||||
public class LobTest {
|
||||
public class LobUnitTest {
|
||||
|
||||
private Session session;
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
package com.baeldung.service;
|
||||
|
||||
import com.baeldung.BaeldungApp;
|
||||
import com.baeldung.domain.User;
|
||||
import com.baeldung.config.Constants;
|
||||
import com.baeldung.repository.UserRepository;
|
||||
import com.baeldung.service.dto.UserDTO;
|
||||
import java.time.ZonedDateTime;
|
||||
import com.baeldung.service.util.RandomUtil;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import java.util.Optional;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Test class for the UserResource REST controller.
|
||||
*
|
||||
* @see UserService
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = BaeldungApp.class)
|
||||
@Transactional
|
||||
public class UserServiceIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Test
|
||||
public void assertThatUserMustExistToResetPassword() {
|
||||
Optional<User> maybeUser = userService.requestPasswordReset("john.doe@localhost");
|
||||
assertThat(maybeUser.isPresent()).isFalse();
|
||||
|
||||
maybeUser = userService.requestPasswordReset("admin@localhost");
|
||||
assertThat(maybeUser.isPresent()).isTrue();
|
||||
|
||||
assertThat(maybeUser.get().getEmail()).isEqualTo("admin@localhost");
|
||||
assertThat(maybeUser.get().getResetDate()).isNotNull();
|
||||
assertThat(maybeUser.get().getResetKey()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertThatOnlyActivatedUserCanRequestPasswordReset() {
|
||||
User user = userService.createUser("johndoe", "johndoe", "John", "Doe", "john.doe@localhost", "http://placehold.it/50x50", "en-US");
|
||||
Optional<User> maybeUser = userService.requestPasswordReset("john.doe@localhost");
|
||||
assertThat(maybeUser.isPresent()).isFalse();
|
||||
userRepository.delete(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertThatResetKeyMustNotBeOlderThan24Hours() {
|
||||
User user = userService.createUser("johndoe", "johndoe", "John", "Doe", "john.doe@localhost", "http://placehold.it/50x50", "en-US");
|
||||
|
||||
ZonedDateTime daysAgo = ZonedDateTime.now().minusHours(25);
|
||||
String resetKey = RandomUtil.generateResetKey();
|
||||
user.setActivated(true);
|
||||
user.setResetDate(daysAgo);
|
||||
user.setResetKey(resetKey);
|
||||
|
||||
userRepository.save(user);
|
||||
|
||||
Optional<User> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey());
|
||||
|
||||
assertThat(maybeUser.isPresent()).isFalse();
|
||||
|
||||
userRepository.delete(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertThatResetKeyMustBeValid() {
|
||||
User user = userService.createUser("johndoe", "johndoe", "John", "Doe", "john.doe@localhost", "http://placehold.it/50x50", "en-US");
|
||||
|
||||
ZonedDateTime daysAgo = ZonedDateTime.now().minusHours(25);
|
||||
user.setActivated(true);
|
||||
user.setResetDate(daysAgo);
|
||||
user.setResetKey("1234");
|
||||
userRepository.save(user);
|
||||
Optional<User> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey());
|
||||
assertThat(maybeUser.isPresent()).isFalse();
|
||||
userRepository.delete(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertThatUserCanResetPassword() {
|
||||
User user = userService.createUser("johndoe", "johndoe", "John", "Doe", "john.doe@localhost", "http://placehold.it/50x50", "en-US");
|
||||
String oldPassword = user.getPassword();
|
||||
ZonedDateTime daysAgo = ZonedDateTime.now().minusHours(2);
|
||||
String resetKey = RandomUtil.generateResetKey();
|
||||
user.setActivated(true);
|
||||
user.setResetDate(daysAgo);
|
||||
user.setResetKey(resetKey);
|
||||
userRepository.save(user);
|
||||
Optional<User> maybeUser = userService.completePasswordReset("johndoe2", user.getResetKey());
|
||||
assertThat(maybeUser.isPresent()).isTrue();
|
||||
assertThat(maybeUser.get().getResetDate()).isNull();
|
||||
assertThat(maybeUser.get().getResetKey()).isNull();
|
||||
assertThat(maybeUser.get().getPassword()).isNotEqualTo(oldPassword);
|
||||
|
||||
userRepository.delete(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindNotActivatedUsersByCreationDateBefore() {
|
||||
userService.removeNotActivatedUsers();
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(now.minusDays(3));
|
||||
assertThat(users).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assertThatAnonymousUserIsNotGet() {
|
||||
final PageRequest pageable = new PageRequest(0, (int) userRepository.count());
|
||||
final Page<UserDTO> allManagedUsers = userService.getAllManagedUsers(pageable);
|
||||
assertThat(allManagedUsers.getContent().stream()
|
||||
.noneMatch(user -> Constants.ANONYMOUS_USER.equals(user.getLogin())))
|
||||
.isTrue();
|
||||
}
|
||||
}
|
|
@ -86,7 +86,7 @@ public class CommentResourceIntegrationTest {
|
|||
.text(DEFAULT_TEXT)
|
||||
.creationDate(DEFAULT_CREATION_DATE);
|
||||
// Add required entity
|
||||
Post post = PostResourceIntTest.createEntity(em);
|
||||
Post post = PostResourceIntegrationTest.createEntity(em);
|
||||
em.persist(post);
|
||||
em.flush();
|
||||
comment.setPost(post);
|
||||
|
|
|
@ -90,7 +90,7 @@ public class PostResourceIntegrationTest {
|
|||
.content(DEFAULT_CONTENT)
|
||||
.creationDate(DEFAULT_CREATION_DATE);
|
||||
// Add required entity
|
||||
User creator = UserResourceIntTest.createEntity(em);
|
||||
User creator = UserResourceIntegrationTest.createEntity(em);
|
||||
em.persist(creator);
|
||||
em.flush();
|
||||
post.setCreator(creator);
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
### Relevant Articles:
|
||||
================================
|
||||
|
||||
- [Guide to Maven Archetype](http://www.baeldung.com/maven-archetype)
|
20
pom.xml
20
pom.xml
|
@ -36,22 +36,22 @@
|
|||
<module>azure</module>
|
||||
<module>bootique</module>
|
||||
<module>cdi</module>
|
||||
<!--<module>core-java-9</module>-->
|
||||
<!--<module>core-java-9</module>--> <!-- Commented because we have still not upgraded to java 9 -->
|
||||
<module>core-java</module>
|
||||
<module>core-java-collections</module>
|
||||
<module>core-java-io</module>
|
||||
<module>core-java-8</module>
|
||||
<!--<module>core-kotlin</module>-->
|
||||
<module>core-kotlin</module>
|
||||
<module>core-groovy</module>
|
||||
<module>core-java-concurrency</module>
|
||||
<module>couchbase</module>
|
||||
<module>deltaspike</module>
|
||||
<module>dozer</module>
|
||||
<module>ethereum</module>
|
||||
<!--<module>ejb</module>-->
|
||||
<module>ejb</module>
|
||||
<module>feign</module>
|
||||
<module>flips</module>
|
||||
<!--<module>testing-modules/gatling</module> -->
|
||||
<module>testing-modules/gatling</module>
|
||||
<module>geotools</module>
|
||||
<module>testing-modules/groovy-spock</module>
|
||||
<module>google-cloud</module>
|
||||
|
@ -66,14 +66,14 @@
|
|||
<module>spring-static-resources</module>
|
||||
<module>hazelcast</module>
|
||||
<module>hbase</module>
|
||||
<!--<module>hibernate5</module> -->
|
||||
<module>hibernate5</module>
|
||||
<module>httpclient</module>
|
||||
<module>hystrix</module>
|
||||
<!--<module>image-processing</module>-->
|
||||
<module>image-processing</module>
|
||||
<module>immutables</module>
|
||||
<module>influxdb</module>
|
||||
<module>jackson</module>
|
||||
<!--<module>persistence-modules/java-cassandra</module>-->
|
||||
<module>persistence-modules/java-cassandra</module>
|
||||
<module>vavr</module>
|
||||
<module>java-lite</module>
|
||||
<module>java-rmi</module>
|
||||
|
@ -84,7 +84,7 @@
|
|||
<module>javafx</module>
|
||||
<module>jgroups</module>
|
||||
<module>jee-7</module>
|
||||
<!--<module>jhipster/jhipster-monolithic</module>-->
|
||||
<module>jhipster/jhipster-monolithic</module>
|
||||
<module>jjwt</module>
|
||||
<module>jpa-storedprocedure</module>
|
||||
<module>jsf</module>
|
||||
|
@ -177,7 +177,7 @@
|
|||
<module>spring-integration</module>
|
||||
<module>spring-jenkins-pipeline</module>
|
||||
<module>spring-jersey</module>
|
||||
<!--<module>jmeter</module> -->
|
||||
<module>jmeter</module>
|
||||
<module>spring-jms</module>
|
||||
<module>spring-jooq</module>
|
||||
<module>persistence-modules/spring-jpa</module>
|
||||
|
@ -376,7 +376,7 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<version>${maven-pmd-plugin.version}</version>
|
||||
<dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.baeldung.pmd</groupId>
|
||||
<artifactId>custom-pmd</artifactId>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
### Relevant Articles:
|
||||
- [Bootstrap a Simple Application using Spring Boot](http://www.baeldung.com/spring-boot-start)
|
||||
- [Spring Boot Dependency Management with a Custom Parent](http://www.baeldung.com/spring-boot-dependency-management-custom-parent)
|
||||
- [Thin JARs with Spring Boot](http://www.baeldung.com/spring-boot-thin-jar)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Guide to the Favicon in Spring Boot](http://www.baeldung.com/spring-boot-favicon)
|
|
@ -0,0 +1,4 @@
|
|||
### Relevant Articles:
|
||||
================================
|
||||
|
||||
- [Spring Boot Console Application](http://www.baeldung.com/spring-boot-console-app)
|
|
@ -1,3 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [Spring Boot with multiple SQL import files](http://www.baeldung.com/spring-Boot-with-multiple-SQL-import-files)
|
||||
- [Spring Boot with Multiple SQL Import Files](http://www.baeldung.com/spring-boot-sql-import-files)
|
||||
|
|
|
@ -86,11 +86,22 @@
|
|||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tomcat/embed/tomcat-embed-core/8.5.29/tomcat-embed-core-8.5.29.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tomcat/embed/tomcat-embed-el/8.5.29/tomcat-embed-el-8.5.29.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.29/tomcat-embed-websocket-8.5.29.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-test/2.0.1.RELEASE/spring-boot-starter-test-2.0.1.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-test/2.0.1.RELEASE/spring-boot-test-2.0.1.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-test-autoconfigure/2.0.1.RELEASE/spring-boot-test-autoconfigure-2.0.1.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/assertj/assertj-core/3.9.1/assertj-core-3.9.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/mockito/mockito-core/2.15.0/mockito-core-2.15.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/net/bytebuddy/byte-buddy/1.7.11/byte-buddy-1.7.11.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/net/bytebuddy/byte-buddy-agent/1.7.11/byte-buddy-agent-1.7.11.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/objenesis/objenesis/2.6/objenesis-2.6.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/skyscreamer/jsonassert/1.5.0/jsonassert-1.5.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-core/5.0.5.RELEASE/spring-core-5.0.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-jcl/5.0.5.RELEASE/spring-jcl-5.0.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/spring-test/5.0.5.RELEASE/spring-test-5.0.5.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/xmlunit/xmlunit-core/2.5.1/xmlunit-core-2.5.1.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/io/dropwizard/metrics/metrics-core/3.2.6/metrics-core-3.2.6.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/com/h2database/h2/1.4.197/h2-1.4.197.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter/2.0.1.RELEASE/spring-boot-starter-2.0.1.RELEASE.jar" enabled="true" runInBatchMode="false"/>
|
||||
|
@ -145,6 +156,7 @@
|
|||
<factorypathentry kind="VARJAR" id="M2_REPO/com/rometools/rome/1.9.0/rome-1.9.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/com/rometools/rome-utils/1.9.0/rome-utils-1.9.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/jdom/jdom2/2.0.6/jdom2-2.0.6.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/junit/junit/4.12/junit-4.12.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/io/rest-assured/rest-assured/3.1.0/rest-assured-3.1.0.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/codehaus/groovy/groovy/2.4.15/groovy-2.4.15.jar" enabled="true" runInBatchMode="false"/>
|
||||
<factorypathentry kind="VARJAR" id="M2_REPO/org/codehaus/groovy/groovy-xml/2.4.15/groovy-xml-2.4.15.jar" enabled="true" runInBatchMode="false"/>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
- [Iteration in Thymeleaf](http://www.baeldung.com/thymeleaf-iteration)
|
||||
- [Working With Arrays in Thymeleaf](http://www.baeldung.com/thymeleaf-arrays)
|
||||
- [Spring with Thymeleaf Pagination for a List](http://www.baeldung.com/spring-thymeleaf-pagination)
|
||||
- [Working with Select and Option in Thymeleaf](http://www.baeldung.com/thymeleaf-select-option)
|
||||
|
||||
### Build the Project
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
### Relevant Articles:
|
||||
================================
|
||||
|
||||
- [Spring AMQP in Reactive Applications](http://www.baeldung.com/spring-amqp-reactive)
|
|
@ -18,3 +18,4 @@
|
|||
- [Hamcrest File Matchers](http://www.baeldung.com/hamcrest-file-matchers)
|
||||
- [Hamcrest Custom Matchers](http://www.baeldung.com/hamcrest-custom-matchers)
|
||||
- [Hamcrest Common Core Matchers](http://www.baeldung.com/hamcrest-core-matchers)
|
||||
- [Testing Callbacks with Mockito](http://www.baeldung.com/mockito-callbacks)
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.junit.ClassRule;
|
|||
import org.junit.Test;
|
||||
import org.testcontainers.containers.DockerComposeContainer;
|
||||
|
||||
public class DockerComposeContainerUnitTest {
|
||||
public class DockerComposeContainerLiveTest {
|
||||
@ClassRule
|
||||
public static DockerComposeContainer compose =
|
||||
new DockerComposeContainer(
|
|
@ -13,7 +13,7 @@ import org.junit.platform.commons.annotation.Testable;
|
|||
import org.testcontainers.containers.GenericContainer;
|
||||
|
||||
@Testable
|
||||
public class GenericContainerUnitTest {
|
||||
public class GenericContainerLiveTest {
|
||||
@ClassRule
|
||||
public static GenericContainer simpleWebServer =
|
||||
new GenericContainer("alpine:3.2")
|
|
@ -13,7 +13,7 @@ import org.junit.platform.commons.annotation.Testable;
|
|||
import org.testcontainers.containers.PostgreSQLContainer;
|
||||
|
||||
@Testable
|
||||
public class PostgreSqlContainerUnitTest {
|
||||
public class PostgreSqlContainerLiveTest {
|
||||
@Rule
|
||||
public PostgreSQLContainer postgresContainer = new PostgreSQLContainer();
|
||||
|
|
@ -12,7 +12,7 @@ import org.testcontainers.DockerClientFactory;
|
|||
import org.testcontainers.containers.BrowserWebDriverContainer;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
|
||||
public class WebDriverContainerUnitTest {
|
||||
public class WebDriverContainerLiveTest {
|
||||
@Rule
|
||||
public BrowserWebDriverContainer chrome
|
||||
= new BrowserWebDriverContainer()
|
Loading…
Reference in New Issue