using System; using TestFramework.ApplicationAPI; using TestFramework.AuthenticateAPI; using TestFramework; namespace Tests.pool { /// <summary> /// Summary description for PoolRef. /// /// This sample creates a reference and assigns it /// to an existing pool. /// </summary> public class PoolRef { public PoolRef() { } //All these variables are used in this sample public static String poolName = "IBMPOOL_123"; public static String orgName = "IBMORGANIZATION"; public static String orgAdr= "ADR_123"; public static String conName = "IBMCONTACT"; //Session ID is use for all transaction and is get from the //Authenticate.login function. The session ID will replace the //User password while transacting public static String sessionid = ""; public void sampleTest() { // start the communication with the api sessionid = APISetup.SetUp(); // Declare the pool wich we are going to use Pool pool = null; // create a poolscope to keep // track of the relation between // the pool and its attribute PoolScope pScope = new PoolScope(); // create a pool reference scope PoolReferenceScope prScope = new PoolReferenceScope(); // adjust the pool reference scope // to imply the company size prScope.companySize = true; // assign the scope to link with its attribute pScope.poolReferences = prScope; // declare a save result object SaveResult pSave = null; // retrieve the pool in RPM using XPath. pool = (Pool)APISetup.application.loadFromXpath(sessionid, "/Pool[name='" + poolName + "']", pScope).rpmObjectList[0]; // create a pool reference PoolReference pRef = new PoolReference(); // assign the pool as the parent of the reference pRef.parent = pool; // initialize the reference pRef.organizationName = orgName; pRef.organizationAddress = orgAdr; pRef.companySize = (CompanySize)APISetup.application. loadFromXpath(sessionid, "/Companysize", null).rpmObjectList[0]; pRef.contactName = conName; // assign the reference to the pool pool.poolReferences = new PoolReference[] {pRef}; // save the pool in the RPM repository // use the sessionid acquired in the setUp // a scope is necessary to keep the reference pSave = new SaveResult(); pSave = APISetup.application.save(sessionid, pool, pScope, ReloadType.SavedResult ); // method showing the detail of any error in the save APISetup.checkForErrors( pSave ); // end the communication with the api. APISetup.CleanUp(sessionid); } } }