-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryTest.java
More file actions
147 lines (143 loc) · 4.24 KB
/
LibraryTest.java
File metadata and controls
147 lines (143 loc) · 4.24 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package com.test;
import com.Library;
import lombok.extern.log4j.Log4j;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import static com.Constants.PATH_DIR;
@Log4j
public class LibraryTest {
Library lb= new Library();
/**
* The test List files from path
* in this test using 'user.dir' for get path
*/
@Test
public void isGetListFilesTest() throws IOException {
String path = System.getProperty(PATH_DIR);
lb.isGetListFiles(path);
}
/**
* The test is check current date
* for running this test - need to write an expected date
*/
@Test
public void isCurrentDateTest(){
String actual = lb.isCurrentDate();
log.info(actual);
// String expected = "";
// Assert.assertEquals(expected,actual);
}
/**
* The test - check convert a format stamp date
* throws ParseException
*/
@Test
public void isStampConvertTest() throws ParseException {
String index = "10/10/2000";
String inputFormat = "dd/MM/yyyy";
String outputFormat = "MMM d, yyyy hh:mm:ss aa";
String actual = lb.isStampConvert(inputFormat,index,outputFormat);
String expected = "Oct 10, 2000 12:00:00 AM";
Assert.assertEquals(actual,expected);
}
/**
* The test - check method random number
*/
@Test
public void isRandomNumberTest(){
double actual = lb.isRandomNumber(5,7);
double expected =6.0;
Assert.assertEquals(actual,expected,2.0);
}
/**
* The test - check method parse string to integer
*/
@Test
public void isConvertStringToIntegerTest(){
int actual = lb.isConvertStringToInteger("13");
int expected = 13;
Assert.assertEquals(actual,expected);
}
/**
* The test - check method parse integer to string
*/
@Test
public void isConvertIntegerToStringTest(){
String actual = lb.isConvertIntegerToString(13);
String expected = "13";
Assert.assertEquals(actual,expected);
}
/**
* The test - check method if object is Integer
*/
@Test
public void isCheckObjectIntegerTest(){
Object ob = 13;
boolean actual = lb.isCheckObjectInteger(ob);
Assert.assertTrue(actual);
}
/**
* The test - check method if object is String
*/
@Test
public void isCheckValueStringTest(){
Object ob = "13";
boolean actual = lb.isCheckValueString(ob);
Assert.assertTrue(actual);
}
/**
* The test - create file with text
*/
@Test
public void isCreateFileTest() throws IOException {
String path = System.getProperty(PATH_DIR);
lb.isCreateFile(path+"/file.txt","Ho ho ho !!!");
}
/**
* The test - print from map
*/
@Test
public void isPrintMapTest(){
Map<Integer, String> map = new HashMap<>();
map.put(1,"Java");
map.put(2,"Python");
map.put(3,"Scala");
map.put(4,"Go");
map.put(5,"JavaScript");
lb.isPrintMap(map);
}
/**
* The test - print repair number in array
*/
@Test
public void isPrintRepeatingNumberTest(){
int [] arr= {1,2,3,4,4,5,6,7,7,8,9};
lb.isPrintRepeatingNumber(arr);
}
/**
* The test - print new array without repair number in array
*/
@Test
public void isPrintArrayWithOutRepeatingNumberTest() {
int[] arr = {1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9};
lb.isPrintArrayWithOutRepeatingNumber(arr);
}
/**
* The test - print new array without repair number in array
*/
@Test
public void isDeleteRepeatingValueFromArrayTest() {
int[] arr = {1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9};
lb.isDeleteRepeatingValueFromArray(arr);
}
@Test
public void isDifferenceNumberDaysTest()throws ParseException{
int actual = lb.isDifferenceNumberDays("31/12/2021","dd/MM/yyyy");
int expected = lb.isExpectedNumber();
Assert.assertEquals(actual,expected);
}
}