Skip to content

Commit

Permalink
Resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
julgus committed Jul 10, 2023
2 parents 245e4b0 + d1d3dbb commit 7de02a5
Show file tree
Hide file tree
Showing 681 changed files with 4,037 additions and 394 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@

/docs/package-lock.json
.project
/javadoc
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

name: jpa-streamer
title: JPAStreamer Docs
version: 3.0.2
version: 3.0.3-SNAPSHOT
start_page: introduction:introduction.adoc
nav:
- modules/ROOT/nav.adoc
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.0.0",
"description": "Documentation for JPAStreamer built with Antora",
"scripts": {
"build-local": "antora site-local.yml",
"build": "antora site.yml"
"build-local": "antora --fetch site-local.yml",
"build": "antora --fetch site.yml"
},
"author": "JPAStreamer",
"license": "UNLICENSED",
Expand Down
20 changes: 20 additions & 0 deletions integration-tests/README.adoc
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].
97 changes: 97 additions & 0 deletions integration-tests/pom.xml
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>
19 changes: 19 additions & 0 deletions integration-tests/src/main/java/Hello.java
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!");
}

}
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);
}

}

}
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");

}
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);
}

}
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);
}

}
Loading

0 comments on commit 7de02a5

Please sign in to comment.