-
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.
Add tests for terminal operation optimization #31
- Loading branch information
Showing
12 changed files
with
567 additions
and
39 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
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
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
53 changes: 37 additions & 16 deletions
53
...c/test/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/AnyMatchTest.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 |
---|---|---|
@@ -1,55 +1,76 @@ | ||
package com.speedment.jpastreamer.termopoptimizer.standard.internal; | ||
|
||
import com.speedment.jpastreamer.field.ComparableField; | ||
import com.speedment.jpastreamer.field.ShortField; | ||
import com.speedment.jpastreamer.field.predicate.SpeedmentPredicate; | ||
import com.speedment.jpastreamer.pipeline.Pipeline; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
|
||
final class AnyMatchTest extends StandardTerminalOperationOptimizerTest<String> { | ||
final class AnyMatchTest extends StandardTerminalOperationOptimizerTest<Film> { | ||
|
||
@Override | ||
Class<String> getEntityClass() { | ||
return String.class; | ||
Class<Film> getEntityClass() { | ||
return Film.class; | ||
} | ||
|
||
@Override | ||
protected Stream<PipelineTestCase<String>> pipelines() { | ||
protected Stream<PipelineTestCase<Film>> pipelines() { | ||
return Stream.of( | ||
noAnyMatch(), | ||
anyMatch() | ||
anyMatchLambda(), | ||
anyMatchSpeedmentPredicate() | ||
); | ||
} | ||
|
||
private PipelineTestCase<String> noAnyMatch() { | ||
final Pipeline<String> noAnyMatch = createPipeline( | ||
private PipelineTestCase<Film> noAnyMatch() { | ||
final Pipeline<Film> noAnyMatch = createPipeline( | ||
tof.createAllMatch(s -> s.equals("test")), | ||
iof.createLimit(1) | ||
iof.createLimit(100) | ||
); | ||
|
||
final Pipeline<String> noAnyMatchExpected = createPipeline( | ||
final Pipeline<Film> noAnyMatchExpected = createPipeline( | ||
tof.createAllMatch(s -> s.equals("test")), | ||
iof.createLimit(1) | ||
iof.createLimit(100) | ||
); | ||
|
||
return new PipelineTestCase<>("No Any Match", noAnyMatch, noAnyMatchExpected); | ||
} | ||
|
||
private PipelineTestCase<String> anyMatch() { | ||
final Predicate<String> p = s -> (s.equals("test")); | ||
private PipelineTestCase<Film> anyMatchLambda() { | ||
final Predicate<Film> p = f -> f.getTitle().startsWith("A"); | ||
|
||
final Pipeline<String> anyMatch = createPipeline( | ||
final Pipeline<Film> anyMatch = createPipeline( | ||
tof.createAnyMatch(p), | ||
iof.createLimit(100) | ||
); | ||
|
||
final Pipeline<String> anyMatchExpected = createPipeline( | ||
final Pipeline<Film> anyMatchExpected = createPipeline( | ||
tof.createAnyMatch(s -> true), | ||
iof.createLimit(100) | ||
); | ||
|
||
return new PipelineTestCase<>("Any Match Lambda", anyMatch, anyMatchExpected); | ||
} | ||
|
||
private PipelineTestCase<Film> anyMatchSpeedmentPredicate() { | ||
SpeedmentPredicate<Film> predicate = Film$.title.startsWith("A"); | ||
|
||
final Pipeline<Film> anyMatch = createPipeline( | ||
tof.createAnyMatch(predicate), | ||
iof.createLimit(100) | ||
); | ||
|
||
final Pipeline<Film> anyMatchExpected = createPipeline( | ||
tof.createAnyMatch(s -> true), | ||
iof.createLimit(100), | ||
iof.createLimit(1), | ||
iof.createFilter(p) | ||
iof.createFilter(predicate) | ||
); | ||
|
||
return new PipelineTestCase<>("Any Match", anyMatch, anyMatchExpected); | ||
return new PipelineTestCase<>("Any Match Speedment Predicate", anyMatch, anyMatchExpected); | ||
} | ||
|
||
} |
111 changes: 111 additions & 0 deletions
111
...dard/src/test/java/com/speedment/jpastreamer/termopoptimizer/standard/internal/Film$.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,111 @@ | ||
package com.speedment.jpastreamer.termopoptimizer.standard.internal; | ||
|
||
import com.speedment.jpastreamer.field.ComparableField; | ||
import com.speedment.jpastreamer.field.ReferenceField; | ||
import com.speedment.jpastreamer.field.ShortField; | ||
import com.speedment.jpastreamer.field.StringField; | ||
|
||
import java.math.BigDecimal; | ||
import java.sql.Timestamp; | ||
|
||
/** | ||
* The generated base for entity {@link Film} representing entities of the | ||
* {@code film}-table in the database. | ||
* <p> This file has been automatically generated by JPAStreamer. | ||
* | ||
* @author JPAStreamer | ||
*/ | ||
public final class Film$ { | ||
|
||
/** | ||
* This Field corresponds to the {@link Film} field "length". | ||
*/ | ||
public static final ComparableField<Film, Short> length = ComparableField.create( | ||
Film.class, | ||
"length", | ||
Film::getLength, | ||
false | ||
); | ||
/** | ||
* This Field corresponds to the {@link Film} field "filmId". | ||
*/ | ||
public static final ShortField<Film> filmId = ShortField.create( | ||
Film.class, | ||
"filmId", | ||
Film::getFilmId, | ||
false | ||
); | ||
/** | ||
* This Field corresponds to the {@link Film} field "replacementCost". | ||
*/ | ||
public static final ComparableField<Film, BigDecimal> replacementCost = ComparableField.create( | ||
Film.class, | ||
"replacementCost", | ||
Film::getReplacementCost, | ||
false | ||
); | ||
|
||
/** | ||
* This Field corresponds to the {@link Film} field "rating". | ||
*/ | ||
public static final StringField<Film> rating = StringField.create( | ||
Film.class, | ||
"rating", | ||
Film::getRating, | ||
false | ||
); | ||
/** | ||
* This Field corresponds to the {@link Film} field "title". | ||
*/ | ||
public static final StringField<Film> title = StringField.create( | ||
Film.class, | ||
"title", | ||
Film::getTitle, | ||
false | ||
); | ||
/** | ||
* This Field corresponds to the {@link Film} field "languageId". | ||
*/ | ||
public static final ShortField<Film> languageId = ShortField.create( | ||
Film.class, | ||
"languageId", | ||
Film::getLanguageId, | ||
false | ||
); | ||
/** | ||
* This Field corresponds to the {@link Film} field "description". | ||
*/ | ||
public static final StringField<Film> description = StringField.create( | ||
Film.class, | ||
"description", | ||
Film::getDescription, | ||
false | ||
); | ||
/** | ||
* This Field corresponds to the {@link Film} field "rentalRate". | ||
*/ | ||
public static final ComparableField<Film, BigDecimal> rentalRate = ComparableField.create( | ||
Film.class, | ||
"rentalRate", | ||
Film::getRentalRate, | ||
false | ||
); | ||
/** | ||
* This Field corresponds to the {@link Film} field "rentalDuration". | ||
*/ | ||
public static final ShortField<Film> rentalDuration = ShortField.create( | ||
Film.class, | ||
"rentalDuration", | ||
Film::getRentalDuration, | ||
false | ||
); | ||
/** | ||
* This Field corresponds to the {@link Film} field "lastUpdate". | ||
*/ | ||
public static final ComparableField<Film, Timestamp> lastUpdate = ComparableField.create( | ||
Film.class, | ||
"lastUpdate", | ||
Film::getLastUpdate, | ||
false | ||
); | ||
} |
Oops, something went wrong.