2 * This document is a part of the source code and related artifacts
3 * for CollectionSpace, an open source collections management system
4 * for museums and related institutions:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright © 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 package org.collectionspace.services.account.client.test;
25 import java.util.List;
26 import javax.ws.rs.core.Response;
28 import org.collectionspace.services.client.AccountClient;
29 import org.collectionspace.services.client.CollectionSpaceClient;
30 import org.collectionspace.services.account.AccountsCommon;
31 import org.collectionspace.services.account.AccountsCommonList;
32 import org.collectionspace.services.account.AccountListItem;
34 import org.collectionspace.services.account.Status;
35 import org.collectionspace.services.client.AccountFactory;
36 import org.collectionspace.services.client.test.AbstractServiceTestImpl;
37 import org.collectionspace.services.client.test.ServiceRequestType;
38 import org.collectionspace.services.jaxb.AbstractCommonList;
39 import org.jboss.resteasy.client.ClientResponse;
41 import org.testng.Assert;
42 import org.testng.annotations.Test;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
48 * AccountServiceTest, carries out tests against a
49 * deployed and running Account Service.
51 * $LastChangedRevision: 917 $
52 * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
54 public class AccountServiceTest extends AbstractServiceTestImpl {
56 /** The Constant logger. */
57 private final String CLASS_NAME = AccountServiceTest.class.getName();
58 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
59 // Instance variables specific to this test.
60 /** The known resource id. */
61 private String knownResourceId = null;
62 private String prebuiltAdminCSID = null;
63 private String prebuiltAdminUserId = "admin@core.collectionspace.org";
64 private String knownUserId = "barney";
65 private String knownUserPassword = "hithere08";
66 /** The add tenant. */
67 static boolean addTenant = true;
70 public String getServiceName() {
71 return AccountClient.SERVICE_NAME;
75 * This method is called only by the parent class, AbstractServiceTestImpl
78 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
81 protected String getServicePathComponent() {
82 return new AccountClient().getServicePathComponent();
86 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
89 protected CollectionSpaceClient getClientInstance() {
90 return new AccountClient();
94 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
97 protected AbstractCommonList getAbstractCommonList(
98 ClientResponse<AbstractCommonList> response) {
99 //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
100 throw new UnsupportedOperationException();
104 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
106 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
107 dependsOnMethods = {"readList"})
109 public void readPaginatedList(String testName) throws Exception {
110 //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
113 // ---------------------------------------------------------------
114 // CRUD tests : CREATE tests
115 // ---------------------------------------------------------------
118 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
121 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
122 public void create(String testName) throws Exception {
124 if (logger.isDebugEnabled()) {
125 logger.debug(testBanner(testName, CLASS_NAME));
127 // Perform setup, such as initializing the type of service request
128 // (e.g. CREATE, DELETE), its valid and expected status codes, and
129 // its associated HTTP method name (e.g. POST, DELETE).
132 AccountClient client = new AccountClient();
133 // Submit the request to the service and store the response.
134 AccountsCommon account =
135 createAccountInstance(knownUserId, knownUserId, knownUserPassword,
136 "barney@dinoland.com", client.getTenantId(),
137 true, false, true, true);
138 ClientResponse<Response> res = client.create(account);
139 int statusCode = res.getStatus();
141 // Check the status code of the response: does it match
142 // the expected response(s)?
145 // Does it fall within the set of valid status codes?
146 // Does it exactly match the expected status code?
147 if (logger.isDebugEnabled()) {
148 logger.debug(testName + ": status = " + statusCode);
150 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
151 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
152 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
154 // Store the ID returned from this create operation
155 // for additional tests below.
156 knownResourceId = extractId(res);
157 if (logger.isDebugEnabled()) {
158 logger.debug(testName + ": knownResourceId=" + knownResourceId);
163 * Creates the for unique user.
165 * @param testName the test name
166 * @throws Exception the exception
168 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
169 dependsOnMethods = {"create"})
170 public void createForUniqueUser(String testName) throws Exception {
172 if (logger.isDebugEnabled()) {
173 logger.debug(testBanner(testName, CLASS_NAME));
177 // Submit the request to the service and store the response.
178 AccountClient client = new AccountClient();
179 AccountsCommon account =
180 createAccountInstance("barney1", knownUserId, knownUserPassword,
181 "barney@dinoland.com",
182 client.getTenantId(), true, false, true, true);
184 ClientResponse<Response> res = client.create(account);
185 int statusCode = res.getStatus();
186 if (logger.isDebugEnabled()) {
187 logger.debug(testName + ": status = " + statusCode);
189 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
190 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
191 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
195 * Creates the with invalid tenant.
197 * @param testName the test name
198 * @throws Exception the exception
200 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
201 dependsOnMethods = {"create"})
202 public void createWithInvalidTenant(String testName) throws Exception {
204 if (logger.isDebugEnabled()) {
205 logger.debug(testBanner(testName, CLASS_NAME));
209 // Submit the request to the service and store the response.
210 AccountClient client = new AccountClient();
211 AccountsCommon account =
212 createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
213 client.getTenantId(), true, true, true, true);
214 ClientResponse<Response> res = client.create(account);
215 int statusCode = res.getStatus();
216 // Does it exactly match the expected status code?
217 if (logger.isDebugEnabled()) {
218 logger.debug(testName + ": status = " + statusCode);
220 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
221 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
222 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
227 * Creates the without user.
229 * @param testName the test name
230 * @throws Exception the exception
232 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
233 dependsOnMethods = {"create"})
234 public void createWithoutUser(String testName) throws Exception {
236 if (logger.isDebugEnabled()) {
237 logger.debug(testBanner(testName, CLASS_NAME));
241 // Submit the request to the service and store the response.
242 AccountClient client = new AccountClient();
243 AccountsCommon account =
244 createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
245 client.getTenantId(), true, false, false, true);
246 ClientResponse<Response> res = client.create(account);
247 int statusCode = res.getStatus();
248 // Does it exactly match the expected status code?
249 if (logger.isDebugEnabled()) {
250 logger.debug(testName + ": status = " + statusCode);
252 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
253 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
254 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
258 * Creates the with invalid email.
260 * @param testName the test name
261 * @throws Exception the exception
263 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
264 dependsOnMethods = {"create"})
265 public void createWithInvalidEmail(String testName) throws Exception {
267 if (logger.isDebugEnabled()) {
268 logger.debug(testBanner(testName, CLASS_NAME));
272 // Submit the request to the service and store the response.
273 AccountClient client = new AccountClient();
274 AccountsCommon account =
275 createAccountInstance("babybop", "babybop", "hithere08", "babybop.dinoland.com",
276 client.getTenantId(), true, false, true, true);
277 ClientResponse<Response> res = client.create(account);
278 int statusCode = res.getStatus();
279 // Does it exactly match the expected status code?
280 if (logger.isDebugEnabled()) {
281 logger.debug(testName + ": status = " + statusCode);
283 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
284 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
285 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
289 * Creates the without screen name.
291 * @param testName the test name
292 * @throws Exception the exception
294 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
295 dependsOnMethods = {"create"})
296 public void createWithoutScreenName(String testName) throws Exception {
298 if (logger.isDebugEnabled()) {
299 logger.debug(testBanner(testName, CLASS_NAME));
303 // Submit the request to the service and store the response.
304 AccountClient client = new AccountClient();
305 AccountsCommon account =
306 createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
307 client.getTenantId(), false, false, true, true);
308 ClientResponse<Response> res = client.create(account);
309 int statusCode = res.getStatus();
310 // Does it exactly match the expected status code?
311 if (logger.isDebugEnabled()) {
312 logger.debug(testName + ": status = " + statusCode);
314 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
315 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
316 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
320 * Creates the with invalid password.
322 * @param testName the test name
323 * @throws Exception the exception
325 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
326 dependsOnMethods = {"create"})
327 public void createWithInvalidPassword(String testName) throws Exception {
329 if (logger.isDebugEnabled()) {
330 logger.debug(testBanner(testName, CLASS_NAME));
334 // Submit the request to the service and store the response.
335 AccountClient client = new AccountClient();
336 AccountsCommon account =
337 createAccountInstance("babybop", "babybop", "shpswd", "babybop@dinoland.com",
338 client.getTenantId(), true, false, true, true);
339 ClientResponse<Response> res = client.create(account);
340 int statusCode = res.getStatus();
341 // Does it exactly match the expected status code?
342 if (logger.isDebugEnabled()) {
343 logger.debug(testName + ": status = " + statusCode);
345 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
346 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
347 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
351 * Creates the with most invalid.
353 * @param testName the test name
354 * @throws Exception the exception
356 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
357 dependsOnMethods = {"create"})
358 public void createWithMostInvalid(String testName) throws Exception {
360 if (logger.isDebugEnabled()) {
361 logger.debug(testBanner(testName, CLASS_NAME));
365 // Submit the request to the service and store the response.
366 AccountClient client = new AccountClient();
367 AccountsCommon account =
368 createAccountInstance("babybop", "babybop", "hithere08", "babybop/dinoland.com",
369 client.getTenantId(), false, true, false, false);
370 ClientResponse<Response> res = client.create(account);
371 int statusCode = res.getStatus();
372 // Does it exactly match the expected status code?
373 if (logger.isDebugEnabled()) {
374 logger.debug(testName + ": status = " + statusCode);
376 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
377 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
378 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
381 //to not cause uniqueness violation for account, createList is removed
383 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
386 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
387 dependsOnMethods = {"create"})
388 public void createList(String testName) throws Exception {
390 if (logger.isDebugEnabled()) {
391 logger.debug(testBanner(testName, CLASS_NAME));
394 // Submit the request to the service and store the response.
395 AccountClient client = new AccountClient();
396 AccountsCommon account1 =
397 createAccountInstance("curious", "curious", "hithere08", "curious@george.com",
398 client.getTenantId(), true, false, true, true);
399 ClientResponse<Response> res = client.create(account1);
400 int statusCode = res.getStatus();
401 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
402 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
403 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
404 allResourceIdsCreated.add(extractId(res));
406 AccountsCommon account2 =
407 createAccountInstance("tom", "tom", "hithere09", "tom@jerry.com",
408 client.getTenantId(), true, false, true, true);
409 res = client.create(account2);
410 statusCode = res.getStatus();
411 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
412 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
413 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
414 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
415 allResourceIdsCreated.add(extractId(res));
417 AccountsCommon account3 =
418 createAccountInstance("mj", "mj", "hithere10", "mj@dinoland.com",
419 client.getTenantId(), true, false, true, true);
420 res = client.create(account3);
421 statusCode = res.getStatus();
422 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
423 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
424 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
425 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
426 allResourceIdsCreated.add(extractId(res));
430 // Placeholders until the three tests below can be uncommented.
431 // See Issue CSPACE-401.
433 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
436 public void createWithEmptyEntityBody(String testName) throws Exception {
437 //FIXME: Should this test really be empty? If so, please comment accordingly.
441 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
444 public void createWithMalformedXml(String testName) throws Exception {
445 //FIXME: Should this test really be empty? If so, please comment accordingly.
449 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
452 public void createWithWrongXmlSchema(String testName) throws Exception {
453 //FIXME: Should this test really be empty? If so, please comment accordingly.
456 // ---------------------------------------------------------------
457 // CRUD tests : READ tests
458 // ---------------------------------------------------------------
461 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
464 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
465 dependsOnMethods = {"create"})
466 public void read(String testName) throws Exception {
468 if (logger.isDebugEnabled()) {
469 logger.debug(testBanner(testName, CLASS_NAME));
474 // Submit the request to the service and store the response.
475 AccountClient client = new AccountClient();
476 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
477 int statusCode = res.getStatus();
479 // Check the status code of the response: does it match
480 // the expected response(s)?
481 if (logger.isDebugEnabled()) {
482 logger.debug(testName + ": status = " + statusCode);
484 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
485 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
486 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
488 AccountsCommon output = (AccountsCommon) res.getEntity();
489 Assert.assertNotNull(output);
494 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
497 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
498 dependsOnMethods = {"read"})
499 public void readNonExistent(String testName) throws Exception {
501 if (logger.isDebugEnabled()) {
502 logger.debug(testBanner(testName, CLASS_NAME));
505 setupReadNonExistent();
507 // Submit the request to the service and store the response.
508 AccountClient client = new AccountClient();
509 ClientResponse<AccountsCommon> res = client.read(NON_EXISTENT_ID);
510 int statusCode = res.getStatus();
512 // Check the status code of the response: does it match
513 // the expected response(s)?
514 if (logger.isDebugEnabled()) {
515 logger.debug(testName + ": status = " + statusCode);
517 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
518 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
519 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
522 // ---------------------------------------------------------------
523 // CRUD tests : READ_LIST tests
524 // ---------------------------------------------------------------
527 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
530 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
531 dependsOnMethods = {"createList", "read"})
532 public void readList(String testName) throws Exception {
534 if (logger.isDebugEnabled()) {
535 logger.debug(testBanner(testName, CLASS_NAME));
540 // Submit the request to the service and store the response.
541 AccountClient client = new AccountClient();
542 ClientResponse<AccountsCommonList> res = client.readList();
543 AccountsCommonList list = res.getEntity();
544 int statusCode = res.getStatus();
546 // Check the status code of the response: does it match
547 // the expected response(s)?
548 if (logger.isDebugEnabled()) {
549 logger.debug(testName + ": status = " + statusCode);
551 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
552 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
553 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
555 // Optionally output additional data about list members for debugging.
556 boolean iterateThroughList = true;
557 if (iterateThroughList && logger.isDebugEnabled()) {
558 printList(testName, list);
563 * Search screen name.
565 * @param testName the test name
566 * @throws Exception the exception
568 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
569 dependsOnMethods = {"createList", "read"})
570 public void searchScreenName(String testName) throws Exception {
572 if (logger.isDebugEnabled()) {
573 logger.debug(testBanner(testName, CLASS_NAME));
578 // Submit the request to the service and store the response.
579 AccountClient client = new AccountClient();
580 ClientResponse<AccountsCommonList> res =
581 client.readSearchList("tom", null, null);
582 AccountsCommonList list = res.getEntity();
583 int statusCode = res.getStatus();
585 // Check the status code of the response: does it match
586 // the expected response(s)?
587 if (logger.isDebugEnabled()) {
588 logger.debug(testName + ": status = " + statusCode);
590 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
591 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
592 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
593 Assert.assertEquals(1, list.getAccountListItem().size());
594 // Optionally output additional data about list members for debugging.
595 boolean iterateThroughList = true;
596 if (iterateThroughList && logger.isDebugEnabled()) {
597 printList(testName, list);
604 * @param testName the test name
605 * @throws Exception the exception
607 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
608 dependsOnMethods = {"createList", "read"})
609 public void searchUserId(String testName) throws Exception {
611 if (logger.isDebugEnabled()) {
612 logger.debug(testBanner(testName, CLASS_NAME));
617 // Submit the request to the service and store the response.
618 AccountClient client = new AccountClient();
619 ClientResponse<AccountsCommonList> res =
620 client.readSearchList(null, "tom", null);
621 AccountsCommonList list = res.getEntity();
622 int statusCode = res.getStatus();
624 // Check the status code of the response: does it match
625 // the expected response(s)?
626 if (logger.isDebugEnabled()) {
627 logger.debug(testName + ": status = " + statusCode);
629 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
630 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
631 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
632 Assert.assertEquals(1, list.getAccountListItem().size());
633 // Optionally output additional data about list members for debugging.
634 boolean iterateThroughList = true;
635 if (iterateThroughList && logger.isDebugEnabled()) {
636 printList(testName, list);
643 * @param testName the test name
644 * @throws Exception the exception
646 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
647 dependsOnMethods = {"createList", "read"})
648 public void searchEmail(String testName) throws Exception {
650 if (logger.isDebugEnabled()) {
651 logger.debug(testBanner(testName, CLASS_NAME));
656 // Submit the request to the service and store the response.
657 AccountClient client = new AccountClient();
658 ClientResponse<AccountsCommonList> res =
659 client.readSearchList(null, null, "dinoland");
660 AccountsCommonList list = res.getEntity();
661 int statusCode = res.getStatus();
663 // Check the status code of the response: does it match
664 // the expected response(s)?
665 if (logger.isDebugEnabled()) {
666 logger.debug(testName + ": status = " + statusCode);
668 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
669 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
670 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
671 Assert.assertEquals(2, list.getAccountListItem().size());
672 // Optionally output additional data about list members for debugging.
673 boolean iterateThroughList = true;
674 if (iterateThroughList && logger.isDebugEnabled()) {
675 printList(testName, list);
680 * Search screen name email.
682 * @param testName the test name
683 * @throws Exception the exception
685 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
686 dependsOnMethods = {"createList", "read"})
687 public void searchScreenNameEmail(String testName) throws Exception {
689 if (logger.isDebugEnabled()) {
690 logger.debug(testBanner(testName, CLASS_NAME));
695 // Submit the request to the service and store the response.
696 AccountClient client = new AccountClient();
697 ClientResponse<AccountsCommonList> res =
698 client.readSearchList("tom", null, "jerry");
699 AccountsCommonList list = res.getEntity();
700 int statusCode = res.getStatus();
702 // Check the status code of the response: does it match
703 // the expected response(s)?
704 if (logger.isDebugEnabled()) {
705 logger.debug(testName + ": status = " + statusCode);
707 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
708 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
709 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
710 Assert.assertEquals(1, list.getAccountListItem().size());
711 // Optionally output additional data about list members for debugging.
712 boolean iterateThroughList = true;
713 if (iterateThroughList && logger.isDebugEnabled()) {
714 printList(testName, list);
720 // ---------------------------------------------------------------
721 // CRUD tests : UPDATE tests
722 // ---------------------------------------------------------------
725 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
728 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
729 dependsOnMethods = {"read", "readList", "readNonExistent"})
730 public void update(String testName) throws Exception {
732 if (logger.isDebugEnabled()) {
733 logger.debug(testBanner(testName, CLASS_NAME));
738 AccountClient client = new AccountClient();
739 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
740 if (logger.isDebugEnabled()) {
741 logger.debug(testName + ": read status = " + res.getStatus());
743 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
745 if (logger.isDebugEnabled()) {
746 logger.debug("got object to update with ID: " + knownResourceId);
748 AccountsCommon accountFound =
749 (AccountsCommon) res.getEntity();
750 Assert.assertNotNull(accountFound);
752 //create a new account object to test partial updates
753 AccountsCommon accountToUpdate = new AccountsCommon();
754 accountToUpdate.setCsid(knownResourceId);
755 accountToUpdate.setUserId(accountFound.getUserId());
756 // Update the content of this resource.
757 accountToUpdate.setEmail("updated-" + accountFound.getEmail());
758 if (logger.isDebugEnabled()) {
759 logger.debug("updated object");
760 logger.debug(objectAsXmlString(accountFound,
761 AccountsCommon.class));
764 // Submit the request to the service and store the response.
765 res = client.update(knownResourceId, accountToUpdate);
766 int statusCode = res.getStatus();
767 // Check the status code of the response: does it match the expected response(s)?
768 if (logger.isDebugEnabled()) {
769 logger.debug(testName + ": status = " + statusCode);
771 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
772 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
773 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
775 AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
776 Assert.assertNotNull(accountUpdated);
778 Assert.assertEquals(accountUpdated.getEmail(),
779 accountToUpdate.getEmail(),
780 "Data in updated object did not match submitted data.");
786 * @param testName the test name
787 * @throws Exception the exception
789 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
790 dependsOnMethods = {"update"})
791 public void updatePassword(String testName) throws Exception {
793 if (logger.isDebugEnabled()) {
794 logger.debug(testBanner(testName, CLASS_NAME));
799 AccountClient client = new AccountClient();
800 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
801 if (logger.isDebugEnabled()) {
802 logger.debug(testName + ": read status = " + res.getStatus());
804 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
806 if (logger.isDebugEnabled()) {
807 logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
809 AccountsCommon accountFound =
810 (AccountsCommon) res.getEntity();
811 Assert.assertNotNull(accountFound);
813 //create a new account object to test partial updates
814 AccountsCommon accountToUpdate = new AccountsCommon();
815 accountToUpdate.setCsid(knownResourceId);
816 accountToUpdate.setUserId(accountFound.getUserId());
818 accountToUpdate.setPassword("imagination".getBytes());
819 if (logger.isDebugEnabled()) {
820 logger.debug(testName + ": updated object");
821 logger.debug(objectAsXmlString(accountToUpdate,
822 AccountsCommon.class));
825 // Submit the request to the service and store the response.
826 res = client.update(knownResourceId, accountToUpdate);
827 int statusCode = res.getStatus();
828 // Check the status code of the response: does it match the expected response(s)?
829 if (logger.isDebugEnabled()) {
830 logger.debug(testName + ": status = " + statusCode);
832 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
833 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
834 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
837 AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
838 Assert.assertNotNull(accountUpdated);
840 // Assert.assertEquals(accountUpdated.getPassword(),
841 // accountFound.getPassword(),
842 // "Data in updated object did not match submitted data.");
846 * Update password without user.
848 * @param testName the test name
849 * @throws Exception the exception
851 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
852 dependsOnMethods = {"update"})
853 public void updatePasswordWithoutUser(String testName) throws Exception {
855 if (logger.isDebugEnabled()) {
856 logger.debug(testBanner(testName, CLASS_NAME));
861 AccountsCommon accountToUpdate = new AccountsCommon();
862 accountToUpdate.setCsid(knownResourceId);
863 accountToUpdate.setUserId(null);
865 accountToUpdate.setPassword("imagination".getBytes());
866 if (logger.isDebugEnabled()) {
867 logger.debug(testName + " : updated object");
868 logger.debug(objectAsXmlString(accountToUpdate,
869 AccountsCommon.class));
872 AccountClient client = new AccountClient();
873 // Submit the request to the service and store the response.
874 ClientResponse<AccountsCommon> res = client.update(knownResourceId, accountToUpdate);
875 int statusCode = res.getStatus();
876 // Check the status code of the response: does it match the expected response(s)?
877 if (logger.isDebugEnabled()) {
878 logger.debug(testName + ": status = " + statusCode);
880 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
881 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
882 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
887 * Update invalid password.
889 * @param testName the test name
890 * @throws Exception the exception
892 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
893 dependsOnMethods = {"update"})
894 public void updateInvalidPassword(String testName) throws Exception {
896 if (logger.isDebugEnabled()) {
897 logger.debug(testBanner(testName, CLASS_NAME));
901 AccountClient client = new AccountClient();
902 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
903 if (logger.isDebugEnabled()) {
904 logger.debug(testName + ": read status = " + res.getStatus());
906 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
908 if (logger.isDebugEnabled()) {
909 logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
911 AccountsCommon accountFound = (AccountsCommon) res.getEntity();
913 AccountsCommon accountToUpdate = new AccountsCommon();
914 accountToUpdate.setCsid(knownResourceId);
915 accountToUpdate.setUserId(accountFound.getUserId());
916 Assert.assertNotNull(accountToUpdate);
919 accountToUpdate.setPassword("abc123".getBytes());
920 if (logger.isDebugEnabled()) {
921 logger.debug(testName + ": updated object");
922 logger.debug(objectAsXmlString(accountToUpdate,
923 AccountsCommon.class));
926 // Submit the request to the service and store the response.
927 res = client.update(knownResourceId, accountToUpdate);
928 int statusCode = res.getStatus();
929 // Check the status code of the response: does it match the expected response(s)?
930 if (logger.isDebugEnabled()) {
931 logger.debug(testName + ": status = " + statusCode);
933 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
934 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
935 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
939 private void findPrebuiltAdminAccount() {
940 // Search for the prebuilt admin user and then hold its CSID
941 if(prebuiltAdminCSID == null) {
943 AccountClient client = new AccountClient();
944 ClientResponse<AccountsCommonList> res =
945 client.readSearchList(null, this.prebuiltAdminUserId, null);
946 AccountsCommonList list = res.getEntity();
947 int statusCode = res.getStatus();
949 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
950 List<AccountListItem> items = list.getAccountListItem();
951 Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
952 AccountListItem item = items.get(0);
953 prebuiltAdminCSID = item.getCsid();
954 if (logger.isDebugEnabled()) {
955 logger.debug("Found Admin Account with ID: " + prebuiltAdminCSID);
960 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
961 dependsOnMethods = {"read", "readList", "readNonExistent"})
962 public void verifyMetadataProtection(String testName) throws Exception {
963 findPrebuiltAdminAccount();
964 // Try to update the metadata - it should just get ignored
965 if (logger.isDebugEnabled()) {
966 logger.debug(testBanner(testName, CLASS_NAME));
971 AccountClient client = new AccountClient();
972 ClientResponse<AccountsCommon> res = client.read(prebuiltAdminCSID);
973 if (logger.isDebugEnabled()) {
974 logger.debug(testName + ": read status = " + res.getStatus());
976 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
978 if (logger.isDebugEnabled()) {
979 logger.debug("Did get on Admin Account to update with ID: " + prebuiltAdminCSID);
981 AccountsCommon accountFound = (AccountsCommon) res.getEntity();
982 Assert.assertNotNull(accountFound);
984 //create a new account object to test partial updates
985 AccountsCommon accountToUpdate = new AccountsCommon();
986 accountToUpdate.setCsid(prebuiltAdminCSID);
987 accountToUpdate.setUserId(accountFound.getUserId());
988 // Update the content of this resource.
989 accountToUpdate.setEmail("updated-" + accountFound.getEmail());
990 if (logger.isDebugEnabled()) {
991 logger.debug("updated object");
992 logger.debug(objectAsXmlString(accountFound,
993 AccountsCommon.class));
996 // Submit the request to the service and store the response.
997 res = client.update(prebuiltAdminCSID, accountToUpdate);
998 int statusCode = res.getStatus();
999 // Check the status code of the response: does it match the expected response(s)?
1000 if (logger.isDebugEnabled()) {
1001 logger.debug(testName + ": status = " + statusCode);
1003 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1004 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1005 // Note that the error is not returned, it is just ignored
1006 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1008 AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
1009 Assert.assertNotNull(accountUpdated);
1011 Assert.assertFalse(accountUpdated.getEmail().equals(accountToUpdate.getEmail()),
1012 "Admin Account (with metadata lock) allowed update to change the email!");
1016 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1017 dependsOnMethods = {"read", "readList", "readNonExistent"})
1018 public void verifyProtectionReadOnly(String testName) throws Exception {
1020 if (logger.isDebugEnabled()) {
1021 logger.debug(testBanner(testName, CLASS_NAME));
1026 // Submit the request to the service and store the response.
1027 AccountClient client = new AccountClient();
1028 AccountsCommon account =
1029 createAccountInstance("mdTest", "mdTest", "mdTestPW", "md@test.com",
1030 client.getTenantId(), true, false, true, true);
1031 account.setMetadataProtection(AccountClient.IMMUTABLE);
1032 account.setRolesProtection(AccountClient.IMMUTABLE);
1033 ClientResponse<Response> res = client.create(account);
1034 int statusCode = res.getStatus();
1035 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1036 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1037 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1039 // Store the ID returned from this create operation
1040 // for additional tests below.
1041 String testResourceId = extractId(res);
1042 allResourceIdsCreated.add(testResourceId);
1043 if (logger.isDebugEnabled()) {
1044 logger.debug(testName + ": testResourceId=" + testResourceId);
1048 // Submit the request to the service and store the response.
1049 ClientResponse<AccountsCommon> accountRes = client.read(testResourceId);
1050 statusCode = accountRes.getStatus();
1052 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1053 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1054 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1056 AccountsCommon accountRead = (AccountsCommon) accountRes.getEntity();
1057 Assert.assertNotNull(accountRead);
1058 String mdProtection = accountRead.getMetadataProtection();
1059 String rolesProtection = accountRead.getRolesProtection();
1060 if (logger.isTraceEnabled()) {
1061 logger.trace(testName + ": metadataProtection=" + mdProtection);
1062 logger.trace(testName + ": rolesProtection=" + rolesProtection);
1064 Assert.assertFalse(account.getMetadataProtection().equals(mdProtection),
1065 "Account allowed create to set the metadata protection flag.");
1066 Assert.assertFalse(account.getRolesProtection().equals(rolesProtection),
1067 "Account allowed create to set the perms protection flag.");
1071 AccountsCommon accountToUpdate =
1072 createAccountInstance("mdTest", "mdTest", "mdTestPW", "md@test.com",
1073 client.getTenantId(), true, false, true, true);
1074 accountToUpdate.setMetadataProtection(AccountClient.IMMUTABLE);
1075 accountToUpdate.setRolesProtection(AccountClient.IMMUTABLE);
1077 // Submit the request to the service and store the response.
1078 accountRes = client.update(testResourceId, accountToUpdate);
1079 statusCode = accountRes.getStatus();
1080 // Check the status code of the response: does it match the expected response(s)?
1081 if (logger.isDebugEnabled()) {
1082 logger.debug(testName + ": status = " + statusCode);
1084 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1085 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1086 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1089 AccountsCommon accountUpdated = (AccountsCommon) accountRes.getEntity();
1090 Assert.assertNotNull(accountUpdated);
1091 if (logger.isDebugEnabled()) {
1092 logger.debug(testName + "Updated account: ");
1093 logger.debug(objectAsXmlString(accountUpdated,AccountsCommon.class));
1097 AccountClient.IMMUTABLE.equalsIgnoreCase(accountUpdated.getMetadataProtection()),
1098 "Account allowed update of the metadata protection flag.");
1100 AccountClient.IMMUTABLE.equalsIgnoreCase(accountUpdated.getRolesProtection()),
1101 "Account allowed update of the roles protection flag.");
1109 * @param testName the test name
1110 * @throws Exception the exception
1112 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1113 dependsOnMethods = {"updatePasswordWithoutUser"})
1114 public void deactivate(String testName) throws Exception {
1116 if (logger.isDebugEnabled()) {
1117 logger.debug(testBanner(testName, CLASS_NAME));
1122 AccountClient client = new AccountClient();
1123 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
1124 if (logger.isDebugEnabled()) {
1125 logger.debug(testName + ": read status = " + res.getStatus());
1127 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1129 if (logger.isDebugEnabled()) {
1130 logger.debug("got object to update with ID: " + knownResourceId);
1132 AccountsCommon accountFound = (AccountsCommon) res.getEntity();
1134 //create a new account object to test partial updates
1135 AccountsCommon accountToUpdate = new AccountsCommon();
1136 accountToUpdate.setCsid(knownResourceId);
1137 accountToUpdate.setUserId(accountFound.getUserId());
1139 // Update the content of this resource.
1140 accountToUpdate.setStatus(Status.INACTIVE);
1141 if (logger.isDebugEnabled()) {
1142 logger.debug("updated object");
1143 logger.debug(objectAsXmlString(accountToUpdate,
1144 AccountsCommon.class));
1147 // Submit the request to the service and store the response.
1148 res = client.update(knownResourceId, accountToUpdate);
1149 int statusCode = res.getStatus();
1150 // Check the status code of the response: does it match the expected response(s)?
1151 if (logger.isDebugEnabled()) {
1152 logger.debug(testName + ": status = " + statusCode);
1154 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1155 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1156 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1158 AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
1159 Assert.assertNotNull(accountUpdated);
1161 Assert.assertEquals(accountUpdated.getStatus(),
1162 accountToUpdate.getStatus(),
1163 "Data in updated object did not match submitted data.");
1168 // Placeholders until the three tests below can be uncommented.
1169 // See Issue CSPACE-401.
1171 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1174 public void updateWithEmptyEntityBody(String testName) throws Exception {
1175 //FIXME: Should this test really be empty? If so, please comment accordingly.
1179 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1182 public void updateWithMalformedXml(String testName) throws Exception {
1183 //FIXME: Should this test really be empty? If so, please comment accordingly.
1187 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1190 public void updateWithWrongXmlSchema(String testName) throws Exception {
1191 //FIXME: Should this test really be empty? If so, please comment accordingly.
1195 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1198 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1199 dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
1200 public void updateNonExistent(String testName) throws Exception {
1202 if (logger.isDebugEnabled()) {
1203 logger.debug(testBanner(testName, CLASS_NAME));
1206 setupUpdateNonExistent();
1208 // Submit the request to the service and store the response.
1210 // Note: The ID used in this 'create' call may be arbitrary.
1211 // The only relevant ID may be the one used in updateAccount(), below.
1212 AccountClient client = new AccountClient();
1213 AccountsCommon account =
1214 createAccountInstance("simba", "simba", "tiger", "simba@lionking.com",
1215 client.getTenantId(), true, false, true, true);
1216 ClientResponse<AccountsCommon> res =
1217 client.update(NON_EXISTENT_ID, account);
1218 int statusCode = res.getStatus();
1220 // Check the status code of the response: does it match
1221 // the expected response(s)?
1222 if (logger.isDebugEnabled()) {
1223 logger.debug(testName + ": status = " + statusCode);
1225 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1226 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1227 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1231 * Update wrong user.
1233 * @param testName the test name
1234 * @throws Exception the exception
1236 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1237 dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
1238 public void updateWrongUser(String testName) throws Exception {
1240 if (logger.isDebugEnabled()) {
1241 logger.debug(testBanner(testName, CLASS_NAME));
1245 // Submit the request to the service and store the response.
1247 // Note: The ID used in this 'create' call may be arbitrary.
1248 // The only relevant ID may be the one used in updateAccount(), below.
1249 AccountClient client = new AccountClient();
1250 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
1251 if (logger.isDebugEnabled()) {
1252 logger.debug(testName + ": read status = " + res.getStatus());
1254 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1256 if (logger.isDebugEnabled()) {
1257 logger.debug("got object to update with ID: " + knownResourceId);
1259 AccountsCommon accountToUpdate =
1260 (AccountsCommon) res.getEntity();
1261 Assert.assertNotNull(accountToUpdate);
1263 accountToUpdate.setUserId("barneyFake");
1264 if (logger.isDebugEnabled()) {
1265 logger.debug("updated object with wrongUser");
1266 logger.debug(objectAsXmlString(accountToUpdate,
1267 AccountsCommon.class));
1270 res = client.update(knownResourceId, accountToUpdate);
1271 int statusCode = res.getStatus();
1273 // Check the status code of the response: does it match
1274 // the expected response(s)?
1275 if (logger.isDebugEnabled()) {
1276 logger.debug(testName + ": status = " + statusCode);
1278 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1279 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1280 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
1283 // ---------------------------------------------------------------
1284 // CRUD tests : DELETE tests
1285 // ---------------------------------------------------------------
1288 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1291 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1292 dependsOnMethods = {"testSubmitRequest", "updateWrongUser"})
1293 public void delete(String testName) throws Exception {
1295 if (logger.isDebugEnabled()) {
1296 logger.debug(testBanner(testName, CLASS_NAME));
1301 // Submit the request to the service and store the response.
1302 AccountClient client = new AccountClient();
1303 ClientResponse<Response> res = client.delete(knownResourceId);
1304 int statusCode = res.getStatus();
1306 // Check the status code of the response: does it match
1307 // the expected response(s)?
1308 if (logger.isDebugEnabled()) {
1309 logger.debug(testName + ": status = " + statusCode);
1311 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1312 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1313 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1318 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1321 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1322 dependsOnMethods = {"delete"})
1323 public void deleteNonExistent(String testName) throws Exception {
1325 if (logger.isDebugEnabled()) {
1326 logger.debug(testBanner(testName, CLASS_NAME));
1329 setupDeleteNonExistent();
1331 // Submit the request to the service and store the response.
1332 AccountClient client = new AccountClient();
1333 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1334 int statusCode = res.getStatus();
1336 // Check the status code of the response: does it match
1337 // the expected response(s)?
1338 if (logger.isDebugEnabled()) {
1339 logger.debug(testName + ": status = " + statusCode);
1341 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1342 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1343 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1346 // ---------------------------------------------------------------
1348 // ---------------------------------------------------------------
1351 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
1352 public void searchWorkflowDeleted(String testName) throws Exception {
1353 // Fixme: null test for now, overriding test in base class
1356 // ---------------------------------------------------------------
1357 // Utility tests : tests of code used in tests above
1358 // ---------------------------------------------------------------
1360 * Tests the code for manually submitting data that is used by several
1361 * of the methods above.
1364 @Test(dependsOnMethods = {"create", "read"})
1365 public void testSubmitRequest() throws Exception {
1369 // Submit the request to the service and store the response.
1370 String method = ServiceRequestType.READ.httpMethodName();
1371 String url = getResourceURL(knownResourceId);
1372 int statusCode = submitRequest(method, url);
1374 // Check the status code of the response: does it match
1375 // the expected response(s)?
1376 if (logger.isDebugEnabled()) {
1377 logger.debug("testSubmitRequest: url=" + url
1378 + " status=" + statusCode);
1380 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1384 // ---------------------------------------------------------------
1385 // Utility methods used by tests above
1386 // ---------------------------------------------------------------
1388 * create account instance
1393 * @param useScreenName
1394 * @param invalidTenant
1396 * @param usePassword
1399 AccountsCommon createAccountInstance(String screenName,
1400 String userName, String passwd, String email, String tenantId,
1401 boolean useScreenName, boolean invalidTenant, boolean useUser, boolean usePassword) {
1403 AccountsCommon account = AccountFactory.createAccountInstance(screenName,
1404 userName, passwd, email, tenantId, useScreenName,
1405 invalidTenant, useUser, usePassword);
1406 if (logger.isDebugEnabled()) {
1407 logger.debug("to be created, account common");
1408 logger.debug(objectAsXmlString(account,
1409 AccountsCommon.class));
1419 * @param testName the test name
1420 * @param list the list
1422 private void printList(String testName, AccountsCommonList list) {
1423 List<AccountListItem> items =
1424 list.getAccountListItem();
1427 for (AccountListItem item : items) {
1428 logger.debug(testName + ": list-item[" + i + "] csid="
1430 logger.debug(testName + ": list-item[" + i + "] screenName="
1431 + item.getScreenName());
1432 logger.debug(testName + ": list-item[" + i + "] URI="