Skip to content

Commit 97051ed

Browse files
author
TanyaEf
committed
Updated javadocs for deprecated methods
1 parent 4fa4a25 commit 97051ed

File tree

7 files changed

+110
-34
lines changed

7 files changed

+110
-34
lines changed

src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ public BatchOrganizationsAdapter allOrganizations() {
4646
return new BatchOrganizationsAdapter(sessionStorage);
4747
}
4848

49-
// Deprecated method, use allOrganizations() method
49+
/**
50+
* @deprecated Replaced by {@link OrganizationsService#allOrganizations()}.
51+
*/
5052
@Deprecated
5153
public BatchOrganizationsAdapter organizations() {
5254
return new BatchOrganizationsAdapter(sessionStorage);

src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/SingleOrganizationAdapter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,12 @@ private JerseyRequest<ClientTenant> request() {
141141
new DefaultErrorHandler()
142142
);
143143
}
144-
// Deprecated method, use organization(organizationID).create() methods
145-
@Deprecated
146-
public OperationResult<ClientTenant> create(ClientTenant clientTenant) {
144+
145+
/**
146+
* @deprecated Replaced by {@link SingleOrganizationAdapter#create()}.
147+
*/
148+
@Deprecated
149+
public OperationResult<ClientTenant> create(ClientTenant clientTenant) {
147150
JerseyRequest<ClientTenant> request = request();
148151
return params.size() != 0
149152
? request.addParams(params).post(clientTenant)

src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapter.java

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ public class SingleUserRequestAdapter extends AbstractAdapter {
1717
private StringBuilder uri = new StringBuilder("");
1818

1919
private ClientUser user;
20-
//the field should be deleted after deleting deprecated methods
21-
@Deprecated
20+
/**
21+
* The field is used for deprecated methods of the class.
22+
* @deprecated Replaced by {@link SingleUserRequestAdapter#uri}.
23+
*/
2224
private String userUriPrefix;
2325

2426

@@ -91,7 +93,9 @@ private JerseyRequest<ClientUser> buildRequest() {
9193
new DefaultErrorHandler());
9294
}
9395

94-
@Deprecated
96+
/**
97+
* @deprecated Replaced by {@link SingleUserRequestAdapter#SingleUserRequestAdapter(SessionStorage, ClientUser)}.
98+
*/
9599
public SingleUserRequestAdapter(SessionStorage sessionStorage, String organizationId, String username) {
96100
super(sessionStorage);
97101
if (organizationId != null) {
@@ -104,7 +108,9 @@ public SingleUserRequestAdapter(SessionStorage sessionStorage, String organizati
104108
uri.append(userUriPrefix);
105109
}
106110

107-
@Deprecated
111+
/**
112+
* @deprecated Replaced by {@link SingleUserRequestAdapter#SingleUserRequestAdapter(SessionStorage, ClientUser)}.
113+
*/
108114
public SingleUserRequestAdapter(SessionStorage sessionStorage, String organizationId) {
109115
super(sessionStorage);
110116
if (organizationId != null) {
@@ -114,7 +120,9 @@ public SingleUserRequestAdapter(SessionStorage sessionStorage, String organizati
114120
}
115121
}
116122

117-
@Deprecated
123+
/**
124+
* @deprecated Replaced by {@link SingleUserRequestAdapter#SingleUserRequestAdapter(SessionStorage, ClientUser)}.
125+
*/
118126
public SingleUserRequestAdapter(String userId, String organizationId, SessionStorage sessionStorage) {
119127
super(sessionStorage);
120128
if (organizationId != null && !organizationId.equals("") && userId != null && !userId.equals("")) {
@@ -126,10 +134,11 @@ public SingleUserRequestAdapter(String userId, String organizationId, SessionSto
126134
}
127135
}
128136

129-
@Deprecated
137+
/**
138+
* @deprecated Replaced by {@link SingleUserRequestAdapter#get()}.
139+
*/
130140
public OperationResult<ClientUser> get(String userId) {
131141

132-
/* checks if we already have setted userId */
133142
if (compile("^.*?users/([^/]+)$").matcher(uri.toString()).find()) {
134143
return request().get();
135144
}
@@ -138,12 +147,16 @@ public OperationResult<ClientUser> get(String userId) {
138147
return request().get();
139148
}
140149

141-
@Deprecated
150+
/**
151+
* @deprecated Replaced by {@link SingleUserRequestAdapter#buildRequest()}.
152+
*/
142153
private JerseyRequest<ClientUser> request() {
143154
return JerseyRequest.buildRequest(sessionStorage, ClientUser.class, new String[]{uri.toString()}, new DefaultErrorHandler());
144155
}
145156

146-
@Deprecated
157+
/**
158+
* @deprecated Replaced by {@link SingleUserRequestAdapter#asyncGet(Callback)}.
159+
*/
147160
public <R> RequestExecution asyncGet(final Callback<OperationResult<ClientUser>, R> callback, String userId) {
148161
if (!compile("^.*?users/([^/]+)$").matcher(uri.toString()).find()) {
149162
uri.append(userId);
@@ -159,7 +172,9 @@ public void run() {
159172
return task;
160173
}
161174

162-
@Deprecated
175+
/**
176+
* @deprecated Replaced by {@link SingleUserRequestAdapter#createOrUpdate(ClientUser)}.
177+
*/
163178
public OperationResult<ClientUser> updateOrCreate(ClientUser user) {
164179
uri.append(user.getUsername());
165180
if (!uri.toString().contains("organizations") && user.getTenantId() != null) {
@@ -168,7 +183,9 @@ public OperationResult<ClientUser> updateOrCreate(ClientUser user) {
168183
return request().put(user);
169184
}
170185

171-
@Deprecated
186+
/**
187+
* @deprecated Replaced by {@link SingleUserRequestAdapter#asyncCreateOrUpdate(ClientUser, Callback)}.
188+
*/
172189
public <R> RequestExecution asyncCreateOrUpdate(final ClientUser user, final Callback<OperationResult<ClientUser>, R> callback, final String userId) {
173190
if (!compile("^.*?users/([^/]+)$").matcher(uri.toString()).find()) {
174191
uri.append(userId);
@@ -184,19 +201,25 @@ public void run() {
184201
return task;
185202
}
186203

187-
@Deprecated
204+
/**
205+
* @deprecated Replaced by {@link SingleUserRequestAdapter#delete()}.
206+
*/
188207
public OperationResult delete(String userId) {
189208
uri.append(userId);
190209
return request().delete();
191210
}
192211

193-
@Deprecated
212+
/**
213+
* @deprecated Replaced by {@link SingleUserRequestAdapter#delete()}.
214+
*/
194215
public OperationResult delete(ClientUser user) {
195216
uri.append(user.getUsername());
196217
return request().delete();
197218
}
198219

199-
@Deprecated
220+
/**
221+
* @deprecated Replaced by {@link SingleUserRequestAdapter#asyncDelete(Callback)}.
222+
*/
200223
public <R> RequestExecution asyncDelete(final Callback<OperationResult<ClientUser>, R> callback, String userId) {
201224
uri.append(userId);
202225
final JerseyRequest<ClientUser> request = request();

src/main/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersService.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ public BatchUsersRequestAdapter allUsers() {
6969

7070
return new BatchUsersRequestAdapter(sessionStorage, organizationId);
7171
}
72-
@Deprecated
72+
73+
/**
74+
* @deprecated Replaced by {@link UsersService#forOrganization(String)} or {@link UsersService#forOrganization(ClientTenant)}.
75+
*/
7376
public UsersService organization(String organizationId) {
7477
if ("".equals(organizationId) || "/".equals(organizationId)) {
7578
throw new IllegalArgumentException("'organizationId' mustn't be an empty string");
@@ -78,16 +81,19 @@ public UsersService organization(String organizationId) {
7881
return this;
7982
}
8083

81-
// Deprecated method, use user(userName) method
82-
@Deprecated
84+
/**
85+
* @deprecated Replaced by {@link UsersService#user(String)} or {@link UsersService#user(ClientUser)}.
86+
*/
8387
public SingleUserRequestAdapter username(String username) {
8488
if ("".equals(username) || "/".equals(username)) {
8589
throw new IllegalArgumentException("'username' mustn't be an empty string");
8690
}
8791
return new SingleUserRequestAdapter(sessionStorage, organizationId, username);
8892
}
89-
// Deprecated method, use user(userName) method
90-
@Deprecated
93+
94+
/**
95+
* @deprecated Replaced by {@link UsersService#user(String)} or {@link UsersService#user(ClientUser)}.
96+
*/
9197
public SingleUserRequestAdapter user() {
9298
return new SingleUserRequestAdapter(sessionStorage, organizationId);
9399
}

src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/organizations/OrganizationsServiceTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ public void should_throw_exception_when_organization_id_is_empty() throws Except
109109
// When
110110
service.organization("");
111111
}
112-
//test should be deleted after deleting appropriate method
113-
@Deprecated
112+
113+
/**
114+
* Test should be deleted after deleting appropriate method
115+
* @deprecated Replaced by {@link OrganizationsServiceTest#should_return_proper_instance_of_BatchOrganizationsAdapter_deprecated}.
116+
*/
114117
@Test
115118
public void should_return_proper_instance_of_BatchOrganizationsAdapter_deprecated() throws Exception {
116119

src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/SingleUserRequestAdapterDeprecatedTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
import static org.testng.Assert.assertSame;
3737

3838
/**
39-
* Unit tests for {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users.SingleUserRequestAdapter}
39+
* Class should be deleted after deleting appropriate deprecated methods in SingleUserRequestAdapter class
40+
* @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.organizations.OrganizationsServiceTest}.
4041
*/
41-
// Class should be deleted after deleting appropriate deprecated methods in SingleUserRequestAdapter class
4242
@Deprecated
4343
@PrepareForTest({
4444
SingleUserRequestAdapter.class,

src/test/java/com/jaspersoft/jasperserver/jaxrs/client/apiadapters/authority/users/UsersServiceTest.java

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void should_throw_exception_when_organization_name_is_empty() {
7373
public void should_throw_exception_when_organization_name_is_null() {
7474
// When
7575
UsersService service = new UsersService(sessionStorageMock);
76-
service.forOrganization((String)null);
76+
service.forOrganization((String) null);
7777
// Then
7878
}
7979

@@ -93,6 +93,30 @@ public void should_throw_exception_when_organization_is_null() {
9393
// Then
9494
}
9595

96+
@Test(expectedExceptions = IllegalArgumentException.class)
97+
public void should_throw_exception_when_user_name_is_empty() {
98+
// When
99+
UsersService service = new UsersService(sessionStorageMock);
100+
service.forOrganization("come org").user("");
101+
// Then
102+
}
103+
104+
@Test(expectedExceptions = IllegalArgumentException.class)
105+
public void should_throw_exception_when_user_name_is_null() {
106+
// When
107+
UsersService service = new UsersService(sessionStorageMock);
108+
service.forOrganization("come org").user((String)null);
109+
// Then
110+
}
111+
112+
@Test(expectedExceptions = IllegalArgumentException.class)
113+
public void should_throw_exception_when_users_is_null() {
114+
// When
115+
UsersService service = new UsersService(sessionStorageMock);
116+
service.forOrganization("come org").user((ClientUser) null);
117+
// Then
118+
}
119+
96120
@Test
97121
public void should_return_proper_user_adapter_when_invoke_user_method_with_string() throws Exception {
98122
// When
@@ -131,22 +155,31 @@ public void should_return_BatchUsersRequestAdapter() throws Exception {
131155
assertNotNull(retrieved);
132156
assertSame(retrieved, batchUsersRequestAdapterMock);
133157
}
134-
@Deprecated
158+
159+
/**
160+
* @deprecated Replaced by {@link UsersServiceTest#should_set_organization_id()}.
161+
*/
135162
@Test
136-
public void should_set_ord_id (){
163+
public void should_set_org_id (){
137164
UsersService service = new UsersService(sessionStorageMock);
138165
UsersService retrieved = service.organization("MyCoolOrg");
139166

140167
assertSame(retrieved, service);
141168
assertEquals(Whitebox.getInternalState(service, "organizationId"), "MyCoolOrg");
142169
}
143-
@Deprecated
170+
171+
/**
172+
* @deprecated Replaced by {@link UsersServiceTest#should_throw_exception_when_organization_name_is_empty()}.
173+
*/
144174
@Test(expectedExceptions = IllegalArgumentException.class)
145175
public void should_throw_exception_when_not_specified_ord_name (){
146176
UsersService service = new UsersService(sessionStorageMock);
147177
UsersService retrieved = service.organization("");
148178
}
149-
@Deprecated
179+
180+
/**
181+
* @deprecated Replaced by {@link UsersServiceTest#should_return_proper_user_adapter_when_invoke_user_method_with_string()}.
182+
*/
150183
@Test
151184
public void should_return_proper_user_adapter_when_invoke_username_method() throws Exception {
152185
UsersService service = new UsersService(sessionStorageMock);
@@ -157,13 +190,19 @@ public void should_return_proper_user_adapter_when_invoke_username_method() thro
157190
assertSame(retrieved, singleUserRequestAdapterMock);
158191
//verifyNew(SingleUserRequestAdapter.class);
159192
}
160-
@Deprecated
193+
194+
/**
195+
* @deprecated Replaced by {@link UsersServiceTest#should_throw_exception_when_user_name_is_empty()}.
196+
*/
161197
@Test(expectedExceptions = IllegalArgumentException.class)
162198
public void should_throw_exception_when_username_not_specified() {
163199
UsersService service = new UsersService(sessionStorageMock);
164200
service.username("");
165201
}
166-
@Deprecated
202+
203+
/**
204+
* @deprecated Replaced by {@link com.jaspersoft.jasperserver.jaxrs.client.apiadapters.authority.users.UsersServiceTest#should_return_proper_user_adapter_when_invoke_user_method_with_string()}.
205+
*/
167206
@Test
168207
public void should_return_proper_user_adapter_() throws Exception {
169208
UsersService service = new UsersService(sessionStorageMock);

0 commit comments

Comments
 (0)