本文整理汇总了Java中org.fluttercode.datafactory.impl.DataFactory类的典型用法代码示例。如果您正苦于以下问题:Java DataFactory类的具体用法?Java DataFactory怎么用?Java DataFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataFactory类属于org.fluttercode.datafactory.impl包,在下文中一共展示了DataFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareData
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
/**
* Method to generate mock data for insertion
* Uses third party library https://github.com/andygibson/datafactory
*/
private void prepareData() {
int num = numRecords;
records = new ArrayList<DbTestRecordModel>(num);
while(num-- > 0) {
DbTestRecordModel record = new DbTestRecordModel();
DataFactory person = new DataFactory();
record.setName(person.getName());
record.setAge(21);
record.setAddress(person.getAddress());
records.add(record);
}
}
示例2: testBulkCreate
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Test
@Ignore
public void testBulkCreate() {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
InputStream is = classloader.getResourceAsStream("articleId.csv");
java.util.Scanner s = new java.util.Scanner(is).useDelimiter(",");
DataFactory df = new DataFactory();
LoremIpsum loremIpsum = new LoremIpsum();
while(s.hasNext()) {
String articleId = s.next().trim();
Random randomGenerator = new Random();
Integer amount = randomGenerator.nextInt(50);
List<Comment> comments = new ArrayList<>();
for(int i=0; i<amount;i++) {
comments.add(new Comment(null,articleId,df.getName(),loremIpsum.getParagraphs(randomGenerator.nextInt(5))));
}
repo.bulkCreateComments(comments);
}
}
示例3: testReadByArticleId
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Test
public void testReadByArticleId() {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
InputStream is = classloader.getResourceAsStream("articleId.csv");
java.util.Scanner s = new java.util.Scanner(is).useDelimiter(",");
DataFactory df = new DataFactory();
LoremIpsum loremIpsum = new LoremIpsum();
int i=0;
while(s.hasNext()) {
if(i==10) break;
String articleId = s.next().trim();
final List<Comment> commentsByArticleId = repo.findCommentsByArticleId(articleId);
assertNotNull(commentsByArticleId);
assertFalse(commentsByArticleId.isEmpty());
commentsByArticleId.forEach(c-> System.out.println(c));
i++;
}
}
示例4: onCreate
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH);
PersonAdaptor personAdaptor = new PersonAdaptor(this);
for (int i = 0; i < 30; i++) {
personAdaptor.add(new Person(i, new DataFactory(), sdf));
}
SpreadSheetView spreadSheetView = (SpreadSheetView) findViewById(R.id.spread_sheet);
spreadSheetView.setAdaptor(personAdaptor);
spreadSheetView.invalidate();
}
示例5: generateAndStorePlaces
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
/**
* This is a development helper function for seeding the db.
* It generates massive amounts of places with fake data and inserts then to database.
* The x0 and y0 are longitude and latitude respectively, the new places will be generated
* in a circle around them.
* @param places_num The number of placed to generate.
* @param latitude The latitude at the center of circle
* @param longitude The longitude at the center of circle
* @param radius The radious of circle in meters.
*/
public void generateAndStorePlaces(int places_num, double latitude, double longitude, double radius ){
DataFactory df = new DataFactory();
Random randomGenerator = new Random();
List<Category> categories = getAllCategories();
double radiusInDegrees = radius / 111000f; // Convert radius from meters to degrees (near the equator)
while(--places_num >= 0) {
Category randomCategory = categories.get(randomGenerator.nextInt(categories.size()));
/* u and v are random number between 0 and 1 */
double u = randomGenerator.nextDouble();
double v = randomGenerator.nextDouble();
/* Random point inside radious algorithm. Credits here: http://gis.stackexchange.com/questions/25877/ */
double w = radiusInDegrees * Math.sqrt(u);
double t = 2 * Math.PI * v;
double x = w * Math.cos(t);
double y = w * Math.sin(t);
// Adjust the x-coordinate for the shrinking of the east-west distances
double new_x = x / Math.cos(latitude);
double randomLongitude = new_x + longitude;
double randomLatitude = y + latitude;
Place p = new Place(df.getName() + " - " + df.getBusinessName(),
df.getRandomWord() + " " + df.getRandomText(35, 55) + " " + df.getRandomWord(),
randomLatitude,
randomLongitude,
randomCategory.getId());
insertOrReplacePlace(p);
// Log.d("Generated Place", p.toString());
// Log.d("Iteration #", Integer.toString(places_num));
}
}
示例6: createBulkData
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Test
@Ignore
public void createBulkData() {
DataFactory df = new DataFactory();
List<Article> all = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
all.add(new Article(null,df.getName(),df.getEmailAddress(),df.getCity(),df.getRandomText(200),df.getLastName()));
}
repo.bulkCreateArticles(all);
}
示例7: setupUser
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@GET
@Path("/setupuser")
@Produces(MediaType.APPLICATION_JSON)
public String setupUser() {
logger.info("Setup aufrufen");
DataFactory df = DataFactory.create();
User user = new User(df.getFirstName(),df.getLastName(), df.getEmailAddress());
Key<User> userKey = ObjectifyService.ofy().save().entity(user).now();
User user2 = new User(df.getFirstName(),df.getLastName(), df.getEmailAddress());
Key<User> user2Key = ObjectifyService.ofy().save().entity(user2).now();
Address addr = new Address(df.getCity(),String.valueOf( df.getNumberBetween(10000, 99999)), df.getStreetName(),
String.valueOf(df.getNumberUpTo(300)));
// need to store to db, so the address entity gets a key in the db that can be assigned to the item
Key<Address> key = ObjectifyService.ofy().save().entity(addr).now();
Address addr2 = new Address(df.getCity(),String.valueOf( df.getNumberBetween(10000, 99999)), df.getStreetName(),
String.valueOf(df.getNumberUpTo(300)));
// need to store to db, so the address entity gets a key in the db that can be assigned to the item
Key<Address> key2 = ObjectifyService.ofy().save().entity(addr2).now();
user.addAddress(key2);
user2.addAddress(key);
UserRating userRating = new UserRating(userKey.getId(), user2Key.getId(), df.getNumberBetween(0, 5));
ObjectifyService.ofy().save().entity(userRating).now();
UserRating userRating2 = new UserRating(userKey.getId(), user2Key.getId(), df.getNumberBetween(0, 5));
ObjectifyService.ofy().save().entity(userRating2).now();
ObjectifyService.ofy().save().entity(user).now();
ObjectifyService.ofy().save().entity(user2).now();
logger.info("Saved user with address.");
return "{\"status\":\"done\"}";
}
示例8: mock
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Override
public void mock() {
person.mock();
DataFactory df = new DataFactory();
address = df.getAddress();
city = df.getCity();
telephone = String.valueOf(100000 + new Random().nextInt(900000));
}
示例9: mock
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Override
public void mock() {
customerNr = "CN - " + (int)(Math.random() * 9000 + 1000);
DataFactory df = new DataFactory();
surname = df.getLastName();
firstname = df.getFirstName();
boolean male = Math.random() < 0.5;
email = firstname.toLowerCase() + "." + surname.toLowerCase() + "@loremipsum.com";
company = surname + " " + (Math.random() < 0.5 ? "AG" : "GmbH");
salutation = male ? Salutation.Male : Salutation.Female;
customersince = LocalDate.now();
}
示例10: mock
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Override
public void mock() {
DataFactory df = new DataFactory();
name1 = df.getName();
matchcode = name1;
address.city = df.getCity();
address.street = df.getStreetName();
}
示例11: mock
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Override
public void mock() {
DataFactory df = new DataFactory();
name1 = df.getName();
matchcode = name1;
address.city = df.getCity();
address.street = df.getStreetName();
contact.email = df.getEmailAddress();
}
示例12: fillWithDemoData
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Override
protected void fillWithDemoData(Customer customer) {
super.fillWithDemoData(customer);
DataFactory df = new DataFactory();
customer.name = df.getLastName();
customer.firstName = df.getFirstName();
}
示例13: Person
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
public Person(int id, DataFactory dataFactory, SimpleDateFormat simpleDateFormat) {
this.id = id;
this.firstName = dataFactory.getFirstName();
this.lastName = dataFactory.getLastName();
this.city = dataFactory.getCity();
this.company = new CustomCompany(dataFactory.getBusinessName());
this.birthday = simpleDateFormat.format(dataFactory.getBirthDate());
this.email = dataFactory.getEmailAddress();
this.gender = id % 3 == 0;
}
示例14: doIt
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
private void doIt(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
User user = null;
DataFactory df = new DataFactory();
//for (int i = 0; i < 100; i++) {
user = new User();
user.setFirstname(df.getFirstName());
user.setLastname(df.getLastName());
user.setNickname(df.getRandomWord(8, 12));
user.setPhone(df.getNumberText(8));
user.setEmail(df.getEmailAddress());
userManager.create(user);
//}
}
示例15: createBulkData
import org.fluttercode.datafactory.impl.DataFactory; //导入依赖的package包/类
@Test
@Ignore
public void createBulkData() {
DataFactory df = new DataFactory();
List<Employee> all = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
all.add(new Employee(df.getRandomChars(5),df.getName(),df.getBirthDate(),df.getAddress(),df.getFirstName(),df.getLastName()));
}
repo.bulkCreateEmployees(all);
}