]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
dac8a35861738d7688e4d638676774ab35d54718
[tmp/jakarta-migration.git] /
1 /**
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:
5  *
6  * http://www.collectionspace.org
7  * http://wiki.collectionspace.org
8  *
9  * Copyright © 2009 Regents of the University of California
10  *
11  * Licensed under the Educational Community License (ECL), Version 2.0.
12  * You may not use this file except in compliance with this License.
13  *
14  * You may obtain a copy of the ECL 2.0 License at
15  * https://source.collectionspace.org/collection-space/LICENSE.txt
16  *
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.
22  */
23 package org.collectionspace.services.account.client.test;
24
25 import java.util.List;
26 import javax.ws.rs.core.Response;
27
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;
38
39 import org.testng.Assert;
40 import org.testng.annotations.Test;
41
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
44
45 /**
46  * AccountServiceTest, carries out tests against a
47  * deployed and running Account Service.
48  * 
49  * $LastChangedRevision: 917 $
50  * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
51  */
52 public class AccountServiceTest extends AbstractServiceTestImpl {
53
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 knownUserId = "barney";
61     private String knownUserPassword = "hithere08";
62     /** The add tenant. */
63     static boolean addTenant = true;
64
65     @Override
66     public String getServiceName() {
67         return AccountClient.SERVICE_NAME;
68     }
69     
70     /*
71      * This method is called only by the parent class, AbstractServiceTestImpl
72      */
73     /* (non-Javadoc)
74      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
75      */
76     @Override
77     protected String getServicePathComponent() {
78         return new AccountClient().getServicePathComponent();
79     }
80
81     /* (non-Javadoc)
82      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
83      */
84     @Override
85     protected CollectionSpaceClient getClientInstance() {
86         return new AccountClient();
87     }
88
89     /* (non-Javadoc)
90      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
91      */
92     @Override
93     protected AbstractCommonList getAbstractCommonList(
94             ClientResponse<AbstractCommonList> response) {
95         //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
96         throw new UnsupportedOperationException();
97     }
98
99     /* (non-Javadoc)
100      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
101      */
102     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
103             dependsOnMethods = {"readList"})
104     @Override
105     public void readPaginatedList(String testName) throws Exception {
106         //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
107     }
108
109     // ---------------------------------------------------------------
110     // CRUD tests : CREATE tests
111     // ---------------------------------------------------------------
112     // Success outcomes
113     /* (non-Javadoc)
114      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
115      */
116     @Override
117     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
118     public void create(String testName) throws Exception {
119
120         if (logger.isDebugEnabled()) {
121             logger.debug(testBanner(testName, CLASS_NAME));
122         }
123         // Perform setup, such as initializing the type of service request
124         // (e.g. CREATE, DELETE), its valid and expected status codes, and
125         // its associated HTTP method name (e.g. POST, DELETE).
126         setupCreate();
127
128         AccountClient client = new AccountClient();
129         // Submit the request to the service and store the response.
130         AccountsCommon account =
131                 createAccountInstance(knownUserId, knownUserId, knownUserPassword,
132                 "barney@dinoland.com", client.getTenantId(),
133                 true, false, true, true);
134         ClientResponse<Response> res = client.create(account);
135         int statusCode = res.getStatus();
136
137         // Check the status code of the response: does it match
138         // the expected response(s)?
139         //
140         // Specifically:
141         // Does it fall within the set of valid status codes?
142         // Does it exactly match the expected status code?
143         if (logger.isDebugEnabled()) {
144             logger.debug(testName + ": status = " + statusCode);
145         }
146         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
147                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
148         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
149
150         // Store the ID returned from this create operation
151         // for additional tests below.
152         knownResourceId = extractId(res);
153         if (logger.isDebugEnabled()) {
154             logger.debug(testName + ": knownResourceId=" + knownResourceId);
155         }
156     }
157
158     /**
159      * Creates the for unique user.
160      *
161      * @param testName the test name
162      * @throws Exception the exception
163      */
164     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
165     dependsOnMethods = {"create"})
166     public void createForUniqueUser(String testName) throws Exception {
167
168         if (logger.isDebugEnabled()) {
169             logger.debug(testBanner(testName, CLASS_NAME));
170         }
171         setupCreate();
172
173         // Submit the request to the service and store the response.
174         AccountClient client = new AccountClient();
175         AccountsCommon account =
176                 createAccountInstance("barney1", knownUserId, knownUserPassword,
177                 "barney@dinoland.com",
178                 client.getTenantId(), true, false, true, true);
179
180         ClientResponse<Response> res = client.create(account);
181         int statusCode = res.getStatus();
182         if (logger.isDebugEnabled()) {
183             logger.debug(testName + ": status = " + statusCode);
184         }
185         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
186                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
187         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
188     }
189
190     /**
191      * Creates the with invalid tenant.
192      *
193      * @param testName the test name
194      * @throws Exception the exception
195      */
196     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
197     dependsOnMethods = {"create"})
198     public void createWithInvalidTenant(String testName) throws Exception {
199
200         if (logger.isDebugEnabled()) {
201             logger.debug(testBanner(testName, CLASS_NAME));
202         }
203         setupCreate();
204
205         // Submit the request to the service and store the response.
206         AccountClient client = new AccountClient();
207         AccountsCommon account =
208                 createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
209                 client.getTenantId(), true, true, true, true);
210         ClientResponse<Response> res = client.create(account);
211         int statusCode = res.getStatus();
212         // Does it exactly match the expected status code?
213         if (logger.isDebugEnabled()) {
214             logger.debug(testName + ": status = " + statusCode);
215         }
216         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
217                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
218         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
219
220     }
221
222     /**
223      * Creates the without user.
224      *
225      * @param testName the test name
226      * @throws Exception the exception
227      */
228     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
229     dependsOnMethods = {"create"})
230     public void createWithoutUser(String testName) throws Exception {
231
232         if (logger.isDebugEnabled()) {
233             logger.debug(testBanner(testName, CLASS_NAME));
234         }
235         setupCreate();
236
237         // Submit the request to the service and store the response.
238         AccountClient client = new AccountClient();
239         AccountsCommon account =
240                 createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
241                 client.getTenantId(), true, false, false, true);
242         ClientResponse<Response> res = client.create(account);
243         int statusCode = res.getStatus();
244         // Does it exactly match the expected status code?
245         if (logger.isDebugEnabled()) {
246             logger.debug(testName + ": status = " + statusCode);
247         }
248         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
249                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
250         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
251     }
252
253     /**
254      * Creates the with invalid email.
255      *
256      * @param testName the test name
257      * @throws Exception the exception
258      */
259     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
260     dependsOnMethods = {"create"})
261     public void createWithInvalidEmail(String testName) throws Exception {
262
263         if (logger.isDebugEnabled()) {
264             logger.debug(testBanner(testName, CLASS_NAME));
265         }
266         setupCreate();
267
268         // Submit the request to the service and store the response.
269         AccountClient client = new AccountClient();
270         AccountsCommon account =
271                 createAccountInstance("babybop", "babybop", "hithere08", "babybop.dinoland.com",
272                 client.getTenantId(), true, false, true, true);
273         ClientResponse<Response> res = client.create(account);
274         int statusCode = res.getStatus();
275         // Does it exactly match the expected status code?
276         if (logger.isDebugEnabled()) {
277             logger.debug(testName + ": status = " + statusCode);
278         }
279         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
280                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
281         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
282     }
283
284     /**
285      * Creates the without screen name.
286      *
287      * @param testName the test name
288      * @throws Exception the exception
289      */
290     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
291     dependsOnMethods = {"create"})
292     public void createWithoutScreenName(String testName) throws Exception {
293
294         if (logger.isDebugEnabled()) {
295             logger.debug(testBanner(testName, CLASS_NAME));
296         }
297         setupCreate();
298
299         // Submit the request to the service and store the response.
300         AccountClient client = new AccountClient();
301         AccountsCommon account =
302                 createAccountInstance("babybop", "babybop", "hithere08", "babybop@dinoland.com",
303                 client.getTenantId(), false, false, true, true);
304         ClientResponse<Response> res = client.create(account);
305         int statusCode = res.getStatus();
306         // Does it exactly match the expected status code?
307         if (logger.isDebugEnabled()) {
308             logger.debug(testName + ": status = " + statusCode);
309         }
310         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
311                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
312         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
313     }
314
315     /**
316      * Creates the with invalid password.
317      *
318      * @param testName the test name
319      * @throws Exception the exception
320      */
321     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
322     dependsOnMethods = {"create"})
323     public void createWithInvalidPassword(String testName) throws Exception {
324
325         if (logger.isDebugEnabled()) {
326             logger.debug(testBanner(testName, CLASS_NAME));
327         }
328         setupCreate();
329
330         // Submit the request to the service and store the response.
331         AccountClient client = new AccountClient();
332         AccountsCommon account =
333                 createAccountInstance("babybop", "babybop", "shpswd", "babybop@dinoland.com",
334                 client.getTenantId(), true, false, true, true);
335         ClientResponse<Response> res = client.create(account);
336         int statusCode = res.getStatus();
337         // Does it exactly match the expected status code?
338         if (logger.isDebugEnabled()) {
339             logger.debug(testName + ": status = " + statusCode);
340         }
341         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
342                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
343         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
344     }
345
346     /**
347      * Creates the with most invalid.
348      *
349      * @param testName the test name
350      * @throws Exception the exception
351      */
352     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
353     dependsOnMethods = {"create"})
354     public void createWithMostInvalid(String testName) throws Exception {
355
356         if (logger.isDebugEnabled()) {
357             logger.debug(testBanner(testName, CLASS_NAME));
358         }
359         setupCreate();
360
361         // Submit the request to the service and store the response.
362         AccountClient client = new AccountClient();
363         AccountsCommon account =
364                 createAccountInstance("babybop", "babybop", "hithere08", "babybop/dinoland.com",
365                 client.getTenantId(), false, true, false, false);
366         ClientResponse<Response> res = client.create(account);
367         int statusCode = res.getStatus();
368         // Does it exactly match the expected status code?
369         if (logger.isDebugEnabled()) {
370             logger.debug(testName + ": status = " + statusCode);
371         }
372         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
373                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
374         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
375     }
376
377     //to not cause uniqueness violation for account, createList is removed
378     /* (non-Javadoc)
379      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
380      */
381     @Override
382     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
383     dependsOnMethods = {"create"})
384     public void createList(String testName) throws Exception {
385
386         if (logger.isDebugEnabled()) {
387             logger.debug(testBanner(testName, CLASS_NAME));
388         }
389         setupCreate();
390         // Submit the request to the service and store the response.
391         AccountClient client = new AccountClient();
392         AccountsCommon account1 =
393                 createAccountInstance("curious", "curious", "hithere08", "curious@george.com",
394                 client.getTenantId(), true, false, true, true);
395         ClientResponse<Response> res = client.create(account1);
396         int statusCode = res.getStatus();
397         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
398                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
399         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
400         allResourceIdsCreated.add(extractId(res));
401
402         AccountsCommon account2 =
403                 createAccountInstance("tom", "tom", "hithere09", "tom@jerry.com",
404                 client.getTenantId(), true, false, true, true);
405         res = client.create(account2);
406         statusCode = res.getStatus();
407         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
408                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
409         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
410         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
411         allResourceIdsCreated.add(extractId(res));
412
413         AccountsCommon account3 =
414                 createAccountInstance("mj", "mj", "hithere10", "mj@dinoland.com",
415                 client.getTenantId(), true, false, true, true);
416         res = client.create(account3);
417         statusCode = res.getStatus();
418         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
419                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
420         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
421         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
422         allResourceIdsCreated.add(extractId(res));
423     }
424
425     // Failure outcomes
426     // Placeholders until the three tests below can be uncommented.
427     // See Issue CSPACE-401.
428     /* (non-Javadoc)
429      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
430      */
431     @Override
432     public void createWithEmptyEntityBody(String testName) throws Exception {
433         //FIXME: Should this test really be empty?  If so, please comment accordingly.
434     }
435
436     /* (non-Javadoc)
437      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
438      */
439     @Override
440     public void createWithMalformedXml(String testName) throws Exception {
441         //FIXME: Should this test really be empty?  If so, please comment accordingly.
442     }
443
444     /* (non-Javadoc)
445      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
446      */
447     @Override
448     public void createWithWrongXmlSchema(String testName) throws Exception {
449         //FIXME: Should this test really be empty?  If so, please comment accordingly.
450     }
451
452     // ---------------------------------------------------------------
453     // CRUD tests : READ tests
454     // ---------------------------------------------------------------
455     // Success outcomes
456     /* (non-Javadoc)
457      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
458      */
459     @Override
460     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
461     dependsOnMethods = {"create"})
462     public void read(String testName) throws Exception {
463
464         if (logger.isDebugEnabled()) {
465             logger.debug(testBanner(testName, CLASS_NAME));
466         }
467         // Perform setup.
468         setupRead();
469
470         // Submit the request to the service and store the response.
471         AccountClient client = new AccountClient();
472         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
473         int statusCode = res.getStatus();
474
475         // Check the status code of the response: does it match
476         // the expected response(s)?
477         if (logger.isDebugEnabled()) {
478             logger.debug(testName + ": status = " + statusCode);
479         }
480         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
481                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
482         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
483
484         AccountsCommon output = (AccountsCommon) res.getEntity();
485         Assert.assertNotNull(output);
486     }
487
488     // Failure outcomes
489     /* (non-Javadoc)
490      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
491      */
492     @Override
493     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
494     dependsOnMethods = {"read"})
495     public void readNonExistent(String testName) throws Exception {
496
497         if (logger.isDebugEnabled()) {
498             logger.debug(testBanner(testName, CLASS_NAME));
499         }
500         // Perform setup.
501         setupReadNonExistent();
502
503         // Submit the request to the service and store the response.
504         AccountClient client = new AccountClient();
505         ClientResponse<AccountsCommon> res = client.read(NON_EXISTENT_ID);
506         int statusCode = res.getStatus();
507
508         // Check the status code of the response: does it match
509         // the expected response(s)?
510         if (logger.isDebugEnabled()) {
511             logger.debug(testName + ": status = " + statusCode);
512         }
513         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
514                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
515         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
516     }
517
518     // ---------------------------------------------------------------
519     // CRUD tests : READ_LIST tests
520     // ---------------------------------------------------------------
521     // Success outcomes
522     /* (non-Javadoc)
523      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
524      */
525     @Override
526     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
527     dependsOnMethods = {"createList", "read"})
528     public void readList(String testName) throws Exception {
529
530         if (logger.isDebugEnabled()) {
531             logger.debug(testBanner(testName, CLASS_NAME));
532         }
533         // Perform setup.
534         setupReadList();
535
536         // Submit the request to the service and store the response.
537         AccountClient client = new AccountClient();
538         ClientResponse<AccountsCommonList> res = client.readList();
539         AccountsCommonList list = res.getEntity();
540         int statusCode = res.getStatus();
541
542         // Check the status code of the response: does it match
543         // the expected response(s)?
544         if (logger.isDebugEnabled()) {
545             logger.debug(testName + ": status = " + statusCode);
546         }
547         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
548                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
549         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
550
551         // Optionally output additional data about list members for debugging.
552         boolean iterateThroughList = true;
553         if (iterateThroughList && logger.isDebugEnabled()) {
554             printList(testName, list);
555         }
556     }
557
558     /**
559      * Search screen name.
560      *
561      * @param testName the test name
562      * @throws Exception the exception
563      */
564     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
565     dependsOnMethods = {"createList", "read"})
566     public void searchScreenName(String testName) throws Exception {
567
568         if (logger.isDebugEnabled()) {
569             logger.debug(testBanner(testName, CLASS_NAME));
570         }
571         // Perform setup.
572         setupReadList();
573
574         // Submit the request to the service and store the response.
575         AccountClient client = new AccountClient();
576         ClientResponse<AccountsCommonList> res =
577                 client.readSearchList("tom", null, null);
578         AccountsCommonList list = res.getEntity();
579         int statusCode = res.getStatus();
580
581         // Check the status code of the response: does it match
582         // the expected response(s)?
583         if (logger.isDebugEnabled()) {
584             logger.debug(testName + ": status = " + statusCode);
585         }
586         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
587                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
588         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
589         Assert.assertEquals(1, list.getAccountListItem().size());
590         // Optionally output additional data about list members for debugging.
591         boolean iterateThroughList = true;
592         if (iterateThroughList && logger.isDebugEnabled()) {
593             printList(testName, list);
594         }
595     }
596
597     /**
598      * Search user id.
599      *
600      * @param testName the test name
601      * @throws Exception the exception
602      */
603     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
604     dependsOnMethods = {"createList", "read"})
605     public void searchUserId(String testName) throws Exception {
606
607         if (logger.isDebugEnabled()) {
608             logger.debug(testBanner(testName, CLASS_NAME));
609         }
610         // Perform setup.
611         setupReadList();
612
613         // Submit the request to the service and store the response.
614         AccountClient client = new AccountClient();
615         ClientResponse<AccountsCommonList> res =
616                 client.readSearchList(null, "tom", null);
617         AccountsCommonList list = res.getEntity();
618         int statusCode = res.getStatus();
619
620         // Check the status code of the response: does it match
621         // the expected response(s)?
622         if (logger.isDebugEnabled()) {
623             logger.debug(testName + ": status = " + statusCode);
624         }
625         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
626                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
627         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
628         Assert.assertEquals(1, list.getAccountListItem().size());
629         // Optionally output additional data about list members for debugging.
630         boolean iterateThroughList = true;
631         if (iterateThroughList && logger.isDebugEnabled()) {
632             printList(testName, list);
633         }
634     }
635
636     /**
637      * Search email.
638      *
639      * @param testName the test name
640      * @throws Exception the exception
641      */
642     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
643     dependsOnMethods = {"createList", "read"})
644     public void searchEmail(String testName) throws Exception {
645
646         if (logger.isDebugEnabled()) {
647             logger.debug(testBanner(testName, CLASS_NAME));
648         }
649         // Perform setup.
650         setupReadList();
651
652         // Submit the request to the service and store the response.
653         AccountClient client = new AccountClient();
654         ClientResponse<AccountsCommonList> res =
655                 client.readSearchList(null, null, "dinoland");
656         AccountsCommonList list = res.getEntity();
657         int statusCode = res.getStatus();
658
659         // Check the status code of the response: does it match
660         // the expected response(s)?
661         if (logger.isDebugEnabled()) {
662             logger.debug(testName + ": status = " + statusCode);
663         }
664         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
665                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
666         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
667         Assert.assertEquals(2, list.getAccountListItem().size());
668         // Optionally output additional data about list members for debugging.
669         boolean iterateThroughList = true;
670         if (iterateThroughList && logger.isDebugEnabled()) {
671             printList(testName, list);
672         }
673     }
674
675     /**
676      * Search screen name email.
677      *
678      * @param testName the test name
679      * @throws Exception the exception
680      */
681     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
682     dependsOnMethods = {"createList", "read"})
683     public void searchScreenNameEmail(String testName) throws Exception {
684
685         if (logger.isDebugEnabled()) {
686             logger.debug(testBanner(testName, CLASS_NAME));
687         }
688         // Perform setup.
689         setupReadList();
690
691         // Submit the request to the service and store the response.
692         AccountClient client = new AccountClient();
693         ClientResponse<AccountsCommonList> res =
694                 client.readSearchList("tom", null, "jerry");
695         AccountsCommonList list = res.getEntity();
696         int statusCode = res.getStatus();
697
698         // Check the status code of the response: does it match
699         // the expected response(s)?
700         if (logger.isDebugEnabled()) {
701             logger.debug(testName + ": status = " + statusCode);
702         }
703         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
704                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
705         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
706         Assert.assertEquals(1, list.getAccountListItem().size());
707         // Optionally output additional data about list members for debugging.
708         boolean iterateThroughList = true;
709         if (iterateThroughList && logger.isDebugEnabled()) {
710             printList(testName, list);
711         }
712     }
713
714     // Failure outcomes
715     // None at present.
716     // ---------------------------------------------------------------
717     // CRUD tests : UPDATE tests
718     // ---------------------------------------------------------------
719     // Success outcomes
720     /* (non-Javadoc)
721      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
722      */
723     @Override
724     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
725     dependsOnMethods = {"read", "readList", "readNonExistent"})
726     public void update(String testName) throws Exception {
727
728         if (logger.isDebugEnabled()) {
729             logger.debug(testBanner(testName, CLASS_NAME));
730         }
731         // Perform setup.
732         setupUpdate();
733
734         AccountClient client = new AccountClient();
735         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
736         if (logger.isDebugEnabled()) {
737             logger.debug(testName + ": read status = " + res.getStatus());
738         }
739         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
740
741         if (logger.isDebugEnabled()) {
742             logger.debug("got object to update with ID: " + knownResourceId);
743         }
744         AccountsCommon accountFound =
745                 (AccountsCommon) res.getEntity();
746         Assert.assertNotNull(accountFound);
747
748         //create a new account object to test partial updates
749         AccountsCommon accountToUpdate = new AccountsCommon();
750         accountToUpdate.setCsid(knownResourceId);
751         accountToUpdate.setUserId(accountFound.getUserId());
752         // Update the content of this resource.
753         accountToUpdate.setEmail("updated-" + accountFound.getEmail());
754         if (logger.isDebugEnabled()) {
755             logger.debug("updated object");
756             logger.debug(objectAsXmlString(accountFound,
757                     AccountsCommon.class));
758         }
759
760         // Submit the request to the service and store the response.
761         res = client.update(knownResourceId, accountToUpdate);
762         int statusCode = res.getStatus();
763         // Check the status code of the response: does it match the expected response(s)?
764         if (logger.isDebugEnabled()) {
765             logger.debug(testName + ": status = " + statusCode);
766         }
767         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
768                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
769         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
770
771         AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
772         Assert.assertNotNull(accountUpdated);
773
774         Assert.assertEquals(accountUpdated.getEmail(),
775                 accountToUpdate.getEmail(),
776                 "Data in updated object did not match submitted data.");
777     }
778
779     /**
780      * Update password.
781      *
782      * @param testName the test name
783      * @throws Exception the exception
784      */
785     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
786     dependsOnMethods = {"update"})
787     public void updatePassword(String testName) throws Exception {
788
789         if (logger.isDebugEnabled()) {
790             logger.debug(testBanner(testName, CLASS_NAME));
791         }
792         // Perform setup.
793         setupUpdate();
794
795         AccountClient client = new AccountClient();
796         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
797         if (logger.isDebugEnabled()) {
798             logger.debug(testName + ": read status = " + res.getStatus());
799         }
800         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
801
802         if (logger.isDebugEnabled()) {
803             logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
804         }
805         AccountsCommon accountFound =
806                 (AccountsCommon) res.getEntity();
807         Assert.assertNotNull(accountFound);
808
809         //create a new account object to test partial updates
810         AccountsCommon accountToUpdate = new AccountsCommon();
811         accountToUpdate.setCsid(knownResourceId);
812         accountToUpdate.setUserId(accountFound.getUserId());
813         //change password
814         accountToUpdate.setPassword("imagination".getBytes());
815         if (logger.isDebugEnabled()) {
816             logger.debug(testName + ": updated object");
817             logger.debug(objectAsXmlString(accountToUpdate,
818                     AccountsCommon.class));
819         }
820
821         // Submit the request to the service and store the response.
822         res = client.update(knownResourceId, accountToUpdate);
823         int statusCode = res.getStatus();
824         // Check the status code of the response: does it match the expected response(s)?
825         if (logger.isDebugEnabled()) {
826             logger.debug(testName + ": status = " + statusCode);
827         }
828         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
829                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
830         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
831
832
833         AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
834         Assert.assertNotNull(accountUpdated);
835
836 //        Assert.assertEquals(accountUpdated.getPassword(),
837 //                accountFound.getPassword(),
838 //                "Data in updated object did not match submitted data.");
839     }
840
841     /**
842      * Update password without user.
843      *
844      * @param testName the test name
845      * @throws Exception the exception
846      */
847     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
848     dependsOnMethods = {"update"})
849     public void updatePasswordWithoutUser(String testName) throws Exception {
850
851         if (logger.isDebugEnabled()) {
852             logger.debug(testBanner(testName, CLASS_NAME));
853         }
854         // Perform setup.
855         setupUpdate();
856
857         AccountsCommon accountToUpdate = new AccountsCommon();
858         accountToUpdate.setCsid(knownResourceId);
859         accountToUpdate.setUserId(null);
860         //change password
861         accountToUpdate.setPassword("imagination".getBytes());
862         if (logger.isDebugEnabled()) {
863             logger.debug(testName + " : updated object");
864             logger.debug(objectAsXmlString(accountToUpdate,
865                     AccountsCommon.class));
866         }
867
868         AccountClient client = new AccountClient();
869         // Submit the request to the service and store the response.
870         ClientResponse<AccountsCommon> res = client.update(knownResourceId, accountToUpdate);
871         int statusCode = res.getStatus();
872         // Check the status code of the response: does it match the expected response(s)?
873         if (logger.isDebugEnabled()) {
874             logger.debug(testName + ": status = " + statusCode);
875         }
876         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
877                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
878         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
879
880     }
881
882     /**
883      * Update invalid password.
884      *
885      * @param testName the test name
886      * @throws Exception the exception
887      */
888     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
889     dependsOnMethods = {"update"})
890     public void updateInvalidPassword(String testName) throws Exception {
891
892         if (logger.isDebugEnabled()) {
893             logger.debug(testBanner(testName, CLASS_NAME));
894         }
895         // Perform setup.
896         setupUpdate();
897         AccountClient client = new AccountClient();
898         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
899         if (logger.isDebugEnabled()) {
900             logger.debug(testName + ": read status = " + res.getStatus());
901         }
902         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
903
904         if (logger.isDebugEnabled()) {
905             logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
906         }
907         AccountsCommon accountFound = (AccountsCommon) res.getEntity();
908
909         AccountsCommon accountToUpdate = new AccountsCommon();
910         accountToUpdate.setCsid(knownResourceId);
911         accountToUpdate.setUserId(accountFound.getUserId());
912         Assert.assertNotNull(accountToUpdate);
913
914         //change password
915         accountToUpdate.setPassword("abc123".getBytes());
916         if (logger.isDebugEnabled()) {
917             logger.debug(testName + ": updated object");
918             logger.debug(objectAsXmlString(accountToUpdate,
919                     AccountsCommon.class));
920         }
921
922         // Submit the request to the service and store the response.
923         res = client.update(knownResourceId, accountToUpdate);
924         int statusCode = res.getStatus();
925         // Check the status code of the response: does it match the expected response(s)?
926         if (logger.isDebugEnabled()) {
927             logger.debug(testName + ": status = " + statusCode);
928         }
929         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
930                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
931         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
932
933     }
934
935     /**
936      * Deactivate.
937      *
938      * @param testName the test name
939      * @throws Exception the exception
940      */
941     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
942     dependsOnMethods = {"updatePasswordWithoutUser"})
943     public void deactivate(String testName) throws Exception {
944
945         if (logger.isDebugEnabled()) {
946             logger.debug(testBanner(testName, CLASS_NAME));
947         }
948         // Perform setup.
949         setupUpdate();
950
951         AccountClient client = new AccountClient();
952         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
953         if (logger.isDebugEnabled()) {
954             logger.debug(testName + ": read status = " + res.getStatus());
955         }
956         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
957
958         if (logger.isDebugEnabled()) {
959             logger.debug("got object to update with ID: " + knownResourceId);
960         }
961         AccountsCommon accountFound = (AccountsCommon) res.getEntity();
962
963         //create a new account object to test partial updates
964         AccountsCommon accountToUpdate = new AccountsCommon();
965         accountToUpdate.setCsid(knownResourceId);
966         accountToUpdate.setUserId(accountFound.getUserId());
967
968         // Update the content of this resource.
969         accountToUpdate.setStatus(Status.INACTIVE);
970         if (logger.isDebugEnabled()) {
971             logger.debug("updated object");
972             logger.debug(objectAsXmlString(accountToUpdate,
973                     AccountsCommon.class));
974         }
975
976         // Submit the request to the service and store the response.
977         res = client.update(knownResourceId, accountToUpdate);
978         int statusCode = res.getStatus();
979         // Check the status code of the response: does it match the expected response(s)?
980         if (logger.isDebugEnabled()) {
981             logger.debug(testName + ": status = " + statusCode);
982         }
983         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
984                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
985         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
986
987         AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
988         Assert.assertNotNull(accountUpdated);
989
990         Assert.assertEquals(accountUpdated.getStatus(),
991                 accountToUpdate.getStatus(),
992                 "Data in updated object did not match submitted data.");
993
994     }
995
996     // Failure outcomes
997     // Placeholders until the three tests below can be uncommented.
998     // See Issue CSPACE-401.
999     /* (non-Javadoc)
1000      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
1001      */
1002     @Override
1003     public void updateWithEmptyEntityBody(String testName) throws Exception {
1004         //FIXME: Should this test really be empty?  If so, please comment accordingly.
1005     }
1006
1007     /* (non-Javadoc)
1008      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
1009      */
1010     @Override
1011     public void updateWithMalformedXml(String testName) throws Exception {
1012         //FIXME: Should this test really be empty?  If so, please comment accordingly.
1013     }
1014
1015     /* (non-Javadoc)
1016      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
1017      */
1018     @Override
1019     public void updateWithWrongXmlSchema(String testName) throws Exception {
1020         //FIXME: Should this test really be empty?  If so, please comment accordingly.
1021     }
1022
1023     /* (non-Javadoc)
1024      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
1025      */
1026     @Override
1027     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1028     dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
1029     public void updateNonExistent(String testName) throws Exception {
1030
1031         if (logger.isDebugEnabled()) {
1032             logger.debug(testBanner(testName, CLASS_NAME));
1033         }
1034         // Perform setup.
1035         setupUpdateNonExistent();
1036
1037         // Submit the request to the service and store the response.
1038         //
1039         // Note: The ID used in this 'create' call may be arbitrary.
1040         // The only relevant ID may be the one used in updateAccount(), below.
1041         AccountClient client = new AccountClient();
1042         AccountsCommon account =
1043                 createAccountInstance("simba", "simba", "tiger", "simba@lionking.com",
1044                 client.getTenantId(), true, false, true, true);
1045         ClientResponse<AccountsCommon> res =
1046                 client.update(NON_EXISTENT_ID, account);
1047         int statusCode = res.getStatus();
1048
1049         // Check the status code of the response: does it match
1050         // the expected response(s)?
1051         if (logger.isDebugEnabled()) {
1052             logger.debug(testName + ": status = " + statusCode);
1053         }
1054         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1055                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1056         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1057     }
1058
1059     /**
1060      * Update wrong user.
1061      *
1062      * @param testName the test name
1063      * @throws Exception the exception
1064      */
1065     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1066     dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
1067     public void updateWrongUser(String testName) throws Exception {
1068
1069         if (logger.isDebugEnabled()) {
1070             logger.debug(testBanner(testName, CLASS_NAME));
1071         }
1072         setupUpdate();
1073
1074         // Submit the request to the service and store the response.
1075         //
1076         // Note: The ID used in this 'create' call may be arbitrary.
1077         // The only relevant ID may be the one used in updateAccount(), below.
1078         AccountClient client = new AccountClient();
1079         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
1080         if (logger.isDebugEnabled()) {
1081             logger.debug(testName + ": read status = " + res.getStatus());
1082         }
1083         Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
1084
1085         if (logger.isDebugEnabled()) {
1086             logger.debug("got object to update with ID: " + knownResourceId);
1087         }
1088         AccountsCommon accountToUpdate =
1089                 (AccountsCommon) res.getEntity();
1090         Assert.assertNotNull(accountToUpdate);
1091
1092         accountToUpdate.setUserId("barneyFake");
1093         if (logger.isDebugEnabled()) {
1094             logger.debug("updated object with wrongUser");
1095             logger.debug(objectAsXmlString(accountToUpdate,
1096                     AccountsCommon.class));
1097         }
1098
1099         res = client.update(knownResourceId, accountToUpdate);
1100         int statusCode = res.getStatus();
1101
1102         // Check the status code of the response: does it match
1103         // the expected response(s)?
1104         if (logger.isDebugEnabled()) {
1105             logger.debug(testName + ": status = " + statusCode);
1106         }
1107         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1108                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1109         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
1110     }
1111
1112     // ---------------------------------------------------------------
1113     // CRUD tests : DELETE tests
1114     // ---------------------------------------------------------------
1115     // Success outcomes
1116     /* (non-Javadoc)
1117      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
1118      */
1119     @Override
1120     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1121     dependsOnMethods = {"testSubmitRequest", "updateWrongUser"})
1122     public void delete(String testName) throws Exception {
1123
1124         if (logger.isDebugEnabled()) {
1125             logger.debug(testBanner(testName, CLASS_NAME));
1126         }
1127         // Perform setup.
1128         setupDelete();
1129
1130         // Submit the request to the service and store the response.
1131         AccountClient client = new AccountClient();
1132         ClientResponse<Response> res = client.delete(knownResourceId);
1133         int statusCode = res.getStatus();
1134
1135         // Check the status code of the response: does it match
1136         // the expected response(s)?
1137         if (logger.isDebugEnabled()) {
1138             logger.debug(testName + ": status = " + statusCode);
1139         }
1140         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1141                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1142         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1143     }
1144
1145     // Failure outcomes
1146     /* (non-Javadoc)
1147      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
1148      */
1149     @Override
1150     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
1151     dependsOnMethods = {"delete"})
1152     public void deleteNonExistent(String testName) throws Exception {
1153
1154         if (logger.isDebugEnabled()) {
1155             logger.debug(testBanner(testName, CLASS_NAME));
1156         }
1157         // Perform setup.
1158         setupDeleteNonExistent();
1159
1160         // Submit the request to the service and store the response.
1161         AccountClient client = new AccountClient();
1162         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
1163         int statusCode = res.getStatus();
1164
1165         // Check the status code of the response: does it match
1166         // the expected response(s)?
1167         if (logger.isDebugEnabled()) {
1168             logger.debug(testName + ": status = " + statusCode);
1169         }
1170         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
1171                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
1172         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1173     }
1174
1175     // ---------------------------------------------------------------
1176     // Search tests
1177     // ---------------------------------------------------------------
1178     
1179     @Override
1180     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
1181     public void searchWorkflowDeleted(String testName) throws Exception {
1182         // Fixme: null test for now, overriding test in base class
1183     }
1184     
1185     // ---------------------------------------------------------------
1186     // Utility tests : tests of code used in tests above
1187     // ---------------------------------------------------------------
1188     /**
1189      * Tests the code for manually submitting data that is used by several
1190      * of the methods above.
1191      * @throws Exception 
1192      */
1193     @Test(dependsOnMethods = {"create", "read"})
1194     public void testSubmitRequest() throws Exception {
1195
1196         setupRead();
1197
1198         // Submit the request to the service and store the response.
1199         String method = ServiceRequestType.READ.httpMethodName();
1200         String url = getResourceURL(knownResourceId);
1201         int statusCode = submitRequest(method, url);
1202
1203         // Check the status code of the response: does it match
1204         // the expected response(s)?
1205         if (logger.isDebugEnabled()) {
1206             logger.debug("testSubmitRequest: url=" + url
1207                     + " status=" + statusCode);
1208         }
1209         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
1210
1211     }
1212
1213     // ---------------------------------------------------------------
1214     // Utility methods used by tests above
1215     // ---------------------------------------------------------------
1216     /**
1217      * create account instance
1218      * @param screenName
1219      * @param userName
1220      * @param passwd
1221      * @param email
1222      * @param useScreenName
1223      * @param invalidTenant
1224      * @param useUser
1225      * @param usePassword
1226      * @return
1227      */
1228     AccountsCommon createAccountInstance(String screenName,
1229             String userName, String passwd, String email, String tenantId,
1230             boolean useScreenName, boolean invalidTenant, boolean useUser, boolean usePassword) {
1231
1232         AccountsCommon account = AccountFactory.createAccountInstance(screenName,
1233                 userName, passwd, email, tenantId, useScreenName,
1234                 invalidTenant, useUser, usePassword);
1235         if (logger.isDebugEnabled()) {
1236             logger.debug("to be created, account common");
1237             logger.debug(objectAsXmlString(account,
1238                     AccountsCommon.class));
1239         }
1240         return account;
1241
1242     }
1243
1244
1245     /**
1246      * Prints the list.
1247      *
1248      * @param testName the test name
1249      * @param list the list
1250      */
1251     private void printList(String testName, AccountsCommonList list) {
1252         List<AccountsCommonList.AccountListItem> items =
1253                 list.getAccountListItem();
1254         int i = 0;
1255
1256         for (AccountsCommonList.AccountListItem item : items) {
1257             logger.debug(testName + ": list-item[" + i + "] csid="
1258                     + item.getCsid());
1259             logger.debug(testName + ": list-item[" + i + "] screenName="
1260                     + item.getScreenName());
1261             logger.debug(testName + ": list-item[" + i + "] URI="
1262                     + item.getUri());
1263             i++;
1264
1265         }
1266     }
1267 }