|
1 | 1 | package com.epam.izh.rd.online; |
2 | 2 |
|
3 | 3 | import com.epam.izh.rd.online.entity.Author; |
| 4 | +import com.epam.izh.rd.online.repository.SimpleAuthorRepository; |
4 | 5 | import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList; |
5 | 6 | import com.sun.xml.internal.ws.addressing.WsaActionUtil; |
6 | 7 | import org.springframework.util.Assert; |
7 | 8 | import org.springframework.util.SocketUtils; |
8 | 9 |
|
| 10 | +import java.time.LocalDate; |
9 | 11 | import java.util.ArrayList; |
10 | 12 |
|
11 | 13 | public class Main { |
12 | 14 |
|
13 | 15 | public static void main(String[] args) { |
14 | 16 |
|
15 | | - {/* SECTION FOR DEBUGGING CLASS Author */ |
16 | | -// |
17 | | -// Author author1 = new Author(); |
18 | | -// |
19 | | -// author1.setName("Yaroslav"); |
20 | | -// author1.setCountry("Russia"); |
21 | | -// |
22 | | -// class FreakAuthor extends Author { |
23 | | -// public FreakAuthor(String name) { |
24 | | -// this.setName(name); |
25 | | -// } |
26 | | -// |
27 | | -// @Override |
28 | | -// public int hashCode() { |
29 | | -// return Object.class.hashCode(); |
30 | | -// } |
31 | | -// |
32 | | -// } |
33 | | -// |
34 | | -// FreakAuthor freak = new FreakAuthor("John"); |
35 | | -// |
36 | | -// System.out.println("author1.objectToString(): " + author1.objectToString()); |
37 | | -// System.out.println("author1.toString(): " + author1.toString()); |
38 | | -// System.out.println("\n" + "author1 is the following " + author1.toString()); |
39 | | -// |
40 | | -// System.out.println("\nHash code1 for author " + author1.getName() + " is " + author1.hashCode()); |
41 | | -// System.out.println("Hash code2 for author " + author1.getName() + " is " + author1.hashCode()); |
42 | | -// System.out.println("Hash code3 for author " + author1.getName() + " is " + author1.hashCode()); |
43 | | -// |
44 | | -// System.out.println("\nHash code1 for author " + freak.getName() + " is " + freak.hashCode()); |
45 | | -// System.out.println("Hash code2 for author " + freak.getName() + " is " + freak.hashCode()); |
46 | | -// System.out.println("Hash code3 for author " + freak.getName() + " is " + freak.hashCode()); |
47 | | -// System.out.println("author1.ToStringHash(): " + author1.ToStringHash()); |
48 | | - |
49 | | - }/* END OF DEBUGGING CLASS Author */ |
50 | | - |
51 | | - |
52 | 17 | {/* SECTION FOR PLAYING WITH ASSERTIONS */ |
53 | 18 |
|
54 | 19 | System.out.println("\n/* SECTION FOR PLAYING WITH ASSERTIONS */\n"); |
@@ -305,6 +270,59 @@ void subtleMethod( byte par ) { |
305 | 270 |
|
306 | 271 | }/* END OF DEBUGGING BINDING METHODS */ |
307 | 272 |
|
| 273 | + |
| 274 | + {/* SECTION FOR DEBUGGING CLASSES */ |
| 275 | + |
| 276 | + System.out.println("\n/* SECTION FOR DEBUGGING CLASSES */\n"); |
| 277 | + |
| 278 | + Author author1 = new Author("Yaroslav", "Kozlov", LocalDate.of(1974,10,05), "Russia"); |
| 279 | + Author author2 = new Author("James", "Bond", null, "UK"); |
| 280 | + Author author3 = new Author("Wolfgang", "Mozart", LocalDate.of(1756,01,27), "Austria"); |
| 281 | + |
| 282 | + SimpleAuthorRepository rep4Authors = new SimpleAuthorRepository(); |
| 283 | + |
| 284 | + System.out.println("author1.toString(): " + author1.toString()); |
| 285 | + System.out.println("author2.toString(): " + author2.toString()); |
| 286 | + System.out.println("author3.toString(): " + author3.toString()); |
| 287 | + |
| 288 | + System.out.println("\nNumber of authors saved in repository is " + rep4Authors.count()); |
| 289 | + |
| 290 | + System.out.println("\nSaving author1 in repository"); |
| 291 | + rep4Authors.save(author1); |
| 292 | + System.out.println("Number of authors saved in repository is " + rep4Authors.count()); |
| 293 | + |
| 294 | + System.out.println("\nSaving author2 in repository"); |
| 295 | + rep4Authors.save(author2); |
| 296 | + System.out.println("Number of authors saved in repository is " + rep4Authors.count()); |
| 297 | + |
| 298 | + System.out.println("\nSaving author3 in repository"); |
| 299 | + rep4Authors.save(author3); |
| 300 | + System.out.println("Number of authors saved in repository is " + rep4Authors.count()); |
| 301 | + |
| 302 | + Author found; |
| 303 | + found = rep4Authors.findByFullName("James", "Bond"); |
| 304 | + System.out.println("\nIs James Bond in repository? " + (found == null ? "No: " : "Yes: ") + found); |
| 305 | + found = rep4Authors.findByFullName("Vasya", "Pupkin"); |
| 306 | + System.out.println("Is Vasya Pupkin in repository? " + (found == null ? "No: " : "Yes: ") + found); |
| 307 | + |
| 308 | + Author vasya = new Author("Vasya","Pupkin",null, null); |
| 309 | + System.out.println("\nSaving author Vasya Pupkin in repository"); |
| 310 | + rep4Authors.save(vasya); |
| 311 | + System.out.println("Number of authors saved in repository is " + rep4Authors.count()); |
| 312 | + |
| 313 | + found = rep4Authors.findByFullName("Vasya", "Pupkin"); |
| 314 | + System.out.println("Is Vasya Pupkin in repository? " + (found == null ? "No: " : "Yes: ") + found); |
| 315 | + |
| 316 | + System.out.println("\nRemoving author Vasya Pupkin from repository"); |
| 317 | + rep4Authors.remove(vasya); |
| 318 | + System.out.println("Number of authors saved in repository is " + rep4Authors.count()); |
| 319 | + found = rep4Authors.findByFullName("Vasya", "Pupkin"); |
| 320 | + System.out.println("Is Vasya Pupkin in repository? " + (found == null ? "No: " : "Yes: ") + found); |
| 321 | + |
| 322 | + System.out.println("\n/* END OF DEBUGGING CLASSES */\n"); |
| 323 | + |
| 324 | + }/* END OF DEBUGGING CLASSES */ |
| 325 | + |
308 | 326 | System.exit(0); |
309 | 327 | } |
310 | 328 |
|
|
0 commit comments