Made the random books to be more appropriate.

This commit is contained in:
Iiro Krankka
2017-01-09 12:12:20 +02:00
parent f558906eb0
commit 0b9daddf3a
2 changed files with 21 additions and 22 deletions

View File

@@ -8,16 +8,15 @@ import java.util.List;
public class RandomBookGenerator { public class RandomBookGenerator {
private static final String[] SUBJECTS = { private static final String[] SUBJECTS = {
"Chicken", "Pig", "Hippo", "Dinosaur", "Giraffe", "Orangutan", "Chicken", "Pig", "Hippo", "Dinosaur", "Giraffe", "Orangutan",
"Bat", "Lion", "Daddy", "Grandpa", "Donald Trump", "Coffee", "Bat", "Lion", "Daddy", "Grandpa", "Coffee", "Dog", "Rat",
"Dog", "Rat", "Pokemon", "Cat", "Senile", "Pensioner", "Pokemon", "Cat", "Pensioner", "Project Manager", "Salesperson"
"Project manager", "Salesperson"
}; };
private static final String[] SECOND_WORDS = { private static final String[] SECOND_WORDS = {
"strip club", "that knew too little", "Strategy", "parking space", "That Knew Too Little", "Strategy", "Parking Lot",
"Office", "Banana", "Toilet", "Poop", "Fart", "Rain", "Job", "Office", "Banana", "Toilet", "Rain", "Job", "Thing",
"Thing", "Radio", "Zoo", "Office", "House", "Village", "Radio", "Zoo", "Office", "House", "Village", "Swimming Pool",
"swimming pool", "Computer" "Computer"
}; };
private static final String[] FIRST_NAMES = { private static final String[] FIRST_NAMES = {
@@ -26,7 +25,7 @@ public class RandomBookGenerator {
}; };
private static final String[] LAST_NAMES = { private static final String[] LAST_NAMES = {
"Doe", "Trump", "Bond", "Jackson", "Jordan", "Young", "Page", "Doe", "Smith", "Bond", "Jackson", "Jordan", "Young", "Page",
"Johnson", "Springsteen", "Kauffman", "Schmidt", "Jokinen" "Johnson", "Springsteen", "Kauffman", "Schmidt", "Jokinen"
}; };
@@ -72,7 +71,7 @@ public class RandomBookGenerator {
private static Date randomDate() { private static Date randomDate() {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, RandomUtils.randBetween(1995, 2016)); calendar.set(Calendar.YEAR, RandomUtils.randBetween(1995, 2017));
calendar.set(Calendar.MONTH, RandomUtils.randBetween(0, 11)); calendar.set(Calendar.MONTH, RandomUtils.randBetween(0, 11));
calendar.set(Calendar.DAY_OF_MONTH, RandomUtils.randBetween(1, 25)); calendar.set(Calendar.DAY_OF_MONTH, RandomUtils.randBetween(1, 25));

View File

@@ -2,34 +2,34 @@ Feature: Book Search
A customer must be able to search books by year, author or title A customer must be able to search books by year, author or title
Background: Background:
Given the library has a book with title "How to be awesome", written by "Iiro Krankka", published in 16 May 2016 Given the library has a book with title "How to be awesome", written by "Jane Smith", published in 16 May 2016
And a book with title "My life as an awesome guy", written by "Iiro Krankka", published in 27 July 2016 And a book with title "My life as an awesome girl", written by "Jane Smith", published in 27 July 2016
And a book with title "I think my teacher is cool", written by "John Doe", published in 01 January 2010 And a book with title "I think my teacher is cool", written by "John Doe", published in 01 January 2010
Scenario: List all books Scenario: List all books
When the customer wants to know all books in the library When the customer wants to know all books in the library
Then 3 books should be found Then 3 books should be found
And Book 1 should have the title "How to be awesome" And Book 1 should have the title "How to be awesome"
And Book 2 should have the title "My life as an awesome guy" And Book 2 should have the title "My life as an awesome girl"
And Book 3 should have the title "I think my teacher is cool" And Book 3 should have the title "I think my teacher is cool"
Scenario: Search books by year Scenario: Search books by year
When the customer searches for books published in year 2016 When the customer searches for books published in year 2016
Then 2 books should be found Then 2 books should be found
And Book 1 should have the title "How to be awesome" And Book 1 should have the title "How to be awesome"
And Book 2 should have the title "My life as an awesome guy" And Book 2 should have the title "My life as an awesome girl"
Scenario Outline: Search books by author Scenario Outline: Search books by author
When the customer searches for books by author <Author Search> When the customer searches for books by author <Author Search>
Then 2 books should be found Then 2 books should be found
And Book 1 should have the title "How to be awesome" And Book 1 should have the title "How to be awesome"
And Book 2 should have the title "My life as an awesome guy" And Book 2 should have the title "My life as an awesome girl"
Examples: Examples:
| Author Search | | Author Search |
| "Iiro" | | "Jane" |
| "Krankka" | | "Smith" |
| "Iiro Krankka" | | "Jane Smith" |
Scenario Outline: Search books by title Scenario Outline: Search books by title
When the customer searches for books with title <Title Search> When the customer searches for books with title <Title Search>
@@ -37,7 +37,7 @@ Feature: Book Search
And Books should be <Found Books> And Books should be <Found Books>
Examples: Examples:
| Title Search | Number of Results | Found Books | | Title Search | Number of Results | Found Books |
| "Awesome" | 2 | "How to be awesome" and "My life as an awesome guy" | | "Awesome" | 2 | "How to be awesome" and "My life as an awesome girl" |
| "cool" | 1 | "I think my teacher is cool" | | "cool" | 1 | "I think my teacher is cool" |
| "How to be" | 1 | "How to be awesome" | | "How to be" | 1 | "How to be awesome" |