Skip to content

Instantly share code, notes, and snippets.

@joelso
Last active October 9, 2015 09:27
Show Gist options
  • Save joelso/3478255 to your computer and use it in GitHub Desktop.
Save joelso/3478255 to your computer and use it in GitHub Desktop.
Simple test util for producing mock data
package util;
import java.util.*;
public class MockData {
private static Random rand = new Random();
private static final List<String> firstNames = Arrays.asList("Kevin", "Dave", "David", "Alan", "Derek", "Paul", "Nick", "Mark", "Sam", "Dan", "Robert", "Gavin", "Terry", "Barry", "Rahul", "Steve", "John", "Naeem", "Harris", "Natalie","Sarah","Deidre","Gladys","Penny","Rebecca","Grace","Kelly","Sally","Maggie","Kate","Kathryn");
private static final List<String> lastNames = Arrays.asList("Jones","Smith","Baker","Havilland","Partridge","Rogers","Magnets","Trains","Rafferty","O'Toole","Hattes","Borde","Thorpe","Gravis","Twerp","Dingle","Schist","Granite","Evans","Gravel","Doon","Yaris","Corby","Toast","Greens","Havers", "Söderström");
private static final List<String> countries = Arrays.asList("England", "Norway", "Sweden", "Denmark", "Finland", "Germany", "Poland", "Russia", "Ukraine", "Belarus","Spain","France","Portugal","Greece","Holland","Belgium");
private static final List<String> cities = Arrays.asList("London", "Berlin", "Madrid", "Rome","Paris","Hamburg","Budapest","Vienna","Warsaw","Bucharest","Barcelona","Munich","Milan","Pargue","Sofia","Burssels","Birmingham","Cologne","Naples","Turine","Stockholm","Marseille","Valencia","Amsterdam","Kraków","Leeds","Łódź","Athens","Riga","Sevilla", "Franfurt");
private static final List<String> streets = Arrays.asList("Queens Street", "Broadway", "Kings Cross", "Baker Street", "Berea Street", "Abbey Road", "Boston Post Road", "Calle Estafeta", "Voie Sacrée");
private static final List<String> companies = Arrays.asList("Google", "Yahoo", "Apple", "Microsoft", "Ford Automobiles", "Morgan Stanley", "General Electric", "Samsung", "Ericsson", "Frost Stockholm AB");
private static final List<String> adjectives = Arrays.asList("Red", "Green", "Blue", "Purple", "White", "Black", "Smooth", "Fast", "Strong", "Swift");
private static final List<String> nouns = Arrays.asList("Warrior", "Elk", "Tiger", "Harpoon", "Spider", "Bull", "Captain", "Shark", "Agent", "Moon");
public static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
private static Calendar cal = Calendar.getInstance();
public static String fullName() {
return firstName() + " " + lastName();
}
public static String firstName() {
return randomEntry(firstNames);
}
public static String lastName() {
return randomEntry(lastNames);
}
public static String street() {
return randomEntry(streets);
}
public static String city() {
return randomEntry(cities);
}
public static String country() {
return randomEntry(countries);
}
public static String company() {
return randomEntry(companies);
}
public static String mumboJumbo() {
return randomEntry(adjectives) + " " + randomEntry(nouns);
}
public static String email() {
return firstName().toLowerCase() + "@" + mumboJumbo().replaceAll(" ", "").toLowerCase() + ".com";
}
public static String phone(boolean withCountryCode) {
String countryCode = withCountryCode ? "+" + (rand.nextInt(100)+1) + " " : "";
return countryCode + Math.abs(UUID.randomUUID().hashCode());
}
public static int year() {
return cal.get(Calendar.YEAR) - rand.nextInt(20);
}
private static String randomEntry(List<String> list) {
return list.get( rand.nextInt(list.size()) );
}
public static String website() {
return "http://" + (rand.nextBoolean() ? "www." : "") + mumboJumbo().replaceAll(" ", "").toLowerCase() + ".com";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment