Skip to content

Commit ce3fed3

Browse files
committed
Adding all the Get Notification Registration calls for each registration type. Added tests to verify that all the paths are correct.
1 parent ab78887 commit ce3fed3

14 files changed

+267
-31
lines changed

ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/NotificationsIntegration_test.java

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,66 @@ public static void startup() {
2929

3030
@Test
3131
public void objectCompletionRegistration() throws IOException, SignatureException {
32-
final CreateNotificationResponse response = client.createObjectCachedNotification(new CreateObjectCachedNotificationRequest("192.168.56.101"));
32+
final NotificationResponse response = client.createObjectCachedNotification(new CreateObjectCachedNotificationRequest("192.168.56.101"));
3333
assertThat(response, is(notNullValue()));
3434
assertThat(response.getRegistration(), is(notNullValue()));
3535

3636
final UUID registrationId = response.getRegistration().getId();
3737

38+
final NotificationResponse getResponse = client.getObjectCachedNotification(new GetObjectCachedNotificationRequest(registrationId));
39+
assertThat(getResponse, is(notNullValue()));
40+
assertThat(getResponse.getRegistration(), is(notNullValue()));
41+
assertThat(getResponse.getRegistration().getId(), is(notNullValue()));
42+
3843
assertThat(client.deleteObjectCachedNotification(new DeleteObjectCachedNotificationRequest(registrationId)), is(notNullValue()));
3944

4045
}
4146

4247
@Test
4348
public void jobCompletionRegistration() throws IOException, SignatureException {
44-
final CreateNotificationResponse response = client.createJobCompletedNotification(new CreateJobCompletedNotificationRequest("192.168.56.101/other"));
49+
final NotificationResponse response = client.createJobCompletedNotification(new CreateJobCompletedNotificationRequest("192.168.56.101/other"));
4550
assertThat(response, is(notNullValue()));
4651
assertThat(response.getRegistration(), is(notNullValue()));
4752

4853
final UUID registrationId = response.getRegistration().getId();
4954

55+
final NotificationResponse getResponse = client.getJobCompletedNotification(new GetJobCompletedNotificationRequest(registrationId));
56+
assertThat(getResponse, is(notNullValue()));
57+
assertThat(getResponse.getRegistration(), is(notNullValue()));
58+
assertThat(getResponse.getRegistration().getId(), is(notNullValue()));
59+
5060
assertThat(client.deleteJobCompleteNotification(new DeleteJobCompletedNotificationRequest(registrationId)), is(notNullValue()));
5161
}
5262

5363
@Test
5464
public void jobCreateRegistration() throws IOException, SignatureException {
55-
final CreateNotificationResponse response = client.createJobCreatedNotification(new CreateJobCreatedNotificationRequest("192.168.56.101/other"));
65+
final NotificationResponse response = client.createJobCreatedNotification(new CreateJobCreatedNotificationRequest("192.168.56.101/other"));
5666
assertThat(response, is(notNullValue()));
5767
assertThat(response.getRegistration(), is(notNullValue()));
5868

5969
final UUID registrationId = response.getRegistration().getId();
6070

71+
final NotificationResponse getResponse = client.getJobCreatedNotification(new GetJobCreatedNotificationRequest(registrationId));
72+
assertThat(getResponse, is(notNullValue()));
73+
assertThat(getResponse.getRegistration(), is(notNullValue()));
74+
assertThat(getResponse.getRegistration().getId(), is(notNullValue()));
75+
6176
assertThat(client.deleteJobCreatedNotification(new DeleteJobCreatedNotificationRequest(registrationId)), is(notNullValue()));
6277
}
6378

6479
@Test
6580
public void objectLostRegistration() throws IOException, SignatureException {
66-
final CreateNotificationResponse response = client.createObjectLostNotification(new CreateObjectLostNotificationRequest("192.168.56.101/other"));
81+
final NotificationResponse response = client.createObjectLostNotification(new CreateObjectLostNotificationRequest("192.168.56.101/other"));
6782
assertThat(response, is(notNullValue()));
6883
assertThat(response.getRegistration(), is(notNullValue()));
6984

7085
final UUID registrationId = response.getRegistration().getId();
7186

87+
final NotificationResponse getResponse = client.getObjectLostNotification(new GetObjectLostNotificationRequest(registrationId));
88+
assertThat(getResponse, is(notNullValue()));
89+
assertThat(getResponse.getRegistration(), is(notNullValue()));
90+
assertThat(getResponse.getRegistration().getId(), is(notNullValue()));
91+
7292
assertThat(client.deleteObjectLostNotification(new DeleteObjectLostNotificationRequest(registrationId)), is(notNullValue()));
7393
}
7494

@@ -80,18 +100,55 @@ public void objectPersistedRegistration() throws IOException, SignatureException
80100
client.putBucket(new PutBucketRequest(bucketName));
81101
final Ds3ClientHelpers.Job job = Util.getLoadJob(client, bucketName, Util.RESOURCE_BASE_NAME);
82102

83-
final CreateNotificationResponse response = client.createObjectPersistedNotification(new CreateObjectPersistedNotificationRequest("192.168.56.101/other", job.getJobId()));
103+
final NotificationResponse response = client.createObjectPersistedNotification(new CreateObjectPersistedNotificationRequest("192.168.56.101/other", job.getJobId()));
84104
assertThat(response, is(notNullValue()));
85105
assertThat(response.getRegistration(), is(notNullValue()));
86106

87107
job.transfer(new ResourceObjectPutter(Util.RESOURCE_BASE_NAME));
88108

89109
final UUID registrationId = response.getRegistration().getId();
90110

111+
final NotificationResponse getResponse = client.getObjectPersistedNotification(new GetObjectPersistedNotificationRequest(registrationId));
112+
assertThat(getResponse, is(notNullValue()));
113+
assertThat(getResponse.getRegistration(), is(notNullValue()));
114+
assertThat(getResponse.getRegistration().getId(), is(notNullValue()));
115+
91116
assertThat(client.deleteObjectPersistedNotification(new DeleteObjectPersistedNotificationRequest(registrationId)), is(notNullValue()));
92117
}
93118
finally {
94119
Util.deleteAllContents(client, bucketName);
95120
}
96121
}
122+
123+
@Test
124+
public void partitionFailureRegistration() throws IOException, SignatureException {
125+
final NotificationResponse response = client.createPartitionFailureNotification(new CreatePartitionFailureNotificationRequest("192.168.56.101/other"));
126+
assertThat(response, is(notNullValue()));
127+
assertThat(response.getRegistration(), is(notNullValue()));
128+
129+
final UUID registrationId = response.getRegistration().getId();
130+
131+
final NotificationResponse getResponse = client.getPartitionFailureNotification(new GetPartitionFailureNotificationRequest(registrationId));
132+
assertThat(getResponse, is(notNullValue()));
133+
assertThat(getResponse.getRegistration(), is(notNullValue()));
134+
assertThat(getResponse.getRegistration().getId(), is(notNullValue()));
135+
136+
assertThat(client.deletePartitionFailureNotification(new DeletePartitionFailureNotificationRequest(registrationId)), is(notNullValue()));
137+
}
138+
139+
@Test
140+
public void tapeFailureRegistration() throws IOException, SignatureException {
141+
final NotificationResponse response = client.createTapeFailureNotification(new CreateTapeFailureNotificationRequest("192.168.56.101/other"));
142+
assertThat(response, is(notNullValue()));
143+
assertThat(response.getRegistration(), is(notNullValue()));
144+
145+
final UUID registrationId = response.getRegistration().getId();
146+
147+
final NotificationResponse getResponse = client.getTapeFailureNotification(new GetTapeFailureNotificationRequest(registrationId));
148+
assertThat(getResponse, is(notNullValue()));
149+
assertThat(getResponse.getRegistration(), is(notNullValue()));
150+
assertThat(getResponse.getRegistration().getId(), is(notNullValue()));
151+
152+
assertThat(client.deleteTapeFailureNotification(new DeleteTapeFailureNotificationRequest(registrationId)), is(notNullValue()));
153+
}
97154
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3Client.java

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,43 +224,64 @@ public abstract CancelJobResponse cancelJob(CancelJobRequest request)
224224
public abstract ModifyJobResponse modifyJob(ModifyJobRequest request)
225225
throws IOException, SignatureException;
226226

227-
public abstract CreateNotificationResponse createObjectCachedNotification(CreateObjectCachedNotificationRequest request)
227+
public abstract NotificationResponse createObjectCachedNotification(CreateObjectCachedNotificationRequest request)
228+
throws IOException, SignatureException;
229+
230+
public abstract NotificationResponse getObjectCachedNotification(GetObjectCachedNotificationRequest request)
228231
throws IOException, SignatureException;
229232

230233
public abstract DeleteNotificationResponse deleteObjectCachedNotification(DeleteObjectCachedNotificationRequest request)
231234
throws IOException, SignatureException;
232235

233-
public abstract CreateNotificationResponse createJobCompletedNotification(CreateJobCompletedNotificationRequest request)
236+
public abstract NotificationResponse createJobCompletedNotification(CreateJobCompletedNotificationRequest request)
237+
throws IOException, SignatureException;
238+
239+
public abstract NotificationResponse getJobCompletedNotification(GetJobCompletedNotificationRequest request)
234240
throws IOException, SignatureException;
235241

236242
public abstract DeleteNotificationResponse deleteJobCompleteNotification(DeleteJobCompletedNotificationRequest request)
237243
throws IOException, SignatureException;
238244

239-
public abstract CreateNotificationResponse createJobCreatedNotification(CreateJobCreatedNotificationRequest request)
245+
public abstract NotificationResponse createJobCreatedNotification(CreateJobCreatedNotificationRequest request)
246+
throws IOException, SignatureException;
247+
248+
public abstract NotificationResponse getJobCreatedNotification(GetJobCreatedNotificationRequest request)
240249
throws IOException, SignatureException;
241250

242251
public abstract DeleteNotificationResponse deleteJobCreatedNotification(DeleteJobCreatedNotificationRequest request)
243252
throws IOException, SignatureException;
244253

245-
public abstract CreateNotificationResponse createObjectLostNotification(CreateObjectLostNotificationRequest request)
254+
public abstract NotificationResponse createObjectLostNotification(CreateObjectLostNotificationRequest request)
255+
throws IOException, SignatureException;
256+
257+
public abstract NotificationResponse getObjectLostNotification(GetObjectLostNotificationRequest request)
246258
throws IOException, SignatureException;
247259

248260
public abstract DeleteNotificationResponse deleteObjectLostNotification(DeleteObjectLostNotificationRequest request)
249261
throws IOException, SignatureException;
250262

251-
public abstract CreateNotificationResponse createObjectPersistedNotification(CreateObjectPersistedNotificationRequest request)
263+
public abstract NotificationResponse createObjectPersistedNotification(CreateObjectPersistedNotificationRequest request)
264+
throws IOException, SignatureException;
265+
266+
public abstract NotificationResponse getObjectPersistedNotification(GetObjectPersistedNotificationRequest request)
252267
throws IOException, SignatureException;
253268

254269
public abstract DeleteNotificationResponse deleteObjectPersistedNotification(DeleteObjectPersistedNotificationRequest request)
255270
throws IOException, SignatureException;
256271

257-
public abstract CreateNotificationResponse createPartitionFailureNotification(CreatePartitionFailureNotificationRequest request)
272+
public abstract NotificationResponse createPartitionFailureNotification(CreatePartitionFailureNotificationRequest request)
273+
throws IOException, SignatureException;
274+
275+
public abstract NotificationResponse getPartitionFailureNotification(GetPartitionFailureNotificationRequest request)
258276
throws IOException, SignatureException;
259277

260278
public abstract DeleteNotificationResponse deletePartitionFailureNotification(DeletePartitionFailureNotificationRequest request)
261279
throws IOException, SignatureException;
262280

263-
public abstract CreateNotificationResponse createTapeFailureNotification(CreateTapeFailureNotificationRequest request)
281+
public abstract NotificationResponse createTapeFailureNotification(CreateTapeFailureNotificationRequest request)
282+
throws IOException, SignatureException;
283+
284+
public abstract NotificationResponse getTapeFailureNotification(GetTapeFailureNotificationRequest request)
264285
throws IOException, SignatureException;
265286

266287
public abstract DeleteNotificationResponse deleteTapeFailureNotification(DeleteTapeFailureNotificationRequest request)

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,13 @@ public ModifyJobResponse modifyJob(final ModifyJobRequest request) throws IOExce
126126
}
127127

128128
@Override
129-
public CreateNotificationResponse createObjectCachedNotification(final CreateObjectCachedNotificationRequest request) throws IOException, SignatureException {
130-
return new CreateNotificationResponse(this.netClient.getResponse(request));
129+
public NotificationResponse createObjectCachedNotification(final CreateObjectCachedNotificationRequest request) throws IOException, SignatureException {
130+
return new NotificationResponse(this.netClient.getResponse(request));
131+
}
132+
133+
@Override
134+
public NotificationResponse getObjectCachedNotification(GetObjectCachedNotificationRequest request) throws IOException, SignatureException {
135+
return new NotificationResponse(this.netClient.getResponse(request));
131136
}
132137

133138
@Override
@@ -136,8 +141,13 @@ public DeleteNotificationResponse deleteObjectCachedNotification(final DeleteObj
136141
}
137142

138143
@Override
139-
public CreateNotificationResponse createJobCompletedNotification(final CreateJobCompletedNotificationRequest request) throws IOException, SignatureException {
140-
return new CreateNotificationResponse(this.netClient.getResponse(request));
144+
public NotificationResponse createJobCompletedNotification(final CreateJobCompletedNotificationRequest request) throws IOException, SignatureException {
145+
return new NotificationResponse(this.netClient.getResponse(request));
146+
}
147+
148+
@Override
149+
public NotificationResponse getJobCompletedNotification(GetJobCompletedNotificationRequest request) throws IOException, SignatureException {
150+
return new NotificationResponse(this.netClient.getResponse(request));
141151
}
142152

143153
@Override
@@ -146,8 +156,13 @@ public DeleteNotificationResponse deleteJobCompleteNotification(final DeleteJobC
146156
}
147157

148158
@Override
149-
public CreateNotificationResponse createJobCreatedNotification(CreateJobCreatedNotificationRequest request) throws IOException, SignatureException {
150-
return new CreateNotificationResponse(this.netClient.getResponse(request));
159+
public NotificationResponse createJobCreatedNotification(CreateJobCreatedNotificationRequest request) throws IOException, SignatureException {
160+
return new NotificationResponse(this.netClient.getResponse(request));
161+
}
162+
163+
@Override
164+
public NotificationResponse getJobCreatedNotification(GetJobCreatedNotificationRequest request) throws IOException, SignatureException {
165+
return new NotificationResponse(this.netClient.getResponse(request));
151166
}
152167

153168
@Override
@@ -156,8 +171,13 @@ public DeleteNotificationResponse deleteJobCreatedNotification(DeleteJobCreatedN
156171
}
157172

158173
@Override
159-
public CreateNotificationResponse createObjectLostNotification(CreateObjectLostNotificationRequest request) throws IOException, SignatureException {
160-
return new CreateNotificationResponse(this.netClient.getResponse(request));
174+
public NotificationResponse createObjectLostNotification(CreateObjectLostNotificationRequest request) throws IOException, SignatureException {
175+
return new NotificationResponse(this.netClient.getResponse(request));
176+
}
177+
178+
@Override
179+
public NotificationResponse getObjectLostNotification(GetObjectLostNotificationRequest request) throws IOException, SignatureException {
180+
return new NotificationResponse(this.netClient.getResponse(request));
161181
}
162182

163183
@Override
@@ -166,8 +186,13 @@ public DeleteNotificationResponse deleteObjectLostNotification(DeleteObjectLostN
166186
}
167187

168188
@Override
169-
public CreateNotificationResponse createObjectPersistedNotification(CreateObjectPersistedNotificationRequest request) throws IOException, SignatureException {
170-
return new CreateNotificationResponse(this.netClient.getResponse(request));
189+
public NotificationResponse createObjectPersistedNotification(CreateObjectPersistedNotificationRequest request) throws IOException, SignatureException {
190+
return new NotificationResponse(this.netClient.getResponse(request));
191+
}
192+
193+
@Override
194+
public NotificationResponse getObjectPersistedNotification(GetObjectPersistedNotificationRequest request) throws IOException, SignatureException {
195+
return new NotificationResponse(this.netClient.getResponse(request));
171196
}
172197

173198
@Override
@@ -176,8 +201,13 @@ public DeleteNotificationResponse deleteObjectPersistedNotification(DeleteObject
176201
}
177202

178203
@Override
179-
public CreateNotificationResponse createPartitionFailureNotification(CreatePartitionFailureNotificationRequest request) throws IOException, SignatureException {
180-
return new CreateNotificationResponse(this.netClient.getResponse(request));
204+
public NotificationResponse createPartitionFailureNotification(CreatePartitionFailureNotificationRequest request) throws IOException, SignatureException {
205+
return new NotificationResponse(this.netClient.getResponse(request));
206+
}
207+
208+
@Override
209+
public NotificationResponse getPartitionFailureNotification(GetPartitionFailureNotificationRequest request) throws IOException, SignatureException {
210+
return new NotificationResponse(this.netClient.getResponse(request));
181211
}
182212

183213
@Override
@@ -186,8 +216,13 @@ public DeleteNotificationResponse deletePartitionFailureNotification(DeleteParti
186216
}
187217

188218
@Override
189-
public CreateNotificationResponse createTapeFailureNotification(CreateTapeFailureNotificationRequest request) throws IOException, SignatureException {
190-
return new CreateNotificationResponse(this.netClient.getResponse(request));
219+
public NotificationResponse createTapeFailureNotification(CreateTapeFailureNotificationRequest request) throws IOException, SignatureException {
220+
return new NotificationResponse(this.netClient.getResponse(request));
221+
}
222+
223+
@Override
224+
public NotificationResponse getTapeFailureNotification(GetTapeFailureNotificationRequest request) throws IOException, SignatureException {
225+
return new NotificationResponse(this.netClient.getResponse(request));
191226
}
192227

193228
@Override
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.spectralogic.ds3client.commands.notifications;
2+
3+
import com.spectralogic.ds3client.HttpVerb;
4+
import com.spectralogic.ds3client.commands.AbstractRequest;
5+
6+
import java.util.UUID;
7+
8+
public abstract class AbstractGetNotificationRequest extends AbstractRequest {
9+
10+
private final UUID notificationId;
11+
12+
public AbstractGetNotificationRequest(final UUID notificationId) {
13+
super();
14+
this.notificationId = notificationId;
15+
}
16+
17+
@Override
18+
public HttpVerb getVerb() {
19+
return HttpVerb.GET;
20+
}
21+
22+
public UUID getNotificationId() {
23+
return notificationId;
24+
}
25+
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/notifications/CreateObjectPersistedNotificationRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public CreateObjectPersistedNotificationRequest(final String endpoint, final UUI
1111

1212
@Override
1313
public String getPath() {
14-
return "/_rest_/object_persisted_notification_registration";
14+
return "/_rest_/object_persisted_notification_registration/";
1515
}
1616

1717
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/notifications/DeleteObjectPersistedNotificationRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public DeleteObjectPersistedNotificationRequest(final UUID notificationId) {
1111

1212
@Override
1313
public String getPath() {
14-
return "/_rest_/job_completed_notification_registration/" + this.getNotificationId().toString();
14+
return "/_rest_/object_persisted_notification_registration/" + this.getNotificationId().toString();
1515
}
1616
}

0 commit comments

Comments
 (0)