-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
681 changed files
with
4,037 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,9 @@ jobs: | |
steps: | ||
- uses: actions/[email protected] | ||
- name: Set up Java | ||
uses: actions/setup-java@v1 | ||
uses: actions/setup-java@v3.5.1 | ||
with: | ||
distribution: 'zulu' | ||
java-version: ${{ matrix.java }} | ||
- name: Build with Maven | ||
run: mvn -B package --file pom.xml -Prelease |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ | |
|
||
/docs/package-lock.json | ||
.project | ||
/javadoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
= Integration Test | ||
Julia Gustafsson | ||
:toc: macro | ||
|
||
The tests assume that you are running the Sakila database as a Docker instance on port 3306. See simple installation instructions below. | ||
|
||
== Sakila Database | ||
The tests makes use of the link:https://dev.mysql.com/doc/sakila/en/[MySQL Sakila database]. It can either be downloaded from Oracle as described link:https://dev.mysql.com/doc/sakila/en/sakila-installation.html[here] or used directly via a link:https://hub.docker.com/r/restsql/mysql-sakila/[Sakila Docker instance] by issuing the following commands: | ||
|
||
[shell script] | ||
---- | ||
$ docker pull restsql/mysql-sakila | ||
---- | ||
|
||
[shell script] | ||
---- | ||
$ docker run -d --publish 3306:3306 --name mysqld restsql/mysql-sakila | ||
---- | ||
|
||
NOTE: This Docker image does not support ARM64 architecture, thus if you are running on e.g. an M1 Mac, you need to emulate an Intel image by adding the flag `--platform linux/amd64` after `docker run` in the above command. This may not always work ideally, learn more about why at the link:https://docs.docker.com/desktop/mac/apple-silicon/#known-issues[Docker webpage]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<!-- | ||
JPAstreamer - Express JPA queries with Java Streams | ||
Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. | ||
License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
See the GNU Lesser General Public License for more details. | ||
See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE | ||
--> | ||
<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"> | ||
<parent> | ||
<artifactId>jpastreamer-parent</artifactId> | ||
<groupId>com.speedment.jpastreamer</groupId> | ||
<version>3.0.3-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>integration-tests</artifactId> | ||
|
||
<name>Maven</name> | ||
<url>http://maven.apache.org/</url> | ||
<inceptionYear>2001</inceptionYear> | ||
|
||
<distributionManagement> | ||
<site> | ||
<id>website</id> | ||
<url>scp://webhost.company.com/www/website</url> | ||
</site> | ||
</distributionManagement> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
<version>6.0.2.Final</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-validator</artifactId> | ||
<version>6.0.13.Final</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hibernate.javax.persistence</groupId> | ||
<artifactId>hibernate-jpa-2.1-api</artifactId> | ||
<version>1.0.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>net.bytebuddy</groupId> | ||
<artifactId>byte-buddy</artifactId> | ||
<version>1.12.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>8.0.30</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.speedment.jpastreamer</groupId> | ||
<artifactId>jpastreamer-core</artifactId> | ||
<version>3.0.3-SNAPSHOT</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-site-plugin</artifactId> | ||
<configuration> | ||
<locales>en,fr</locales> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* JPAstreamer - Express JPA queries with Java Streams | ||
* Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE | ||
*/ | ||
public class Hello { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("A Module Full of Integration Tests!"); | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/CountTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* JPAstreamer - Express JPA queries with Java Streams | ||
* Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE | ||
*/ | ||
package com.speedment.jpastreamer.integration.test; | ||
|
||
import com.speedment.jpastreamer.application.JPAStreamer; | ||
import com.speedment.jpastreamer.application.StreamSupplier; | ||
import com.speedment.jpastreamer.integration.test.model.Film; | ||
import com.speedment.jpastreamer.integration.test.model.Film$; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class CountTest extends JPAStreamerTest { | ||
|
||
@Test | ||
void countTest() { | ||
|
||
final List<Film> collect = jpaStreamer.stream(Film.class).collect(Collectors.toList()); | ||
|
||
final long expected = collect.stream() | ||
.filter(f -> f.getTitle().startsWith("A")) | ||
.count(); | ||
|
||
final long actual = jpaStreamer.stream(Film.class) | ||
.filter(Film$.title.startsWith("A")) | ||
.count(); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
void optimizedCountTest() { | ||
|
||
try (final StreamSupplier<Film> supplier = jpaStreamer.createStreamSupplier(Film.class)) { | ||
|
||
final long actual = supplier.stream() | ||
.filter(Film$.title.startsWith("A")) | ||
.sorted(Film$.filmId) // optimized away | ||
.map(Film$.title) // optimized away | ||
.count(); | ||
|
||
final long expected = supplier.stream() | ||
.filter(f -> f.getTitle().startsWith("A")) | ||
.count(); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...ation-tests/src/test/java/com/speedment/jpastreamer/integration/test/JPAStreamerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* JPAstreamer - Express JPA queries with Java Streams | ||
* Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE | ||
*/ | ||
package com.speedment.jpastreamer.integration.test; | ||
|
||
import com.speedment.jpastreamer.application.JPAStreamer; | ||
|
||
public class JPAStreamerTest { | ||
|
||
final static protected JPAStreamer jpaStreamer = JPAStreamer.of("sakila"); | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...ration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ManyToManyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* JPAstreamer - Express JPA queries with Java Streams | ||
* Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE | ||
*/ | ||
package com.speedment.jpastreamer.integration.test; | ||
|
||
import com.speedment.jpastreamer.integration.test.model.Actor; | ||
import com.speedment.jpastreamer.integration.test.model.Actor$; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static com.speedment.jpastreamer.streamconfiguration.StreamConfiguration.of; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ManyToManyTest extends JPAStreamerTest { | ||
|
||
@Test | ||
void manyToManyTest() { | ||
List<Actor> expected = jpaStreamer.stream(of(Actor.class).joining(Actor$.films)).collect(Collectors.toList()); | ||
|
||
expected = expected.stream() | ||
.filter(a -> a.getFirstName().startsWith("A")) | ||
.sorted(Comparator.comparing(Actor::getLastName)) | ||
.collect(Collectors.toList()); | ||
|
||
List<Actor> actual = jpaStreamer.stream(of(Actor.class).joining(Actor$.films)) | ||
.filter(Actor$.firstName.startsWith("A")) | ||
.sorted(Actor$.lastName) | ||
.collect(Collectors.toList()); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...gration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ManyToOneTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* JPAstreamer - Express JPA queries with Java Streams | ||
* Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE | ||
*/ | ||
package com.speedment.jpastreamer.integration.test; | ||
|
||
import com.speedment.jpastreamer.integration.test.model.Film; | ||
import com.speedment.jpastreamer.integration.test.model.Film$; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import static com.speedment.jpastreamer.streamconfiguration.StreamConfiguration.of; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ManyToOneTest extends JPAStreamerTest { | ||
|
||
@Test | ||
void manyToOneTest() { | ||
List<Film> expected = jpaStreamer.stream(of(Film.class).joining(Film$.language)).collect(Collectors.toList()); | ||
|
||
expected = expected.stream() | ||
.filter(f -> f.getRating().equals("PG-13")) | ||
.sorted(Comparator.comparing(Film::getTitle)) | ||
.collect(Collectors.toList()); | ||
|
||
List<Film> actual = jpaStreamer.stream(of(Film.class).joining(Film$.language)) | ||
.filter(Film$.rating.equal("PG-13")) | ||
.sorted(Film$.title) | ||
.collect(Collectors.toList()); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
} |
Oops, something went wrong.