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.Status;
33 import org.collectionspace.services.client.AccountFactory;
34 import org.collectionspace.services.client.test.AbstractServiceTestImpl;
35 import org.collectionspace.services.client.test.ServiceRequestType;
36 import org.collectionspace.services.jaxb.AbstractCommonList;
37 import org.jboss.resteasy.client.ClientResponse;
39 import org.testng.Assert;
40 import org.testng.annotations.Test;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
46 * AccountServiceTest, carries out tests against a
47 * deployed and running Account Service.
49 * $LastChangedRevision: 917 $
50 * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
52 public class AccountServiceTest extends AbstractServiceTestImpl {
54 /** The Constant logger. */
55 private final String CLASS_NAME = AccountServiceTest.class.getName();
56 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
57 // Instance variables specific to this test.
58 /** The known resource id. */
59 private String knownResourceId = null;
60 private String prebuiltAdminCSID = null;
61 private String prebuiltAdminUserId = "admin@core.collectionspace.org";
62 private String knownUserId = "barney";
63 private String knownUserPassword = "hithere08";
64 /** The add tenant. */
65 static boolean addTenant = true;
68 public String getServiceName() {
69 return AccountClient.SERVICE_NAME;
73 * This method is called only by the parent class, AbstractServiceTestImpl
76 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
79 protected String getServicePathComponent() {
80 return new AccountClient().getServicePathComponent();
84 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
87 protected CollectionSpaceClient getClientInstance() {
88 return new AccountClient();
92 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
95 protected AbstractCommonList getAbstractCommonList(
96 ClientResponse<AbstractCommonList> response) {
97 //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
98 throw new UnsupportedOperationException();
102 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
104 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
105 dependsOnMethods = {"readList"})
107 public void readPaginatedList(String testName) throws Exception {
108 //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
111 // ---------------------------------------------------------------
112 // CRUD tests : CREATE tests
113 // ---------------------------------------------------------------
116 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
119 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
120 public void create(String testName) throws Exception {
122 if (logger.isDebugEnabled()) {
123 logger.debug(testBanner(testName, CLASS_NAME));
125 // Perform setup, such as initializing the type of service request
126 // (e.g. CREATE, DELETE), its valid and expected status codes, and
127 // its associated HTTP method name (e.g. POST, DELETE).
130 AccountClient client = new AccountClient();
131 // Submit the request to the service and store the response.
132 AccountsCommon account =
133 createAccountInstance(knownUserId, knownUserId, knownUserPassword,
134 "barney@dinoland.com", client.getTenantId(),
135 true, false, true, true);
136 ClientResponse<Response> res = client.create(account);
137 int statusCode = res.getStatus();
139 // Check the status code of the response: does it match
140 // the expected response(s)?
143 // Does it fall within the set of valid status codes?
144 // Does it exactly match the expected status code?
145 if (logger.isDebugEnabled()) {
146 logger.debug(testName + ": status = " + statusCode);
148 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
149 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
150 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
152 // Store the ID returned from this create operation
153 // for additional tests below.
154 knownResourceId = extractId(res);
155 if (logger.isDebugEnabled()) {
156 logger.debug(testName + ": knownResourceId=" + knownResourceId);
161 * Creates the for unique user.
163 * @param testName the test name
164 * @throws Exception the exception
166 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
167 dependsOnMethods = {"create"})
168 public void createForUniqueUser(String testName) throws Exception {
170 if (logger.isDebugEnabled()) {
171 logger.debug(testBanner(testName, CLASS_NAME));
175 // Submit the request to the service and store the response.
176 AccountClient client = new AccountClient();
177 AccountsCommon account =
178 createAccountInstance("barney1", knownUserId, knownUserPassword,
179 "barney@dinoland.com",
180 client.getTenantId(), true, false, true, true);
182 ClientResponse<Response> res = client.create(account);
183 int statusCode = res.getStatus();
184 if (logger.isDebugEnabled()) {
185 logger.debug(testName + ": status = " + statusCode);
187 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
188 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
189 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
193 * Creates the with invalid tenant.
195 * @param testName the test name
196 * @throws Exception the exception
198 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
199 dependsOnMethods = {"create"})
200 public void createWithInvalidTenant(String testName) throws Exception {
202 if (logger.isDebugEnabled()) {
203 logger.debug(testBanner(testName, CLASS_NAME));
207 // Submit the request to the service and store the response.
208 AccountClient client = new AccountClient();
209 AccountsCommon account =
210 createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
211 client.getTenantId(), true, true, true, true);
212 ClientResponse<Response> res = client.create(account);
213 int statusCode = res.getStatus();
214 // Does it exactly match the expected status code?
215 if (logger.isDebugEnabled()) {
216 logger.debug(testName + ": status = " + statusCode);
218 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
219 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
220 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
225 * Creates the without user.
227 * @param testName the test name
228 * @throws Exception the exception
230 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
231 dependsOnMethods = {"create"})
232 public void createWithoutUser(String testName) throws Exception {
234 if (logger.isDebugEnabled()) {
235 logger.debug(testBanner(testName, CLASS_NAME));
239 // Submit the request to the service and store the response.
240 AccountClient client = new AccountClient();
241 AccountsCommon account =
242 createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
243 client.getTenantId(), true, false, false, true);
244 ClientResponse<Response> res = client.create(account);
245 int statusCode = res.getStatus();
246 // Does it exactly match the expected status code?
247 if (logger.isDebugEnabled()) {
248 logger.debug(testName + ": status = " + statusCode);
250 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
251 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
252 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
256 * Creates the with invalid email.
258 * @param testName the test name
259 * @throws Exception the exception
261 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
262 dependsOnMethods = {"create"})
263 public void createWithInvalidEmail(String testName) throws Exception {
265 if (logger.isDebugEnabled()) {
266 logger.debug(testBanner(testName, CLASS_NAME));
270 // Submit the request to the service and store the response.
271 AccountClient client = new AccountClient();
272 AccountsCommon account =
273 createAccountInstance("babybop", "babybop", "hithere08", "babybop.dinoland.com",
274 client.getTenantId(), true, false, true, true);
275 ClientResponse<Response> res = client.create(account);
276 int statusCode = res.getStatus();
277 // Does it exactly match the expected status code?
278 if (logger.isDebugEnabled()) {
279 logger.debug(testName + ": status = " + statusCode);
281 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
282 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
283 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
287 * Creates the without screen name.
289 * @param testName the test name
290 * @throws Exception the exception
292 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
293 dependsOnMethods = {"create"})
294 public void createWithoutScreenName(String testName) throws Exception {
296 if (logger.isDebugEnabled()) {
297 logger.debug(testBanner(testName, CLASS_NAME));
301 // Submit the request to the service and store the response.
302 AccountClient client = new AccountClient();
303 AccountsCommon account =
304 createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
305 client.getTenantId(), false, false, true, true);
306 ClientResponse<Response> res = client.create(account);
307 int statusCode = res.getStatus();
308 // Does it exactly match the expected status code?
309 if (logger.isDebugEnabled()) {
310 logger.debug(testName + ": status = " + statusCode);
312 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
313 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
314 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
318 * Creates the with invalid password.
320 * @param testName the test name
321 * @throws Exception the exception
323 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
324 dependsOnMethods = {"create"})
325 public void createWithInvalidPassword(String testName) throws Exception {
327 if (logger.isDebugEnabled()) {
328 logger.debug(testBanner(testName, CLASS_NAME));
332 // Submit the request to the service and store the response.
333 AccountClient client = new AccountClient();
334 AccountsCommon account =
335 createAccountInstance("babybop", "babybop", "shpswd", "babybop@dinoland.com",
336 client.getTenantId(), true, false, true, true);
337 ClientResponse<Response> res = client.create(account);
338 int statusCode = res.getStatus();
339 // Does it exactly match the expected status code?
340 if (logger.isDebugEnabled()) {
341 logger.debug(testName + ": status = " + statusCode);
343 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
344 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
345 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
349 * Creates the with most invalid.
351 * @param testName the test name
352 * @throws Exception the exception
354 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
355 dependsOnMethods = {"create"})
356 public void createWithMostInvalid(String testName) throws Exception {
358 if (logger.isDebugEnabled()) {
359 logger.debug(testBanner(testName, CLASS_NAME));
363 // Submit the request to the service and store the response.
364 AccountClient client = new AccountClient();
365 AccountsCommon account =
366 createAccountInstance("babybop", "babybop", "hithere08", "babybop/dinoland.com",
367 client.getTenantId(), false, true, false, false);
368 ClientResponse<Response> res = client.create(account);
369 int statusCode = res.getStatus();
370 // Does it exactly match the expected status code?
371 if (logger.isDebugEnabled()) {
372 logger.debug(testName + ": status = " + statusCode);
374 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
375 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
376 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
379 //to not cause uniqueness violation for account, createList is removed
381 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
384 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
385 dependsOnMethods = {"create"})
386 public void createList(String testName) throws Exception {
388 if (logger.isDebugEnabled()) {
389 logger.debug(testBanner(testName, CLASS_NAME));
392 // Submit the request to the service and store the response.
393 AccountClient client = new AccountClient();
394 AccountsCommon account1 =
395 createAccountInstance("curious", "curious", "hithere08", "curious@george.com",
396 client.getTenantId(), true, false, true, true);
397 ClientResponse<Response> res = client.create(account1);
398 int statusCode = res.getStatus();
399 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
400 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
401 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
402 allResourceIdsCreated.add(extractId(res));
404 AccountsCommon account2 =
405 createAccountInstance("tom", "tom", "hithere09", "tom@jerry.com",
406 client.getTenantId(), true, false, true, true);
407 res = client.create(account2);
408 statusCode = res.getStatus();
409 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
410 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
411 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
412 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
413 allResourceIdsCreated.add(extractId(res));
415 AccountsCommon account3 =
416 createAccountInstance("mj", "mj", "hithere10", "mj@dinoland.com",
417 client.getTenantId(), true, false, true, true);
418 res = client.create(account3);
419 statusCode = res.getStatus();
420 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
421 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
422 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
423 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
424 allResourceIdsCreated.add(extractId(res));
428 // Placeholders until the three tests below can be uncommented.
429 // See Issue CSPACE-401.
431 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
434 public void createWithEmptyEntityBody(String testName) throws Exception {
435 //FIXME: Should this test really be empty? If so, please comment accordingly.
439 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
442 public void createWithMalformedXml(String testName) throws Exception {
443 //FIXME: Should this test really be empty? If so, please comment accordingly.
447 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
450 public void createWithWrongXmlSchema(String testName) throws Exception {
451 //FIXME: Should this test really be empty? If so, please comment accordingly.
454 // ---------------------------------------------------------------
455 // CRUD tests : READ tests
456 // ---------------------------------------------------------------
459 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
462 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
463 dependsOnMethods = {"create"})
464 public void read(String testName) throws Exception {
466 if (logger.isDebugEnabled()) {
467 logger.debug(testBanner(testName, CLASS_NAME));
472 // Submit the request to the service and store the response.
473 AccountClient client = new AccountClient();
474 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
475 int statusCode = res.getStatus();
477 // Check the status code of the response: does it match
478 // the expected response(s)?
479 if (logger.isDebugEnabled()) {
480 logger.debug(testName + ": status = " + statusCode);
482 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
483 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
484 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
486 AccountsCommon output = (AccountsCommon) res.getEntity();
487 Assert.assertNotNull(output);
492 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
495 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
496 dependsOnMethods = {"read"})
497 public void readNonExistent(String testName) throws Exception {
499 if (logger.isDebugEnabled()) {
500 logger.debug(testBanner(testName, CLASS_NAME));
503 setupReadNonExistent();
505 // Submit the request to the service and store the response.
506 AccountClient client = new AccountClient();
507 ClientResponse<AccountsCommon> res = client.read(NON_EXISTENT_ID);
508 int statusCode = res.getStatus();
510 // Check the status code of the response: does it match
511 // the expected response(s)?
512 if (logger.isDebugEnabled()) {
513 logger.debug(testName + ": status = " + statusCode);
515 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
516 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
517 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
520 // ---------------------------------------------------------------
521 // CRUD tests : READ_LIST tests
522 // ---------------------------------------------------------------
525 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
528 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
529 dependsOnMethods = {"createList", "read"})
530 public void readList(String testName) throws Exception {
532 if (logger.isDebugEnabled()) {
533 logger.debug(testBanner(testName, CLASS_NAME));
538 // Submit the request to the service and store the response.
539 AccountClient client = new AccountClient();
540 ClientResponse<AccountsCommonList> res = client.readList();
541 AccountsCommonList list = res.getEntity();
542 int statusCode = res.getStatus();
544 // Check the status code of the response: does it match
545 // the expected response(s)?
546 if (logger.isDebugEnabled()) {
547 logger.debug(testName + ": status = " + statusCode);
549 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
550 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
551 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
553 // Optionally output additional data about list members for debugging.
554 boolean iterateThroughList = true;
555 if (iterateThroughList && logger.isDebugEnabled()) {
556 printList(testName, list);
561 * Search screen name.
563 * @param testName the test name
564 * @throws Exception the exception
566 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
567 dependsOnMethods = {"createList", "read"})
568 public void searchScreenName(String testName) throws Exception {
570 if (logger.isDebugEnabled()) {
571 logger.debug(testBanner(testName, CLASS_NAME));
576 // Submit the request to the service and store the response.
577 AccountClient client = new AccountClient();
578 ClientResponse<AccountsCommonList> res =
579 client.readSearchList("tom", null, null);
580 AccountsCommonList list = res.getEntity();
581 int statusCode = res.getStatus();
583 // Check the status code of the response: does it match
584 // the expected response(s)?
585 if (logger.isDebugEnabled()) {
586 logger.debug(testName + ": status = " + statusCode);
588 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
589 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
590 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
591 Assert.assertEquals(1, list.getAccountListItem().size());
592 // Optionally output additional data about list members for debugging.
593 boolean iterateThroughList = true;
594 if (iterateThroughList && logger.isDebugEnabled()) {
595 printList(testName, list);
602 * @param testName the test name
603 * @throws Exception the exception
605 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
606 dependsOnMethods = {"createList", "read"})
607 public void searchUserId(String testName) throws Exception {
609 if (logger.isDebugEnabled()) {
610 logger.debug(testBanner(testName, CLASS_NAME));
615 // Submit the request to the service and store the response.
616 AccountClient client = new AccountClient();
617 ClientResponse<AccountsCommonList> res =
618 client.readSearchList(null, "tom", null);
619 AccountsCommonList list = res.getEntity();
620 int statusCode = res.getStatus();
622 // Check the status code of the response: does it match
623 // the expected response(s)?
624 if (logger.isDebugEnabled()) {
625 logger.debug(testName + ": status = " + statusCode);
627 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
628 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
629 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
630 Assert.assertEquals(1, list.getAccountListItem().size());
631 // Optionally output additional data about list members for debugging.
632 boolean iterateThroughList = true;
633 if (iterateThroughList && logger.isDebugEnabled()) {
634 printList(testName, list);
641 * @param testName the test name
642 * @throws Exception the exception
644 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
645 dependsOnMethods = {"createList", "read"})
646 public void searchEmail(String testName) throws Exception {
648 if (logger.isDebugEnabled()) {
649 logger.debug(testBanner(testName, CLASS_NAME));
654 // Submit the request to the service and store the response.
655 AccountClient client = new AccountClient();
656 ClientResponse<AccountsCommonList> res =
657 client.readSearchList(null, null, "dinoland");
658 AccountsCommonList list = res.getEntity();
659 int statusCode = res.getStatus();
661 // Check the status code of the response: does it match
662 // the expected response(s)?
663 if (logger.isDebugEnabled()) {
664 logger.debug(testName + ": status = " + statusCode);
666 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
667 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
668 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
669 Assert.assertEquals(2, list.getAccountListItem().size());
670 // Optionally output additional data about list members for debugging.
671 boolean iterateThroughList = true;
672 if (iterateThroughList && logger.isDebugEnabled()) {
673 printList(testName, list);
678 * Search screen name email.
680 * @param testName the test name
681 * @throws Exception the exception
683 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
684 dependsOnMethods = {"createList", "read"})
685 public void searchScreenNameEmail(String testName) throws Exception {
687 if (logger.isDebugEnabled()) {
688 logger.debug(testBanner(testName, CLASS_NAME));
693 // Submit the request to the service and store the response.
694 AccountClient client = new AccountClient();
695 ClientResponse<AccountsCommonList> res =
696 client.readSearchList("tom", null, "jerry");
697 AccountsCommonList list = res.getEntity();
698 int statusCode = res.getStatus();
700 // Check the status code of the response: does it match
701 // the expected response(s)?
702 if (logger.isDebugEnabled()) {
703 logger.debug(testName + ": status = " + statusCode);
705 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
706 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
707 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
708 Assert.assertEquals(1, list.getAccountListItem().size());
709 // Optionally output additional data about list members for debugging.
710 boolean iterateThroughList = true;
711 if (iterateThroughList && logger.isDebugEnabled()) {
712 printList(testName, list);
718 // ---------------------------------------------------------------
719 // CRUD tests : UPDATE tests
720 // ---------------------------------------------------------------
723 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
726 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
727 dependsOnMethods = {"read", "readList", "readNonExistent"})
728 public void update(String testName) throws Exception {
730 if (logger.isDebugEnabled()) {
731 logger.debug(testBanner(testName, CLASS_NAME));
736 AccountClient client = new AccountClient();
737 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
738 if (logger.isDebugEnabled()) {
739 logger.debug(testName + ": read status = " + res.getStatus());
741 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
743 if (logger.isDebugEnabled()) {
744 logger.debug("got object to update with ID: " + knownResourceId);
746 AccountsCommon accountFound =
747 (AccountsCommon) res.getEntity();
748 Assert.assertNotNull(accountFound);
750 //create a new account object to test partial updates
751 AccountsCommon accountToUpdate = new AccountsCommon();
752 accountToUpdate.setCsid(knownResourceId);
753 accountToUpdate.setUserId(accountFound.getUserId());
754 // Update the content of this resource.
755 accountToUpdate.setEmail("updated-" + accountFound.getEmail());
756 if (logger.isDebugEnabled()) {
757 logger.debug("updated object");
758 logger.debug(objectAsXmlString(accountFound,
759 AccountsCommon.class));
762 // Submit the request to the service and store the response.
763 res = client.update(knownResourceId, accountToUpdate);
764 int statusCode = res.getStatus();
765 // Check the status code of the response: does it match the expected response(s)?
766 if (logger.isDebugEnabled()) {
767 logger.debug(testName + ": status = " + statusCode);
769 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
770 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
771 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
773 AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
774 Assert.assertNotNull(accountUpdated);
776 Assert.assertEquals(accountUpdated.getEmail(),
777 accountToUpdate.getEmail(),
778 "Data in updated object did not match submitted data.");
784 * @param testName the test name
785 * @throws Exception the exception
787 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
788 dependsOnMethods = {"update"})
789 public void updatePassword(String testName) throws Exception {
791 if (logger.isDebugEnabled()) {
792 logger.debug(testBanner(testName, CLASS_NAME));
797 AccountClient client = new AccountClient();
798 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
799 if (logger.isDebugEnabled()) {
800 logger.debug(testName + ": read status = " + res.getStatus());
802 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
804 if (logger.isDebugEnabled()) {
805 logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
807 AccountsCommon accountFound =
808 (AccountsCommon) res.getEntity();
809 Assert.assertNotNull(accountFound);
811 //create a new account object to test partial updates
812 AccountsCommon accountToUpdate = new AccountsCommon();
813 accountToUpdate.setCsid(knownResourceId);
814 accountToUpdate.setUserId(accountFound.getUserId());
816 accountToUpdate.setPassword("imagination".getBytes());
817 if (logger.isDebugEnabled()) {
818 logger.debug(testName + ": updated object");
819 logger.debug(objectAsXmlString(accountToUpdate,
820 AccountsCommon.class));
823 // Submit the request to the service and store the response.
824 res = client.update(knownResourceId, accountToUpdate);
825 int statusCode = res.getStatus();
826 // Check the status code of the response: does it match the expected response(s)?
827 if (logger.isDebugEnabled()) {
828 logger.debug(testName + ": status = " + statusCode);
830 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
831 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
832 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
835 AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
836 Assert.assertNotNull(accountUpdated);
838 // Assert.assertEquals(accountUpdated.getPassword(),
839 // accountFound.getPassword(),
840 // "Data in updated object did not match submitted data.");
844 * Update password without user.
846 * @param testName the test name
847 * @throws Exception the exception
849 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
850 dependsOnMethods = {"update"})
851 public void updatePasswordWithoutUser(String testName) throws Exception {
853 if (logger.isDebugEnabled()) {
854 logger.debug(testBanner(testName, CLASS_NAME));
859 AccountsCommon accountToUpdate = new AccountsCommon();
860 accountToUpdate.setCsid(knownResourceId);
861 accountToUpdate.setUserId(null);
863 accountToUpdate.setPassword("imagination".getBytes());
864 if (logger.isDebugEnabled()) {
865 logger.debug(testName + " : updated object");
866 logger.debug(objectAsXmlString(accountToUpdate,
867 AccountsCommon.class));
870 AccountClient client = new AccountClient();
871 // Submit the request to the service and store the response.
872 ClientResponse<AccountsCommon> res = client.update(knownResourceId, accountToUpdate);
873 int statusCode = res.getStatus();
874 // Check the status code of the response: does it match the expected response(s)?
875 if (logger.isDebugEnabled()) {
876 logger.debug(testName + ": status = " + statusCode);
878 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
879 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
880 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
885 * Update invalid password.
887 * @param testName the test name
888 * @throws Exception the exception
890 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
891 dependsOnMethods = {"update"})
892 public void updateInvalidPassword(String testName) throws Exception {
894 if (logger.isDebugEnabled()) {
895 logger.debug(testBanner(testName, CLASS_NAME));
899 AccountClient client = new AccountClient();
900 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
901 if (logger.isDebugEnabled()) {
902 logger.debug(testName + ": read status = " + res.getStatus());
904 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
906 if (logger.isDebugEnabled()) {
907 logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
909 AccountsCommon accountFound = (AccountsCommon) res.getEntity();
911 AccountsCommon accountToUpdate = new AccountsCommon();
912 accountToUpdate.setCsid(knownResourceId);
913 accountToUpdate.setUserId(accountFound.getUserId());
914 Assert.assertNotNull(accountToUpdate);
917 accountToUpdate.setPassword("abc123".getBytes());
918 if (logger.isDebugEnabled()) {
919 logger.debug(testName + ": updated object");
920 logger.debug(objectAsXmlString(accountToUpdate,
921 AccountsCommon.class));
924 // Submit the request to the service and store the response.
925 res = client.update(knownResourceId, accountToUpdate);
926 int statusCode = res.getStatus();
927 // Check the status code of the response: does it match the expected response(s)?
928 if (logger.isDebugEnabled()) {
929 logger.debug(testName + ": status = " + statusCode);
931 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
932 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
933 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
937 private void findPrebuiltAdminAccount() {
938 // Search for the prebuilt admin user and then hold its CSID
939 if(prebuiltAdminCSID == null) {
941 AccountClient client = new AccountClient();
942 ClientResponse<AccountsCommonList> res =
943 client.readSearchList(null, this.prebuiltAdminUserId, null);
944 AccountsCommonList list = res.getEntity();
945 int statusCode = res.getStatus();
947 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
948 List<AccountsCommonList.AccountListItem> items = list.getAccountListItem();
949 Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
950 AccountsCommonList.AccountListItem item = items.get(0);
951 prebuiltAdminCSID = item.getCsid();
952 if (logger.isDebugEnabled()) {
953 logger.debug("Found Admin Account with ID: " + prebuiltAdminCSID);
958 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
959 dependsOnMethods = {"read", "readList", "readNonExistent"})
960 public void verifyMetadataProtection(String testName) throws Exception {
961 findPrebuiltAdminAccount();
962 // Try to update the metadata - it should just get ignored
963 if (logger.isDebugEnabled()) {
964 logger.debug(testBanner(testName, CLASS_NAME));
969 AccountClient client = new AccountClient();
970 ClientResponse<AccountsCommon> res = client.read(prebuiltAdminCSID);
971 if (logger.isDebugEnabled()) {
972 logger.debug(testName + ": read status = " + res.getStatus());
974 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
976 if (logger.isDebugEnabled()) {
977 logger.debug("Did get on Admin Account to update with ID: " + prebuiltAdminCSID);
979 AccountsCommon accountFound = (AccountsCommon) res.getEntity();
980 Assert.assertNotNull(accountFound);
982 //create a new account object to test partial updates
983 AccountsCommon accountToUpdate = new AccountsCommon();
984 accountToUpdate.setCsid(prebuiltAdminCSID);
985 accountToUpdate.setUserId(accountFound.getUserId());
986 // Update the content of this resource.
987 accountToUpdate.setEmail("updated-" + accountFound.getEmail());
988 if (logger.isDebugEnabled()) {
989 logger.debug("updated object");
990 logger.debug(objectAsXmlString(accountFound,
991 AccountsCommon.class));
994 // Submit the request to the service and store the response.
995 res = client.update(prebuiltAdminCSID, accountToUpdate);
996 int statusCode = res.getStatus();
997 // Check the status code of the response: does it match the expected response(s)?
998 if (logger.isDebugEnabled()) {
999 logger.debug(testName + ": status = " + statusCode);
1001 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1002 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1003 // Note that the error is not returned, it is just ignored
1004 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1006 AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
1007 Assert.assertNotNull(accountUpdated);
1009 Assert.assertFalse(accountUpdated.getEmail().equals(accountToUpdate.getEmail()),
1010 "Admin Account (with metadata lock) allowed update to change the email!");
1014 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1015 dependsOnMethods = {"read", "readList", "readNonExistent"})
1016 public void verifyProtectionReadOnly(String testName) throws Exception {
1018 if (logger.isDebugEnabled()) {
1019 logger.debug(testBanner(testName, CLASS_NAME));
1024 // Submit the request to the service and store the response.
1025 AccountClient client = new AccountClient();
1026 AccountsCommon account =
1027 createAccountInstance("mdTest", "mdTest", "mdTestPW", "md@test.com",
1028 client.getTenantId(), true, false, true, true);
1029 account.setMetadataProtection(AccountClient.IMMUTABLE);
1030 account.setRolesProtection(AccountClient.IMMUTABLE);
1031 ClientResponse<Response> res = client.create(account);
1032 int statusCode = res.getStatus();
1033 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1034 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1035 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1037 // Store the ID returned from this create operation
1038 // for additional tests below.
1039 String testResourceId = extractId(res);
1040 allResourceIdsCreated.add(testResourceId);
1041 if (logger.isDebugEnabled()) {
1042 logger.debug(testName + ": testResourceId=" + testResourceId);
1046 // Submit the request to the service and store the response.
1047 ClientResponse<AccountsCommon> accountRes = client.read(testResourceId);
1048 statusCode = accountRes.getStatus();
1050 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1051 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1052 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1054 AccountsCommon accountRead = (AccountsCommon) accountRes.getEntity();
1055 Assert.assertNotNull(accountRead);
1056 String mdProtection = accountRead.getMetadataProtection();
1057 String rolesProtection = accountRead.getRolesProtection();
1058 if (logger.isTraceEnabled()) {
1059 logger.trace(testName + ": metadataProtection=" + mdProtection);
1060 logger.trace(testName + ": rolesProtection=" + rolesProtection);
1062 Assert.assertFalse(account.getMetadataProtection().equals(mdProtection),
1063 "Account allowed create to set the metadata protection flag.");
1064 Assert.assertFalse(account.getRolesProtection().equals(rolesProtection),
1065 "Account allowed create to set the perms protection flag.");
1069 AccountsCommon accountToUpdate =
1070 createAccountInstance("mdTest", "mdTest", "mdTestPW", "md@test.com",
1071 client.getTenantId(), true, false, true, true);
1072 accountToUpdate.setMetadataProtection(AccountClient.IMMUTABLE);
1073 accountToUpdate.setRolesProtection(AccountClient.IMMUTABLE);
1075 // Submit the request to the service and store the response.
1076 accountRes = client.update(testResourceId, accountToUpdate);
1077 statusCode = accountRes.getStatus();
1078 // Check the status code of the response: does it match the expected response(s)?
1079 if (logger.isDebugEnabled()) {
1080 logger.debug(testName + ": status = " + statusCode);
1082 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1083 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1084 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1087 AccountsCommon accountUpdated = (AccountsCommon) accountRes.getEntity();
1088 Assert.assertNotNull(accountUpdated);
1089 if (logger.isDebugEnabled()) {
1090 logger.debug(testName + "Updated account: ");
1091 logger.debug(objectAsXmlString(accountUpdated,AccountsCommon.class));
1095 AccountClient.IMMUTABLE.equalsIgnoreCase(accountUpdated.getMetadataProtection()),
1096 "Account allowed update of the metadata protection flag.");
1098 AccountClient.IMMUTABLE.equalsIgnoreCase(accountUpdated.getRolesProtection()),
1099 "Account allowed update of the roles protection flag.");
1107 * @param testName the test name
1108 * @throws Exception the exception
1110 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1111 dependsOnMethods = {"updatePasswordWithoutUser"})
1112 public void deactivate(String testName) throws Exception {
1114 if (logger.isDebugEnabled()) {
1115 logger.debug(testBanner(testName, CLASS_NAME));
1120 AccountClient client = new AccountClient();
1121 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
1122 if (logger.isDebugEnabled()) {
1123 logger.debug(testName + ": read status = " + res.getStatus());
1125 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1127 if (logger.isDebugEnabled()) {
1128 logger.debug("got object to update with ID: " + knownResourceId);
1130 AccountsCommon accountFound = (AccountsCommon) res.getEntity();
1132 //create a new account object to test partial updates
1133 AccountsCommon accountToUpdate = new AccountsCommon();
1134 accountToUpdate.setCsid(knownResourceId);
1135 accountToUpdate.setUserId(accountFound.getUserId());
1137 // Update the content of this resource.
1138 accountToUpdate.setStatus(Status.INACTIVE);
1139 if (logger.isDebugEnabled()) {
1140 logger.debug("updated object");
1141 logger.debug(objectAsXmlString(accountToUpdate,
1142 AccountsCommon.class));
1145 // Submit the request to the service and store the response.
1146 res = client.update(knownResourceId, accountToUpdate);
1147 int statusCode = res.getStatus();
1148 // Check the status code of the response: does it match the expected response(s)?
1149 if (logger.isDebugEnabled()) {
1150 logger.debug(testName + ": status = " + statusCode);
1152 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1153 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1154 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1156 AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
1157 Assert.assertNotNull(accountUpdated);
1159 Assert.assertEquals(accountUpdated.getStatus(),
1160 accountToUpdate.getStatus(),
1161 "Data in updated object did not match submitted data.");
1166 // Placeholders until the three tests below can be uncommented.
1167 // See Issue CSPACE-401.
1169 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1172 public void updateWithEmptyEntityBody(String testName) throws Exception {
1173 //FIXME: Should this test really be empty? If so, please comment accordingly.
1177 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1180 public void updateWithMalformedXml(String testName) throws Exception {
1181 //FIXME: Should this test really be empty? If so, please comment accordingly.
1185 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1188 public void updateWithWrongXmlSchema(String testName) throws Exception {
1189 //FIXME: Should this test really be empty? If so, please comment accordingly.
1193 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1196 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1197 dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
1198 public void updateNonExistent(String testName) throws Exception {
1200 if (logger.isDebugEnabled()) {
1201 logger.debug(testBanner(testName, CLASS_NAME));
1204 setupUpdateNonExistent();
1206 // Submit the request to the service and store the response.
1208 // Note: The ID used in this 'create' call may be arbitrary.
1209 // The only relevant ID may be the one used in updateAccount(), below.
1210 AccountClient client = new AccountClient();
1211 AccountsCommon account =
1212 createAccountInstance("simba", "simba", "tiger", "simba@lionking.com",
1213 client.getTenantId(), true, false, true, true);
1214 ClientResponse<AccountsCommon> res =
1215 client.update(NON_EXISTENT_ID, account);
1216 int statusCode = res.getStatus();
1218 // Check the status code of the response: does it match
1219 // the expected response(s)?
1220 if (logger.isDebugEnabled()) {
1221 logger.debug(testName + ": status = " + statusCode);
1223 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1224 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1225 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1229 * Update wrong user.
1231 * @param testName the test name
1232 * @throws Exception the exception
1234 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1235 dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
1236 public void updateWrongUser(String testName) throws Exception {
1238 if (logger.isDebugEnabled()) {
1239 logger.debug(testBanner(testName, CLASS_NAME));
1243 // Submit the request to the service and store the response.
1245 // Note: The ID used in this 'create' call may be arbitrary.
1246 // The only relevant ID may be the one used in updateAccount(), below.
1247 AccountClient client = new AccountClient();
1248 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
1249 if (logger.isDebugEnabled()) {
1250 logger.debug(testName + ": read status = " + res.getStatus());
1252 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1254 if (logger.isDebugEnabled()) {
1255 logger.debug("got object to update with ID: " + knownResourceId);
1257 AccountsCommon accountToUpdate =
1258 (AccountsCommon) res.getEntity();
1259 Assert.assertNotNull(accountToUpdate);
1261 accountToUpdate.setUserId("barneyFake");
1262 if (logger.isDebugEnabled()) {
1263 logger.debug("updated object with wrongUser");
1264 logger.debug(objectAsXmlString(accountToUpdate,
1265 AccountsCommon.class));
1268 res = client.update(knownResourceId, accountToUpdate);
1269 int statusCode = res.getStatus();
1271 // Check the status code of the response: does it match
1272 // the expected response(s)?
1273 if (logger.isDebugEnabled()) {
1274 logger.debug(testName + ": status = " + statusCode);
1276 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1277 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1278 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
1281 // ---------------------------------------------------------------
1282 // CRUD tests : DELETE tests
1283 // ---------------------------------------------------------------
1286 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1289 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1290 dependsOnMethods = {"testSubmitRequest", "updateWrongUser"})
1291 public void delete(String testName) throws Exception {
1293 if (logger.isDebugEnabled()) {
1294 logger.debug(testBanner(testName, CLASS_NAME));
1299 // Submit the request to the service and store the response.
1300 AccountClient client = new AccountClient();
1301 ClientResponse<Response> res = client.delete(knownResourceId);
1302 int statusCode = res.getStatus();
1304 // Check the status code of the response: does it match
1305 // the expected response(s)?
1306 if (logger.isDebugEnabled()) {
1307 logger.debug(testName + ": status = " + statusCode);
1309 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1310 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1311 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1316 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1319 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1320 dependsOnMethods = {"delete"})
1321 public void deleteNonExistent(String testName) throws Exception {
1323 if (logger.isDebugEnabled()) {
1324 logger.debug(testBanner(testName, CLASS_NAME));
1327 setupDeleteNonExistent();
1329 // Submit the request to the service and store the response.
1330 AccountClient client = new AccountClient();
1331 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1332 int statusCode = res.getStatus();
1334 // Check the status code of the response: does it match
1335 // the expected response(s)?
1336 if (logger.isDebugEnabled()) {
1337 logger.debug(testName + ": status = " + statusCode);
1339 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1340 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1341 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1344 // ---------------------------------------------------------------
1346 // ---------------------------------------------------------------
1349 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
1350 public void searchWorkflowDeleted(String testName) throws Exception {
1351 // Fixme: null test for now, overriding test in base class
1354 // ---------------------------------------------------------------
1355 // Utility tests : tests of code used in tests above
1356 // ---------------------------------------------------------------
1358 * Tests the code for manually submitting data that is used by several
1359 * of the methods above.
1362 @Test(dependsOnMethods = {"create", "read"})
1363 public void testSubmitRequest() throws Exception {
1367 // Submit the request to the service and store the response.
1368 String method = ServiceRequestType.READ.httpMethodName();
1369 String url = getResourceURL(knownResourceId);
1370 int statusCode = submitRequest(method, url);
1372 // Check the status code of the response: does it match
1373 // the expected response(s)?
1374 if (logger.isDebugEnabled()) {
1375 logger.debug("testSubmitRequest: url=" + url
1376 + " status=" + statusCode);
1378 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1382 // ---------------------------------------------------------------
1383 // Utility methods used by tests above
1384 // ---------------------------------------------------------------
1386 * create account instance
1391 * @param useScreenName
1392 * @param invalidTenant
1394 * @param usePassword
1397 AccountsCommon createAccountInstance(String screenName,
1398 String userName, String passwd, String email, String tenantId,
1399 boolean useScreenName, boolean invalidTenant, boolean useUser, boolean usePassword) {
1401 AccountsCommon account = AccountFactory.createAccountInstance(screenName,
1402 userName, passwd, email, tenantId, useScreenName,
1403 invalidTenant, useUser, usePassword);
1404 if (logger.isDebugEnabled()) {
1405 logger.debug("to be created, account common");
1406 logger.debug(objectAsXmlString(account,
1407 AccountsCommon.class));
1417 * @param testName the test name
1418 * @param list the list
1420 private void printList(String testName, AccountsCommonList list) {
1421 List<AccountsCommonList.AccountListItem> items =
1422 list.getAccountListItem();
1425 for (AccountsCommonList.AccountListItem item : items) {
1426 logger.debug(testName + ": list-item[" + i + "] csid="
1428 logger.debug(testName + ": list-item[" + i + "] screenName="
1429 + item.getScreenName());
1430 logger.debug(testName + ": list-item[" + i + "] URI="