forked from JavaOPs/basejava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainTestArrayStorage.java
More file actions
51 lines (39 loc) · 1.48 KB
/
MainTestArrayStorage.java
File metadata and controls
51 lines (39 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package ru.javaops.webapp;
import ru.javaops.webapp.model.Resume;
import ru.javaops.webapp.storage.IStorage;
import ru.javaops.webapp.storage.SortedArrayStorage;
public class MainTestArrayStorage {
private static final IStorage ARRAY_STORAGE = new SortedArrayStorage();
//private static final IStorage ARRAY_STORAGE = new ArrayStorage();
public static void main(String[] args) {
final Resume r1 = new Resume("uuid3", "");
final Resume r2 = new Resume("uuid1", "");
final Resume r3 = new Resume("uuid2", "");
ARRAY_STORAGE.save(r1);
ARRAY_STORAGE.save(r2);
ARRAY_STORAGE.save(r3);
System.out.println("Get r1: " + ARRAY_STORAGE.get(r1.getUuid()));
System.out.println("Size: " + ARRAY_STORAGE.size());
System.out.println("Get dummy: " + ARRAY_STORAGE.get("dummy"));
//Test update method
printAll();
ARRAY_STORAGE.update(r3);
printAll();
ARRAY_STORAGE.delete(r1.getUuid());
printAll();
ARRAY_STORAGE.clear();
printAll();
System.out.println("Size: " + ARRAY_STORAGE.size());
//Test storage overflow
for (int i = 0; i < 100001; i++){
Resume resume = new Resume("uuid" + i, "uuid" + i);
ARRAY_STORAGE.save(resume);
}
}
private static void printAll() {
System.out.println("\nGet All");
for (Resume r : ARRAY_STORAGE.getAllSorted()) {
System.out.println(r);
}
}
}