You are on page 1of 14

public void testParameterisedDeclarePageLoadOnlyLoadActivity() { mSession.

doWithSession(new UserSessionAction() { @Override public void action() throws Exception { RuleObjProperty propInt = new RuleObjProperty(th is, "PegaSample", "propInt"); propInt.setSingleValueWithType(RuleObjProperty.T YPE_INTEGER); assertSave(propInt); RuleObjProperty propString = new RuleObjProperty (this, "PegaSample", "propString"); propString.setSingleValueWithType(RuleObjPropert y.TYPE_TEXT); assertSave(propString); RuleObjProperty propBool = new RuleObjProperty(t his, "PegaSample", "propBool"); propString.setSingleValueWithType(RuleObjPropert y.TYPE_TEXT); assertSave(propBool); RuleObjProperty propTrueFalse = new RuleObjPrope rty(this, "PegaSample", "propTrueFalse"); propTrueFalse.setSingleValueWithType(RuleObjProp erty.TYPE_TRUEFALSE); assertSave(propTrueFalse); RuleObjProperty propDate = new RuleObjProperty(t his, "PegaSample", "propDate"); propDate.setSingleValueWithType(RuleObjProperty. TYPE_DATE); assertSave(propDate); RuleObjProperty propDateTime = new RuleObjProper ty(this, "PegaSample", "propDateTime"); propDateTime.setSingleValueWithType(RuleObjPrope rty.TYPE_DATETIME); assertSave(propDateTime); RuleObjProperty propDecimal = new RuleObjPropert y(this, "PegaSample", "propDecimal"); propDecimal.setSingleValueWithType(RuleObjProper ty.TYPE_DECIMAL); assertSave(propDecimal); RuleObjProperty propDouble = new RuleObjProperty (this, "PegaSample", "propDouble"); propDouble.setSingleValueWithType(RuleObjPropert y.TYPE_DOUBLE); assertSave(propDouble); RuleObjProperty propTimeOfDay = new RuleObjPrope rty(this, "PegaSample", "propTimeOfDay"); propTimeOfDay.setSingleValueWithType(RuleObjProp

erty.TYPE_TIMEOFDAY); assertSave(propTimeOfDay); RuleObjProperty propPageName = new RuleObjProper ty(this, "PegaSample", "propPageName"); propPageName.setPageValueWithClass("PegaSample") ; assertSave(propPageName);

RuleObjActivity roaDeclLoader = new RuleObjActiv ity(this, "PegaSample", "LoadDeclPage"); roaDeclLoader.setActivityType(RuleObjActivity.TY PE_LOADDECLARATIVEPAGE); roaDeclLoader.addPagesAndClassesEntry("paramPage Name", "PegaSample"); roaDeclLoader.addParameter("paramInt", RuleObjAc tivity.PARAM_INTEGER); roaDeclLoader.addParameter("paramString", RuleOb jActivity.PARAM_STRING); roaDeclLoader.addParameter("paramBoolean", RuleO bjActivity.PARAM_BOOLEAN); roaDeclLoader.addParameter("paramDate", RuleObjA ctivity.PARAM_DATE); roaDeclLoader.addParameter("paramDateTime", Rule ObjActivity.PARAM_DATETIME); roaDeclLoader.addParameter("paramDecimal", RuleO bjActivity.PARAM_DECIMAL); roaDeclLoader.addParameter("paramDouble", RuleOb jActivity.PARAM_DOUBLE); //roaDeclLoader.addParameter("paramJaveObject", RuleObjActivity.PARAM_JAVA_OBJECT); roaDeclLoader.addParameter("paramPageName", Rule ObjActivity.PARAM_PAGE_NAME); roaDeclLoader.addParameter("paramTimeOfDay", Rul eObjActivity.PARAM_TIMEOFDAY); roaDeclLoader.addParameter("paramTrueFalse", Rul eObjActivity.PARAM_TRUEFALSE); // Populate the declarative page PropertySet step1PropertySet = (PropertySet) roa DeclLoader.defineStep(1, RuleObjActivity.METHOD_PROPERTY_ SET, ""); step1PropertySet.addSet(".propInt", "Param.param Int"); step1PropertySet.addSet(".propString", "Param.pa ramString"); step1PropertySet.addSet(".propTrueFalse", "Param .paramTrueFalse"); step1PropertySet.addSet(".propDate", "Param.para mDate "); step1PropertySet.addSet(".propDateTime", "Param. paramDateTime"); step1PropertySet.addSet(".propDecimal", "Param.p aramDecimal"); step1PropertySet.addSet(".propDouble", "Param.pa ramDouble");

step1PropertySet.addSet(".propTimeOfDay", "Param .paramTimeOfDay"); step1PropertySet.addSet(".propPageName", "Param. paramPageName"); step1PropertySet.addSet(".propBool", "Param.para mBoolean"); // save the activity assertSave(roaDeclLoader); RuleDeclarePages rdpDeclarePageTest = new RuleDe clarePages(this, DECLARE_PAGE_NAME); rdpDeclarePageTest.setScope(Scope.thread); rdpDeclarePageTest.setType(Type.loadonly); rdpDeclarePageTest.setPageClass("PegaSample"); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Adding parameter to Declare Page rdpDeclarePageTest.addDeclarePageParameter("DPpa ramInt", RuleDeclarePages.PARAM_INTEGER); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramString", RuleDeclarePages.PARAM_STRING); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramDate", RuleDeclarePages.PARAM_DATETIME); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramDateTime", RuleDeclarePages.PARAM_DATETIME); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramDecimal", RuleDeclarePages.PARAM_DECIMAL); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramDouble", RuleDeclarePages.PARAM_DOUBLE); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramTimeOfDay", RuleDeclarePages.PARAM_TIMEOFDAY); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramTrueFalse", RuleDeclarePages.PARAM_TRUEFALSE); rdpDeclarePageTest.addDeclarePageParameter("DPBo ol", RuleDeclarePages.PARAM_BOOLEAN); rdpDeclarePageTest.addDeclarePageParameter("DPPa geName", RuleDeclarePages.PARAM_PAGE_NAME); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Assigning values to params of activity with Pa rams of DP. StringMap sm = new HashStringMap(); sm.putString("paramInt", "Param.DPparamInt"); sm.putString("paramString", "Param.DPparamString "); sm.putString("paramDate", "Param.DPparamDate"); sm.putString("paramDateTime", "Param.DPparamDate Time"); sm.putString("paramDecimal", "Param.DPparamDecim al"); sm.putString("paramDouble", "Param.DPparamDouble "); sm.putString("paramTimeOfDay", "Param.DPparamTim eOfDay"); sm.putString("paramTrueFalse", "Param.DPparamTru eFalse"); sm.putString("paramBoolean", "Param.DPBool"); sm.putString("paramPageName", "Param.DPPageName" );

rdpDeclarePageTest.addParameter(sm) ; assertSave(rdpDeclarePageTest); //Creating String Map of parameters to be passed with findPage() ParameterPage ParamSM = new ParameterPage(); ParamSM.put("DPparamInt", "123"); ParamSM.put("DPparamString", "TestParameter"); ParamSM.put("DPparamDate", "Septemper 12,2012"); ParamSM.put("DPparamDateTime", "20120912T101230. 550 GMT"); ParamSM.put("DPparamDecimal", "123.456"); ParamSM.put("DPparamDouble", "123.348734764"); ParamSM.put("DPparamTimeOfDay", "11:43:18 AM"); ParamSM.put("DPparamTrueFalse", "True"); ParamSM.put("DPBool", "true" ); ParamSM.put("DPPageName", "PS" ); ClipboardPage cp = getTools().createPage("PegaSa mple", "PS"); cp.putString(".pyLabel", "Manish Sinha" ); ClipboardPage cpDeclarePageTest = getTools().fin dPage(DECLARE_PAGE_NAME,ParamSM); assertEquals("123", cpDeclarePageTest.getString( ".propInt")); assertEquals("TestParameter", cpDeclarePageTest. getString(".propString")); assertEquals("true", cpDeclarePageTest.getString (".propTrueFalse")); assertEquals("Septemper 12,2012", cpDeclarePageT est.getString(".propDate")); //may take 20120912 assertEquals("20120912T101230.550 GMT", cpDeclar ePageTest.getString(".propDateTime")); assertEquals("123.456", cpDeclarePageTest.getStr ing(".propDecimal")); assertEquals("123.348734764", cpDeclarePageTest. getString(".propDouble")); assertEquals("114318", cpDeclarePageTest.getStri ng(".propTimeOfDay"));// may take 114318 assertEquals("true", cpDeclarePageTest.getString (".propBool")); assertEquals("Manish Sinha", cpDeclarePageTest.g etPage("propPageName").getString(".pyLabel")); assertFalse(cpDeclarePageTest.isReadOnly()); } }); } public void testParameterisedDPLoadOnlyWhenAllParamsNotInitialised() { mSession.doWithSession(new UserSessionAction() { @Override public void action() throws Exception { //This is to test that when all the parameters o f DP are not initialised still the DP can be run with whatever parameters given. RuleObjProperty propInt = new RuleObjProperty(th is, "PegaSample", "propInt"); propInt.setSingleValueWithType(RuleObjProperty.T

YPE_INTEGER); assertSave(propInt); RuleObjProperty propString = new RuleObjProperty (this, "PegaSample", "propString"); propString.setSingleValueWithType(RuleObjPropert y.TYPE_TEXT); assertSave(propString);

RuleObjActivity roaDeclLoader = new RuleObjActiv ity(this, "PegaSample", "LoadDeclPage"); roaDeclLoader.setActivityType(RuleObjActivity.TY PE_LOADDECLARATIVEPAGE); roaDeclLoader.addPagesAndClassesEntry("paramPage Name", "PegaSample"); roaDeclLoader.addParameter("paramInt", RuleObjAc tivity.PARAM_INTEGER); roaDeclLoader.addParameter("paramString", RuleOb jActivity.PARAM_STRING); // Populate the declarative page PropertySet step1PropertySet = (PropertySet) roa DeclLoader.defineStep(1, RuleObjActivity.METHOD_PROPERTY_ SET, ""); step1PropertySet.addSet(".propInt", "Param.param Int"); step1PropertySet.addSet(".propString", "Param.pa ramString"); // save the activity assertSave(roaDeclLoader); RuleDeclarePages rdpDeclarePageTest = new RuleDe clarePages(this, DECLARE_PAGE_NAME); rdpDeclarePageTest.setScope(Scope.thread); rdpDeclarePageTest.setType(Type.loadonly); rdpDeclarePageTest.setPageClass("PegaSample"); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Adding parameter to Declare Page rdpDeclarePageTest.addDeclarePageParameter("DPpa ramInt", RuleDeclarePages.PARAM_INTEGER); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramString", RuleDeclarePages.PARAM_STRING); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Assigning values to params of activity with Pa rams of DP. StringMap sm = new HashStringMap(); sm.putString("paramInt", "Param.DPparamInt"); sm.putString("paramString", "Param.DPparamString "); rdpDeclarePageTest.addParameter(sm) ; assertSave(rdpDeclarePageTest); //Creating String Map of parameters to be passed

with findPage() ParameterPage ParamSM = new ParameterPage(); ParamSM.put("DPparamInt", "123"); ClipboardPage cpDeclarePageTest = getTools().fin dPage(DECLARE_PAGE_NAME,ParamSM); assertEquals("123", cpDeclarePageTest.getString( ".propInt")); assertEquals("",cpDeclarePageTest.getString(".pr opString")); assertFalse(cpDeclarePageTest.isReadOnly()); } }); } public void testParameterisedDPLoadOnlyMultipleInstance() { mSession.doWithSession(new UserSessionAction() { @Override public void action() throws Exception { //This test case is to verify the multiple insta nce of the same DP with differnet param values RuleObjProperty propInt = new RuleObjProperty(th is, "PegaSample", "propInt"); propInt.setSingleValueWithType(RuleObjProperty.T YPE_INTEGER); assertSave(propInt); RuleObjProperty propString = new RuleObjProperty (this, "PegaSample", "propString"); propString.setSingleValueWithType(RuleObjPropert y.TYPE_TEXT); assertSave(propString);

RuleObjActivity roaDeclLoader = new RuleObjActiv ity(this, "PegaSample", "LoadDeclPage"); roaDeclLoader.setActivityType(RuleObjActivity.TY PE_LOADDECLARATIVEPAGE); roaDeclLoader.addPagesAndClassesEntry("paramPage Name", "PegaSample"); roaDeclLoader.addParameter("paramInt", RuleObjAc tivity.PARAM_INTEGER); roaDeclLoader.addParameter("paramString", RuleOb jActivity.PARAM_STRING); // Populate the declarative page PropertySet step1PropertySet = (PropertySet) roa DeclLoader.defineStep(1, RuleObjActivity.METHOD_PROPERTY_ SET, ""); step1PropertySet.addSet(".propInt", "Param.param Int"); step1PropertySet.addSet(".propString", "Param.pa ramString");

// save the activity assertSave(roaDeclLoader); RuleDeclarePages rdpDeclarePageTest = new RuleDe clarePages(this, DECLARE_PAGE_NAME); rdpDeclarePageTest.setScope(Scope.thread); rdpDeclarePageTest.setType(Type.loadonly); rdpDeclarePageTest.setPageClass("PegaSample"); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Adding parameter to Declare Page rdpDeclarePageTest.addDeclarePageParameter("DPpa ramInt", RuleDeclarePages.PARAM_INTEGER); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramString", RuleDeclarePages.PARAM_STRING); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Assigning values to params of activity with Pa rams of DP. StringMap sm = new HashStringMap(); sm.putString("paramInt", "Param.DPparamInt"); sm.putString("paramString", "Param.DPparamString "); rdpDeclarePageTest.addParameter(sm) ; assertSave(rdpDeclarePageTest); //Creating String Map of parameters to be passed with findPage() ParameterPage ParamSM = new ParameterPage(); ParamSM.put("DPparamInt", "123"); ParameterPage ParamSM1 = new ParameterPage(); ParamSM1.put("DPparamInt", "567"); ClipboardPage cpDeclarePageTest = getTools().fin dPage(DECLARE_PAGE_NAME,ParamSM); ClipboardPage cpDeclarePageTest1 = getTools().fi ndPage(DECLARE_PAGE_NAME,ParamSM1); cpDeclarePageTest.putString(".pyLabel", "Manish Sinha" ); assertEquals("123", cpDeclarePageTest.getString( ".propInt")); assertEquals("Manish Sinha",cpDeclarePageTest.ge tString(".pyLabel")); assertEquals("567", cpDeclarePageTest1.getString (".propInt")); } }); } public void testParameterisedDPLoadOnlyPageRemove() { mSession.doWithSession(new UserSessionAction() { @Override public void action() throws Exception { //Test case checks for the removal of paramteris ed DP from clipboard.

RuleObjProperty propString = new RuleObjProperty (this, "PegaSample", "propString"); propString.setSingleValueWithType(RuleObjPropert y.TYPE_TEXT); assertSave(propString); RuleObjActivity roaDeclLoader = new RuleObjActiv ity(this, "PegaSample", "LoadDeclPage"); roaDeclLoader.setActivityType(RuleObjActivity.TY PE_LOADDECLARATIVEPAGE); roaDeclLoader.addPagesAndClassesEntry("paramPage Name", "PegaSample"); roaDeclLoader.addParameter("paramString", RuleOb jActivity.PARAM_STRING); // Populate the declarative page PropertySet step1PropertySet = (PropertySet) roa DeclLoader.defineStep(1, RuleObjActivity.METHOD_PROPERTY_ SET, ""); step1PropertySet.addSet(".propString", "Param.pa ramString + @(Pega-RULES:DateTime).getCurrentTimeStamp()"); // save the activity assertSave(roaDeclLoader); RuleDeclarePages rdpDeclarePageTest = new RuleDe clarePages(this, DECLARE_PAGE_NAME); rdpDeclarePageTest.setScope(Scope.thread); rdpDeclarePageTest.setType(Type.loadonly); rdpDeclarePageTest.setPageClass("PegaSample"); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Adding parameter to Declare Page rdpDeclarePageTest.addDeclarePageParameter("DPpa ramString", RuleDeclarePages.PARAM_STRING); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Assigning values to params of activity with Pa rams of DP. StringMap sm = new HashStringMap(); sm.putString("paramString", "Param.DPparamString "); rdpDeclarePageTest.addParameter(sm) ; assertSave(rdpDeclarePageTest); //Creating String Map of parameters to be passed with findPage() ParameterPage ParamSM = new ParameterPage(); ParamSM.put("DPparamString", "123"); //java.util.Set threadDeclarePageSet = ((com.peg a.pegarules.priv.context.PegaThread)getTools().getThread()).getThreadDeclarative PageNames(); ClipboardPage cpDeclarePageTest = getTools().fin dPage(DECLARE_PAGE_NAME,ParamSM); //threadDeclarePageSet = ((com.pega.pegarules.pr iv.context.PegaThread)getTools().getThread()).getThreadDeclarativePageNames();

String valuefirst = cpDeclarePageTest.getString( ".propString"); //calling Page-Remove String st = cpDeclarePageTest.getName(); boolean p = cpDeclarePageTest.removeFromClipboar d(); assertTrue(p); //Checking Page exists in clipboard //ClipboardPage cp = ((com.pega.pegarules.sessio n.internal.mgmt.PRThreadImpl)getTools().getThread()).searchReadOnlyDeclarativePa ge(null,st); //assertEquals(null,cp); java.util.Set RequestorDeclarePageSet = ((com.pe ga.pegarules.priv.context.PegaThread)getTools().getThread()).getPageNames(); boolean s = RequestorDeclarePageSet.contains(st) ; assertFalse(s); //Again reload the Page ClipboardPage cpDeclarePageTest1 = getTools().fi ndPage(DECLARE_PAGE_NAME,ParamSM); String valueSecond = cpDeclarePageTest1.getStrin g(".propString"); assertNotSame(valuefirst,valueSecond); } }); } public void testPageCopyfromParameterisedDPLoadOnly() { mSession.doWithSession(new UserSessionAction() { @Override public void action() throws Exception { //Test case to checks the Page Copy from DP to n ormal page RuleObjProperty propString = new RuleObjProperty (this, "PegaSample", "propString"); propString.setSingleValueWithType(RuleObjPropert y.TYPE_TEXT); assertSave(propString); RuleObjActivity roaDeclLoader = new RuleObjActiv ity(this, "PegaSample", "LoadDeclPage"); roaDeclLoader.setActivityType(RuleObjActivity.TY PE_LOADDECLARATIVEPAGE); roaDeclLoader.addPagesAndClassesEntry("paramPage Name", "PegaSample"); roaDeclLoader.addParameter("paramString", RuleOb jActivity.PARAM_STRING); // Populate the declarative page PropertySet step1PropertySet = (PropertySet) roa DeclLoader.defineStep(1, RuleObjActivity.METHOD_PROPERTY_ SET, ""); step1PropertySet.addSet(".propString", "Param.pa ramString");

// save the activity assertSave(roaDeclLoader); RuleDeclarePages rdpDeclarePageTest = new RuleDe clarePages(this, DECLARE_PAGE_NAME); rdpDeclarePageTest.setScope(Scope.thread); rdpDeclarePageTest.setType(Type.loadonly); rdpDeclarePageTest.setPageClass("PegaSample"); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Adding parameter to Declare Page rdpDeclarePageTest.addDeclarePageParameter("DPpa ramString", RuleDeclarePages.PARAM_STRING); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Assigning values to params of activity with Pa rams of DP. StringMap sm = new HashStringMap(); sm.putString("paramString", "Param.DPparamString "); rdpDeclarePageTest.addParameter(sm) ; assertSave(rdpDeclarePageTest); //Creating String Map of parameters to be passed with findPage() ClipboardPage normalPage = getTools().createPage ("PegaSample","PS"); normalPage.putString("pyLabel", "123"); normalPage.putString("propString","value second" ); RuleObjActivity activityToPC = new RuleObjActivi ty(this, "PegaSample", "activityToPC"); activityToPC.setActivityType(RuleObjActivity.TYP E_ACTIVITY); Java js = (Java)activityToPC.defineStep(1,RuleOb jActivity.METHOD_JAVA,null); //Passing parameter value in activity DPparamStr ing = "value first" for Declare Page js.setJavaSource("ParameterPage pg = tools.getPa rameterPage();pg.put(\"DPparamString\",\"values first\");"); PageCopy step2PageCopy = (PageCopy) activityToPC .defineStep(2, RuleObjActivity.METHOD_PAGE_COPY , ""); ((PageCopy)step2PageCopy).setCopyFrom(DECLARE_PA GE_NAME); ((PageCopy)step2PageCopy).setCopyInto("PS"); // save the activity assertSave(activityToPC); HashStringMap hsmKeys = new HashStringMap(); hsmKeys.putString("pyActivityName", "activityToP C"); getTools().doActivity(hsmKeys, normalPage, new P

arameterPage()); assertEquals("", getTools().findPage("PS").getSt ring(".pyLabel")); assertEquals("values first", getTools().findPage ("PS").getString(".propString")); } }); } public void testPageCopytoParameterisedDPLoadOnly() { mSession.doWithSession(new UserSessionAction() { @Override public void action() throws Exception { //Test case to checks the Page Copy from DP to n ormal page RuleObjProperty propString = new RuleObjProperty (this, "PegaSample", "propString"); propString.setSingleValueWithType(RuleObjPropert y.TYPE_TEXT); assertSave(propString); RuleObjActivity roaDeclLoader = new RuleObjActiv ity(this, "PegaSample", "LoadDeclPage"); roaDeclLoader.setActivityType(RuleObjActivity.TY PE_LOADDECLARATIVEPAGE); roaDeclLoader.addPagesAndClassesEntry("paramPage Name", "PegaSample"); roaDeclLoader.addParameter("paramString", RuleOb jActivity.PARAM_STRING); // Populate the declarative page PropertySet step1PropertySet = (PropertySet) roa DeclLoader.defineStep(1, RuleObjActivity.METHOD_PROPERTY_ SET, ""); step1PropertySet.addSet(".propString", "Param.pa ramString"); // save the activity assertSave(roaDeclLoader); RuleDeclarePages rdpDeclarePageTest = new RuleDe clarePages(this, DECLARE_PAGE_NAME); rdpDeclarePageTest.setScope(Scope.thread); rdpDeclarePageTest.setType(Type.loadonly); rdpDeclarePageTest.setPageClass("PegaSample"); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Adding parameter to Declare Page rdpDeclarePageTest.addDeclarePageParameter("DPpa ramString", RuleDeclarePages.PARAM_STRING); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Assigning values to params of activity with Pa rams of DP. StringMap sm = new HashStringMap();

sm.putString("paramString", "Param.DPparamString "); rdpDeclarePageTest.addParameter(sm) ; assertSave(rdpDeclarePageTest); //Creating String Map of parameters to be passed with findPage() ClipboardPage normalPage = getTools().createPage ("PegaSample","PS"); normalPage.putString("pyLabel", "123"); normalPage.putString("propString","value second" ); RuleObjActivity activityToPC = new RuleObjActivi ty(this, "PegaSample", "activityToPC"); activityToPC.setActivityType(RuleObjActivity.TYP E_ACTIVITY); Java js = (Java)activityToPC.defineStep(1,RuleOb jActivity.METHOD_JAVA,null); //Passing parameter value in activity DPparamStr ing = "value first" for Declare Page js.setJavaSource("ParameterPage pg = tools.getPa rameterPage();pg.put(\"DPparamString\",\"values first\");"); PageCopy step2PageCopy = (PageCopy) activityToPC .defineStep(2, RuleObjActivity.METHOD_PAGE_COPY , ""); ((PageCopy)step2PageCopy).setCopyFrom("PS"); ((PageCopy)step2PageCopy).setCopyInto(DECLARE_PA GE_NAME); // save the activity assertSave(activityToPC); //ClipboardPage cp = getTools().findPage(DECLARE _PAGE_NAME); ParameterPage ParamSM1 = new ParameterPage(); ParamSM1.put("DPparamString", "values first"); ClipboardPage cp = getTools().findPage(DECLARE_P AGE_NAME,ParamSM1); HashStringMap hsmKeys = new HashStringMap(); hsmKeys.putString("pyActivityName", "activityToP C"); getTools().doActivity(hsmKeys, cp , new Paramete rPage()); assertEquals("123", cp.getString(".pyLabel")); assertEquals("value second", cp.getString(".prop String")); } }); } public void testParameterisedDPLoadOnlyPageMergeInto() { mSession.doWithSession(new UserSessionAction() {

@Override public void action() throws Exception { //Test case to checks the Page Copy from DP to n ormal page RuleObjProperty propString = new RuleObjProperty (this, "PegaSample", "propString"); propString.setSingleValueWithType(RuleObjPropert y.TYPE_TEXT); assertSave(propString); RuleObjProperty propInt = new RuleObjProperty(th is, "PegaSample", "propInt"); propInt.setSingleValueWithType(RuleObjProperty.T YPE_INTEGER); assertSave(propInt); RuleObjActivity roaDeclLoader = new RuleObjActiv ity(this, "PegaSample", "LoadDeclPage"); roaDeclLoader.setActivityType(RuleObjActivity.TY PE_LOADDECLARATIVEPAGE); roaDeclLoader.addPagesAndClassesEntry("paramPage Name", "PegaSample"); roaDeclLoader.addParameter("paramString", RuleOb jActivity.PARAM_STRING); roaDeclLoader.addParameter("paramInt", RuleObjAc tivity.PARAM_INTEGER); // Populate the declarative page PropertySet step1PropertySet = (PropertySet) roa DeclLoader.defineStep(1, RuleObjActivity.METHOD_PROPERTY_ SET, ""); step1PropertySet.addSet(".propString", "Param.pa ramString"); step1PropertySet.addSet(".propInt", "Param.param Int"); // save the activity assertSave(roaDeclLoader); RuleDeclarePages rdpDeclarePageTest = new RuleDe clarePages(this, DECLARE_PAGE_NAME); rdpDeclarePageTest.setScope(Scope.thread); rdpDeclarePageTest.setType(Type.loadonly); rdpDeclarePageTest.setPageClass("PegaSample"); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Adding parameter to Declare Page rdpDeclarePageTest.addDeclarePageParameter("DPpa ramString", RuleDeclarePages.PARAM_STRING); rdpDeclarePageTest.addDeclarePageParameter("DPpa ramInt", RuleDeclarePages.PARAM_INTEGER); rdpDeclarePageTest.setLoadActivity("LoadDeclPage "); //Assigning values to params of activity with Pa rams of DP. StringMap sm = new HashStringMap(); sm.putString("paramString", "Param.DPparamString "); sm.putString("paramInt", "Param.DPparamInt");

rdpDeclarePageTest.addParameter(sm) ; assertSave(rdpDeclarePageTest); //Creating String Map of parameters to be passed with findPage() ClipboardPage normalPage = getTools().createPage ("PegaSample","PS"); normalPage.putString("pyLabel", "Testproperty"); normalPage.putString("propString","DonotChange") ; RuleObjActivity activityToPM = new RuleObjActivi ty(this, "PegaSample", "activityToPC"); activityToPM.setActivityType(RuleObjActivity.TYP E_ACTIVITY); Java js = (Java)activityToPM.defineStep(1,RuleOb jActivity.METHOD_JAVA,null); //Passing parameter value in activity DPparamStr ing = "value first" for Declare Page js.setJavaSource("ParameterPage pg = tools.getPa rameterPage();pg.put(\"DPparamString\",\"values first\");pg.put(\"DPparamInt\",\ "789\");"); PageMergeInto step2PageCopy = (PageMergeInto) ac tivityToPM.defineStep(2, RuleObjActivity.METHOD_PAGE_MERG E_INTO, ""); ((PageMergeInto)step2PageCopy).addPageToMergeInt o(DECLARE_PAGE_NAME); // save the activity assertSave(activityToPM); HashStringMap hsmKeys = new HashStringMap(); hsmKeys.putString("pyActivityName", "activityToP C"); getTools().doActivity(hsmKeys, normalPage, new P arameterPage()); assertEquals("Testproperty", getTools().findPage ("PS").getString(".pyLabel")); assertEquals("DonotChange", getTools().findPage( "PS").getString(".propString")); assertEquals("789", getTools().findPage("PS").ge tString(".propInt")); } }); }