aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2016-08-21 22:31:46 +0200
committerEduardo Pedroni <e.pedroni91@gmail.com>2016-08-21 22:31:46 +0200
commit6db49cf2f92e854ce184c18e45fc31154176bc22 (patch)
tree6e91d871f433f9a291c90dff1d60f58d4af6c8a7
parentb626d7520f9bf51c4d2773475e3e7614048bff47 (diff)
Added standalone task to build.gradle, finished filtering testsHEADmaster
-rw-r--r--.classpath20
-rw-r--r--.project2
-rw-r--r--README.md2
-rw-r--r--build.gradle44
-rw-r--r--settings.gradle2
-rw-r--r--test/eu/equalparts/cardbase/filtering/CardFilteringTest.java198
6 files changed, 244 insertions, 24 deletions
diff --git a/.classpath b/.classpath
index aeb502e..e8c5888 100644
--- a/.classpath
+++ b/.classpath
@@ -1,9 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="res"/>
- <classpathentry kind="src" path="test"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
+ <classpathentry kind="src" path="res">
+ <attributes>
+ <attribute name="FROM_GRADLE_MODEL" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="src">
+ <attributes>
+ <attribute name="FROM_GRADLE_MODEL" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="test">
+ <attributes>
+ <attribute name="FROM_GRADLE_MODEL" value="true"/>
+ </attributes>
+ </classpathentry>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/.project b/.project
index 24b1e12..4e41596 100644
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>NewCardbase</name>
+ <name>Cardbase</name>
<comment>Project Cardbase created by Buildship.</comment>
<projects>
</projects>
diff --git a/README.md b/README.md
index 044e754..b613cfb 100644
--- a/README.md
+++ b/README.md
@@ -61,4 +61,4 @@ Use the "version" command to see the executable's version.
## Building
-Cardbase now uses [gradle](https://gradle.org/) for building and dependency management. As recommended, use the provided `gradlew` script for best results.
+Cardbase now uses [gradle](https://gradle.org/) for building and dependency management. As recommended, use the provided `gradlew` script for best results. In addition to the standard Java tasks, `./gradlew standalone` can be used to generate a "fat jar" with all necessary dependencies bundled.
diff --git a/build.gradle b/build.gradle
index acc2489..ebe537e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,6 @@
/*
- * This build file was auto generated by running the Gradle 'init' task
- * by 'eddy' at '20/08/16 10:27' with Gradle 3.0
+ * This build file was auto generated by running the Gradle "init" task
+ * by "eddy" at "20/08/16 10:27" with Gradle 3.0
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
@@ -8,45 +8,61 @@
*/
// Apply the java plugin to add support for Java
-apply plugin: 'java'
+apply plugin: "java"
+
+// variables
+version = "1.0"
// In this section you declare where to find the dependencies of your project
repositories {
- // Use 'jcenter' for resolving your dependencies.
+ // Use "jcenter" for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
+// configure sourceSets for the alternative project directory structure
sourceSets {
main {
java {
- srcDirs = ['src']
+ srcDirs = ["src"]
}
resources {
- srcDirs = ['res']
+ srcDirs = ["res"]
}
}
test {
java {
- srcDirs = ['test']
+ srcDirs = ["test"]
}
resources {
- srcDirs = ['test']
+ srcDirs = ["test"]
}
}
}
+//create a single jar with all dependencies
+task standalone(type: Jar) {
+ manifest {
+ attributes("Implementation-Title": "Cardbase",
+ "Implementation-Version": version,
+ "Main-Class": "eu.equalparts.cardbase.cli.CardbaseCLI")
+ }
+ baseName = project.name + "-all"
+ from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
+ with jar
+}
+
// In this section you declare the dependencies for your production and test code
dependencies {
// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
- // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
- // 'test.useTestNG()' to your build script.
- testCompile 'junit:junit:4.12'
+ // testCompile dependency to testCompile "org.testng:testng:6.8.1" and add
+ // "test.useTestNG()" to your build script.
+ testCompile "junit:junit:4.12"
// Need jackson for the JSON
- compile 'com.fasterxml.jackson.core:jackson-core:2.8.1'
- compile 'com.fasterxml.jackson.core:jackson-annotations:2.8.1'
- compile 'com.fasterxml.jackson.core:jackson-databind:2.8.1'
+ compile "com.fasterxml.jackson.core:jackson-core:2.8.1"
+ compile "com.fasterxml.jackson.core:jackson-annotations:2.8.1"
+ compile "com.fasterxml.jackson.core:jackson-databind:2.8.1"
}
diff --git a/settings.gradle b/settings.gradle
index 70d7a3d..d9116de 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -16,4 +16,4 @@ include 'api'
include 'services:webservice'
*/
-rootProject.name = 'NewCardbase'
+rootProject.name = 'Cardbase'
diff --git a/test/eu/equalparts/cardbase/filtering/CardFilteringTest.java b/test/eu/equalparts/cardbase/filtering/CardFilteringTest.java
index d4839a6..77377e6 100644
--- a/test/eu/equalparts/cardbase/filtering/CardFilteringTest.java
+++ b/test/eu/equalparts/cardbase/filtering/CardFilteringTest.java
@@ -856,18 +856,210 @@ public class CardFilteringTest {
}
@Test
- public void filterByMultiverseID() throws Exception {
+ public void filterByMultiverseIDEquals() throws Exception {
+ Filter filter = new Filter(FilterType.EQUALS, "multiverseid", "74489");
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 1, testCards.size());
+ assertEquals("Callow Jushi", testCards.get(0).name.get());
+ }
+
+ @Test
+ public void filterByMultiverseIDContains() throws Exception {
+ Filter filter = new Filter(FilterType.CONTAINS, "multiverseid", "38");
+
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 3, testCards.size());
+ int i = 0;
+ String[] names = {
+ "Nightmare",
+ "Shivan Dragon",
+ "Sorin Markov",
+ };
+ for (Card card : testCards) {
+ assertTrue(card.name.get() + " should have been " + names[i] + ", i = " + i, card.name.get().equals(names[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void filterByMultiverseIDRegex() throws Exception {
+ Filter filter = new Filter(FilterType.REGEX, "multiverseid", ".{5}");
+
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 2, testCards.size());
+ int i = 0;
+ String[] names = {
+ "Callow Jushi",
+ "Disrupting Shoal",
+ };
+ for (Card card : testCards) {
+ assertTrue(card.name.get() + " should have been " + names[i] + ", i = " + i, card.name.get().equals(names[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void filterByMultiverseIDGreaterThan() throws Exception {
+ Filter filter = new Filter(FilterType.GREATER_THAN, "multiverseid", "300000");
+
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 4, testCards.size());
+ int i = 0;
+ String[] names = {
+ "Coerced Confession",
+ "Nightmare",
+ "Shivan Dragon",
+ "Ugin's Construct",
+ };
+ for (Card card : testCards) {
+ assertTrue(card.name.get() + " should have been " + names[i] + ", i = " + i, card.name.get().equals(names[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void filterByMultiverseIDSmallerThan() throws Exception {
+ Filter filter = new Filter(FilterType.SMALLER_THAN, "multiverseid", "10000");
+
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 0, testCards.size());
+ }
+
+ @Test
+ public void filterByImageNameEquals() throws Exception {
+ Filter filter = new Filter(FilterType.EQUALS, "imageName", "nightmare");
+
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 1, testCards.size());
+ assertEquals("Nightmare", testCards.get(0).name.get());
+ }
+
+ @Test
+ public void filterByImageNameContains() throws Exception {
+ Filter filter = new Filter(FilterType.CONTAINS, "imageName", "co");
+
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 2, testCards.size());
+ int i = 0;
+ String[] names = {
+ "Coerced Confession",
+ "Ugin's Construct",
+ };
+ for (Card card : testCards) {
+ assertTrue(card.name.get() + " should have been " + names[i] + ", i = " + i, card.name.get().equals(names[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void filterByImageNameRegex() throws Exception {
+ Filter filter = new Filter(FilterType.REGEX, "imageName", ".+? .+?");
+
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 7, testCards.size());
+ int i = 0;
+ String[] names = {
+ "Callow Jushi",
+ "Coerced Confession",
+ "Khalni Hydra",
+ "Shivan Dragon",
+ "Disrupting Shoal",
+ "Sorin Markov",
+ "Ugin's Construct",
+ };
+ for (Card card : testCards) {
+ assertTrue(card.name.get() + " should have been " + names[i] + ", i = " + i, card.name.get().equals(names[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void filterByImageNameGreaterThan() throws Exception {
+ Filter filter = new Filter(FilterType.GREATER_THAN, "imageName", "10");
+
+ exception.expect(IllegalArgumentException.class);
+ CardFiltering.filterByField(testCards, filter);
+ }
+
+ @Test
+ public void filterByImageNameSmallerThan() throws Exception {
+ Filter filter = new Filter(FilterType.SMALLER_THAN, "imageName", "10");
+
+ exception.expect(IllegalArgumentException.class);
+ CardFiltering.filterByField(testCards, filter);
+ }
+
+ @Test
+ public void filterBySetCodeEquals() throws Exception {
+ Filter filter = new Filter(FilterType.EQUALS, "setCode", "GTC");
+
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 1, testCards.size());
+ assertEquals("Coerced Confession", testCards.get(0).name.get());
}
@Test
- public void filterByImageName() throws Exception {
+ public void filterBySetCodeContains() throws Exception {
+ Filter filter = new Filter(FilterType.CONTAINS, "setCode", "o");
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 3, testCards.size());
+ int i = 0;
+ String[] names = {
+ "Callow Jushi",
+ "Khalni Hydra",
+ "Disrupting Shoal",
+ };
+ for (Card card : testCards) {
+ assertTrue(card.name.get() + " should have been " + names[i] + ", i = " + i, card.name.get().equals(names[i]));
+ i++;
+ }
}
@Test
- public void filterBySetCode() throws Exception {
+ public void filterBySetCodeRegex() throws Exception {
+ Filter filter = new Filter(FilterType.REGEX, "setCode", "M[0-9]{2}");
+ CardFiltering.filterByField(testCards, filter);
+
+ assertEquals("Wrong list size.", 3, testCards.size());
+ int i = 0;
+ String[] names = {
+ "Nightmare",
+ "Shivan Dragon",
+ "Sorin Markov",
+ };
+ for (Card card : testCards) {
+ assertTrue(card.name.get() + " should have been " + names[i] + ", i = " + i, card.name.get().equals(names[i]));
+ i++;
+ }
+ }
+
+ @Test
+ public void filterBySetCodeGreaterThan() throws Exception {
+ Filter filter = new Filter(FilterType.GREATER_THAN, "setCode", "10");
+
+ exception.expect(IllegalArgumentException.class);
+ CardFiltering.filterByField(testCards, filter);
+ }
+
+ @Test
+ public void filterBySetCodeSmallerThan() throws Exception {
+ Filter filter = new Filter(FilterType.SMALLER_THAN, "setCode", "10");
+
+ exception.expect(IllegalArgumentException.class);
+ CardFiltering.filterByField(testCards, filter);
}
/*