DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Latest Articles - DZone

article thumbnail
A Guide to Events in Vue
Let's look at how events work in Vue.
May 13, 2022
by Johnny Simpson
· 5,208 Views · 2 Likes
article thumbnail
Modernize Legacy Code in Production: Rebuild Your Airplane Midflight Without Crashing
Rewriting apps is easy. Doing it while preserving compatibility...that's a bit hard. Doing it live in production? That's the big challenge!
May 13, 2022
by Shai Almog DZone Core CORE
· 6,951 Views · 6 Likes
article thumbnail
Advancing to Agile From the Traditional Product Management Approach
Foster increased revenue and greater efficiency with Agile, one of the latest approaches for product management in the software development industry.
Updated May 13, 2022
by Heli Patel
· 2,898 Views · 3 Likes
article thumbnail
Best Practices for Resource Management in PrestoDB
Resource management in a distributed environment makes accessibility of data easier and manages resources over the network of autonomous computers.
May 13, 2022
by Rohan Pednekar
· 5,575 Views · 1 Like
article thumbnail
Flutter vs React Native. How to Cover All Mobile Platforms in 2022 With No Hassle
In this article, we will compare Flutter and React Native to decide which framework to choose for mobile app development.
May 13, 2022
by Sergey Laptick
· 5,982 Views · 2 Likes
article thumbnail
Rebuild System Databases in SQL Server
Learn about system database corruption and what it means. If corruption in system databases occurs, is a problem because it will cause the SQL Server to stop.
May 13, 2022
by Priyanka Chauhan
· 6,802 Views · 2 Likes
article thumbnail
How to Fix Recovery Pending State in SQL Server Database
Getting recovery pending state in SQL Server Database is a common query asked by users. Read this article to get rid of SQL Server recovery pending state error.
Updated May 13, 2022
by Mukesh Nailwal
· 6,244 Views · 3 Likes
article thumbnail
Debugging Deadlocks and Race Conditions
Threading issues are a piece of cake with these simple debugger techniques. Yes, you CAN debug threads with breakpoints, when using the right type!
May 12, 2022
by Shai Almog DZone Core CORE
· 6,892 Views · 7 Likes
article thumbnail
Time Synchronization in Distributed Systems: TiDB's Timestamp Oracle
This article is an introduction to PingCAP's TiDB’s timestamp oracle (TSO), how it delivers time services, and its strengths and weaknesses.
May 12, 2022
by haitao gao
· 7,104 Views · 2 Likes
article thumbnail
IoT Product Development Guide for Startups
75% of IoT projects fail. To avoid this scenario, you should carefully plan your project beforehand and familiarize yourself with the IoT product development stages.
May 12, 2022
by Roman Lapa
· 11,042 Views · 2 Likes
article thumbnail
Untangling the Potential of IoT Protocols and Standards
How IoT Protocols and Standards Support Secure Data Exchange in the IoT Ecosystem?
May 12, 2022
by Amit Srivastava
· 11,222 Views · 4 Likes
article thumbnail
Waterfall Vs. Agile Methodologies: Which Is Best For Project Management?
Depending on the project's complexity, a software development company might choose between Waterfall and Agile methodologies. Learn the core differences.
May 12, 2022
by Sandip Patel
· 5,884 Views · 3 Likes
article thumbnail
Getting Started With Redis on AWS the Easy Way
This quick-start guide demonstrates how to use AWS Cloud9 IDE to help you get up and running with MemoryDB for Redis.
May 12, 2022
by Abhishek Gupta DZone Core CORE
· 39,470 Views · 3 Likes
article thumbnail
How to Test JavaScript Code in a Browser
Check out these six popular tools and techniques for testing your JavaScript code in a browser.
Updated May 11, 2022
by Jaswant Kaur
· 68,641 Views · 13 Likes
article thumbnail
Database Migration tools: Flyway vs Liquibase
Learning and choosing a migration tool for yor project? Deepening your knowledge about Flyway and Liquibase will give you new insight for efficient workflow.
Updated May 11, 2022
by Bartłomiej Żyliński DZone Core CORE
· 70,784 Views · 15 Likes
article thumbnail
The Evolution of Configuration Management: IaC vs. GitOps
Misconfigurations are the leading cause behind security incidents in Kubernetes environments.
May 11, 2022
by Twain Taylor DZone Core CORE
· 7,730 Views · 3 Likes
article thumbnail
Refactoring Java Application: Object-Oriented And Functional Approaches
Learn how you can achieve better design using object-oriented and functional approaches. This post includes examples with inheritance and functional interfaces.
Updated May 11, 2022
by Dmitry Egorov DZone Core CORE
· 24,061 Views · 21 Likes
article thumbnail
How to Watch for Nested Changes in Vue
Let's look at how to watch for Nested Changes in Vue
May 11, 2022
by Johnny Simpson
· 5,846 Views · 2 Likes
article thumbnail
How to Generate Fake Test Data
Are you also often uninspired when you need to think of useful test data for your unit tests? Is ‘John Doe’ your best test friend? Do not worry, Java Faker comes to the rescue! In this blog, you will learn how to generate your test data. 1. Introduction Making up test data is one of the hardest tasks when writing tests. Often you will see 123 when numbers are being used, or John Doe when a name is needed. But this also means that the test will always run with the same data. This is on the one hand a good thing because your tests needs to be stable, but on the other hand a pitty because you also want to find errors. And this is more likely when random test data is being used. Java Faker is a library based on Ruby’s faker gem and Perl’s Data::Faker library. It will generate fake data for you. There are other Java libraries for that, but in order to see which library gains popularity, a view on the GitHub stars history can be quite useful. As you can see, Java Faker is on the rise. Besides that, it is based on existing fakers in other languages. In this blog, you will learn how to use Java Faker. As usual, all sources being used in this blog are available at GitHub. 2. Add Dependency As a project to experiment with, you will create a basic Spring Boot application. Just navigate to start.spring.io and create a Spring Boot application with Java 17. Java Faker can also be used with plain Java applications of course. The only thing remaining to do, is to add the javafaker dependency to the pom. XML com.github.javafaker javafaker 1.0.2 test 3. First Test Java Faker offers many data fakers which can be used. A complete list can be found here and a demo application with some examples can be found here. In the first example you create, you create a Faker instance and from that moment on, you can choose a faker and generate data. Use the Address faker in order to generate a first name, a last name and a street name. Java @Test void addressFaker() { Faker faker = new Faker(); String firstName = faker.address().firstName(); String lastName = faker.address().lastName(); String streetName = faker.address().streetName(); System.out.println("First name: " + firstName); System.out.println("Last name: " + lastName); System.out.println("Street name: " + streetName); } The output is for example the following, but this will change on each run. Shell First name: Mika Last name: Terry Street name: Wisoky Walk 4. Locale Faker In the previous example, you noticed that English names are generated. But what if you want more locale specific names? That is also possible, but note that not every faker is available in every language. The list for your locale can be found here. Since I am interested in the Dutch locale, the previous example can be rewritten als follows (note that the address faker is available in the NL locale). The only difference is that you need to provide the locale when instantiating the Faker. Java @Test void addressNlFaker() { Faker faker = new Faker(new Locale("nl-NL")); String firstName = faker.address().firstName(); String lastName = faker.address().lastName(); String streetName = faker.address().streetName(); System.out.println("First name: " + firstName); System.out.println("Last name: " + lastName); System.out.println("Street name: " + streetName); } This returns the following output, which corresponds to Dutch names. Shell First name: Irmen Last name: Vaassen Street name: Severensweg 5. Random Strings With FakeValuesService With the FakeValuesService, you can generate several strings containing random data. In the next sections, some of the features are shown. 5.1 Random Strings With Numerify With numerify, you can generate a string containing random numbers. First, you need to create a FakeValuesService instance containing a locale and a RandomService. The method numerify will return a string where the hashes (#) are replaced with numbers. For every hash, a number is replaced. Java @Test void fakeValuesServiceNumerify() { FakeValuesService fakeValuesService = new FakeValuesService(new Locale("nl-NL"), new RandomService()); String randomNumber = fakeValuesService.numerify("number##"); System.out.println("Random number is: " + randomNumber); } The output is for example: Shell Random number is: number37 5.2 Random Strings With Letterify Similar as with numerify, letterify will allow you to replace characters in a string by means of a question mark. Java @Test void fakeValuesServiceLetterify() { FakeValuesService fakeValuesService = new FakeValuesService(new Locale("nl-NL"), new RandomService()); String randomLetters = fakeValuesService.letterify("somestring??"); System.out.println("Random letters are: " + randomLetters); } The output is for example: Shell Random letters are: somestringha 5.3 Random Strings With Bothify A combination of numerify and letterify can be achieved with bothify. With bothify, you can combine random numbers and characters. Java @Test void fakeValuesServiceBothify() { FakeValuesService fakeValuesService = new FakeValuesService(new Locale("nl-NL"), new RandomService()); String randomNumbersLetters = fakeValuesService.bothify("some string with numbers ## and letters ??"); System.out.println("Random numbers and letters are: " + randomNumbersLetters); } The output is for example: Shell Random numbers and letters are: some string with numbers 10 and letters ll 5.4 Random Strings With Regexify When all of the above is not enough, you can also generate strings based on a regular expression with regexify. The next regular expression will choose one or more characters of the list a, b, or c, followed by any whitespace character and a digit. Java @Test void fakeValuesServiceRegexify() { FakeValuesService fakeValuesService = new FakeValuesService(new Locale("nl-NL"), new RandomService()); String randomBasedRegex = fakeValuesService.regexify("[abc]+\\s\\d"); System.out.println("Random string based on a pattern: " + randomBasedRegex); } The output is for example the following. Note that it generates ‘any whitespace character’ which in this case is an end of line character. Shell Random string based on a pattern: ab 9 6. Conclusion Java Faker is an easy to use data faker generation library. It relieves you from the burden of making up test data for your tests. Moreover, it will generate other data on each run which might reveal bugs in your application. The documentation of the library could have been better, but on the other hand, the library is also easy to use, so it should not be a major problem after all.
May 11, 2022
by Gunter Rotsaert DZone Core CORE
· 8,293 Views · 6 Likes
article thumbnail
Top Soft Skills to Identify a Great Software Engineer
These interpersonal attributes when corroborated by their technical skills tend to make the greatest software developers of all times.
May 11, 2022
by Mark Williams
· 5,972 Views · 3 Likes
  • Previous
  • ...
  • 714
  • 715
  • 716
  • 717
  • 718
  • 719
  • 720
  • 721
  • 722
  • 723
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×