forked from vijaykosis/smartapi-java
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathExceptionTests.java
More file actions
91 lines (70 loc) · 2.73 KB
/
ExceptionTests.java
File metadata and controls
91 lines (70 loc) · 2.73 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
package com.angelbroking.smartapi.exceptions;
import com.angelbroking.smartapi.http.exceptions.*;
import com.angelbroking.smartapi.smartstream.models.SmartStreamError;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
public class ExceptionTests {
@Test
public void testDataException() {
String message = "Test Message";
String code = "Test Code";
DataException exception = new DataException(message, code);
assertEquals(message, exception.message);
assertEquals(code, exception.code);
}
@Test
public void testGeneralException() {
String message = "Test Message";
String code = "123";
GeneralException exception = new GeneralException(message, code);
assertEquals(message, exception.message);
assertEquals(code, exception.code);
}
@Test
public void testInputException() {
InputException exception = new InputException("Test message", "Test code");
assertEquals("Test message", exception.message);
assertEquals("Test code", exception.code);
}
@Test
public void testNetworkException() {
NetworkException exception = new NetworkException("Test message", "Test code");
assertEquals("Test message", exception.message);
assertEquals("Test code", exception.code);
}
@Test
public void testOrderException() {
OrderException exception = new OrderException("Test message", "Test code");
assertEquals("Test message", exception.message);
assertEquals("Test code", exception.code);
}
@Test
public void testPermissionException() {
PermissionException exception = new PermissionException("Test message", "Test code");
assertEquals("Test message", exception.message);
assertEquals("Test code", exception.code);
}
@Test
public void testTokenException() {
String message = "Test message";
String code = "123";
TokenException tokenException = new TokenException(message, code);
assertEquals(message, tokenException.message);
assertEquals(code, tokenException.code);
}
@Test
public void testApiKeyException() {
String message = "Invalid API Key";
String code = "123";
ApiKeyException exception = new ApiKeyException(message, code);
assertEquals(message, exception.message);
assertEquals(code, exception.code);
}
@Test
public void testSmartStreamError() {
Throwable exception = new Throwable("Test Exception");
SmartStreamError smartStreamError = new SmartStreamError();
smartStreamError.setException(exception);
assertEquals(exception, smartStreamError.getException());
}
}