Skip to content

Commit 36f53a4

Browse files
author
TanyaEf
committed
Resolving conflicts
2 parents eea0048 + 4a204b6 commit 36f53a4

File tree

6 files changed

+403
-124
lines changed

6 files changed

+403
-124
lines changed

src/main/java/com/jaspersoft/jasperserver/jaxrs/client/core/RestClientConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public static RestClientConfiguration loadConfiguration(String path) {
180180

181181
String readTimeout = properties.getProperty("readTimeout");
182182
if (readTimeout != null && !readTimeout.equals(""))
183-
configuration.setConnectionTimeout(Integer.valueOf(readTimeout));
183+
configuration.setReadTimeout(Integer.valueOf(readTimeout));
184184

185185
try {
186186
configuration.setContentMimeType(MimeType.valueOf(properties.getProperty("contentMimeType")));
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.jaspersoft.jasperserver.jaxrs.client.core;
2+
3+
import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.AbstractAdapter;
4+
import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.bundles.BundlesService;
5+
import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.serverInfo.ServerInfoService;
6+
import com.jaspersoft.jasperserver.jaxrs.client.apiadapters.settings.SettingsService;
7+
import org.mockito.Mock;
8+
import org.testng.annotations.AfterMethod;
9+
import org.testng.annotations.BeforeMethod;
10+
import org.testng.annotations.Test;
11+
12+
import static org.mockito.MockitoAnnotations.initMocks;
13+
import static org.testng.Assert.assertNotNull;
14+
import static org.testng.Assert.assertSame;
15+
16+
17+
/**
18+
* Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.core.Session}
19+
*/
20+
public class AnonymousSessionTest {
21+
@Mock
22+
public SessionStorage storageMock;
23+
24+
@BeforeMethod
25+
public void before() {
26+
initMocks(this);
27+
}
28+
29+
@Test(expectedExceptions = RuntimeException.class)
30+
public void should_throw_exception_when_cannot_instantiate_service_class() {
31+
AnonymousSession anonymousSession = new AnonymousSession(storageMock);
32+
class CustomAdapter extends AbstractAdapter {
33+
public CustomAdapter(SessionStorage sessionStorage) {
34+
super(sessionStorage);
35+
}
36+
}
37+
anonymousSession.getService(CustomAdapter.class);
38+
}
39+
40+
@Test
41+
public void should_return_proper_storage() {
42+
AnonymousSession anonymousSession = new AnonymousSession(storageMock);
43+
assertSame(anonymousSession.getStorage(), storageMock);
44+
}
45+
46+
@Test
47+
public void should_return_not_null_ServerInfoService() {
48+
AnonymousSession anonymousSession = new AnonymousSession(storageMock);
49+
ServerInfoService retrieved = anonymousSession.serverInfoService();
50+
assertNotNull(retrieved);
51+
}
52+
53+
@Test
54+
public void should_return_not_null_settingsService() {
55+
AnonymousSession anonymousSession = new AnonymousSession(storageMock);
56+
SettingsService retrieved = anonymousSession.settingsService();
57+
assertNotNull(retrieved);
58+
}
59+
60+
@Test
61+
public void should_return_not_null_bundlesService() {
62+
AnonymousSession anonymousSession = new AnonymousSession(storageMock);
63+
BundlesService retrieved = anonymousSession.bundlesService();
64+
assertNotNull(retrieved);
65+
}
66+
67+
@AfterMethod
68+
public void after() {
69+
storageMock = null;
70+
}
71+
}

src/test/java/com/jaspersoft/jasperserver/jaxrs/client/core/JasperserverRestClientTest.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,52 @@ public void should_throw_an_exception_when_pass_null_param_to_the_constructor()
6363
new JasperserverRestClient(null);
6464
}
6565

66+
@Test(testName = "JasperserverRestClient_authenticate")
67+
public void should_return_null_when_username_is_null() {
68+
// Given
69+
JasperserverRestClient jasperserverRestClient = new JasperserverRestClient(configurationMock);
70+
// When
71+
Session session = jasperserverRestClient.authenticate(null, PASSWORD);
72+
// Then
73+
assertEquals(session, null);
74+
}
75+
@Test(testName = "JasperserverRestClient_authenticate")
76+
public void should_return_null_when_username_is_empty() {
77+
// Given
78+
JasperserverRestClient jasperserverRestClient = new JasperserverRestClient(configurationMock);
79+
// When
80+
Session session = jasperserverRestClient.authenticate("", PASSWORD);
81+
// Then
82+
assertEquals(session, null);
83+
}
84+
85+
@Test(testName = "JasperserverRestClient_authenticate")
86+
public void should_return_null_when_password_is_null() {
87+
// Given
88+
JasperserverRestClient jasperserverRestClient = new JasperserverRestClient(configurationMock);
89+
// When
90+
Session session = jasperserverRestClient.authenticate(USER_NAME, null);
91+
// Then
92+
assertEquals(session, null);
93+
}
94+
@Test(testName = "JasperserverRestClient_authenticate")
95+
public void should_return_null_when_password_is_empty() {
96+
// Given
97+
JasperserverRestClient jasperserverRestClient = new JasperserverRestClient(configurationMock);
98+
// When
99+
Session session = jasperserverRestClient.authenticate(USER_NAME, "");
100+
// Then
101+
assertEquals(session, null);
102+
}
103+
104+
66105
@Test
67106
public void should_return_proper_Session_object() throws Exception {
68107

69108
// Given
70109
final JasperserverRestClient client = new JasperserverRestClient(configurationMock);
71110
final JasperserverRestClient spyClient = spy(client);
72111

73-
74112
whenNew(AuthenticationCredentials.class)
75113
.withArguments(USER_NAME, PASSWORD)
76114
.thenReturn(credentialsMock);

0 commit comments

Comments
 (0)