0

I have a small database table as follows:

select * from customers;
+---------------+---------------+-------------------+-------------------+
| date          | customerTitle | customerBill      | status            |
+---------------+---------------+-------------------+-------------------+
| 1441478000000 | MR            | 000-000-100-0001  | approve           |
| 1442478000000 | MR            | 000-000-200-0002  | approve           |
| 1443478000000 | MISS          | 000-000-300-0003  | approve           |
| 1445478000000 | MRS           | 000-000-400-0004  | approve           |
+---------------+---------------+-------------------+-------------------+
4 rows in set (0.00 sec)

Currently, I query some of the fields in a column/row individually. Is there a way I can just get all the fields from this MySQL table and then assert it against a stored list of values and check that all columns, rows and fields match with expected?

How do I achieve this using code in Java?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Saffik
  • 911
  • 4
  • 19
  • 45

1 Answers1

0

You can create an entity class. Call a select query to load the complete table and store as list of Customers Entity List. Also update equals and hashcode to return true when all the fields are equals and then simply match each entity with the stored one by calling checking contains method of array list.

Aman Chhabra
  • 3,824
  • 1
  • 23
  • 39
  • Great, do you have any examples of that? perhaps a link to it or something to put it into more context? :) @Aman Chhabra – Saffik Mar 29 '18 at 14:23
  • How to create Entity Class - You can create normal POJO class or use eclipse functionality as on link: https://www.eclipse.org/webtools/dali/docs/3.2/user_guide/tasks006.htm – Aman Chhabra Mar 29 '18 at 14:38
  • Updating equals and hashcode: https://stackoverflow.com/questions/17801611/implementing-hashcode-and-equals-for-custom-classes – Aman Chhabra Mar 29 '18 at 14:39