[Dev] Is there any method which can checks the resource exists or not in registry

2015-10-06 Thread Rajeenthini Satkunam
Hi all,

I am writing UI test cases for UES/Dashboard Server(DS).I have tried to
write a test class for adding and deleting dashboard for the Dashboard
Server.Here I need to check the resource is existing or not at the
registry.You can have a look for the class[1] I have wrote for adding and
deleting dashboard.
[1] -
https://github.com/rajeenthini/product-ues/commit/e642d50edf08cc21d2b0a2b21463e4b3aadc587a

BTW I have modified my code in some ways .Those are I have included below
- Deleted deleteResource method from here
resourceAdminServiceClient.deleteResource(resourcePath);

@AfterClass(alwaysRun = true)
public void tearDown() throws MalformedURLException,
XPathExpressionException, RemoteException,
ResourceAdminServiceExceptionException {
try{
UESUIIntegrationTest.logout(getDriver(), getBaseUrl(),
getCurrentUsername());
}finally {
getDriver().quit();
}
}

- Added some code segment to the method deleteDashboard

@Test(groups = "wso2.ues.dashboard", description = "Deleting added
dashboard", dependsOnMethods = "testAddDashboardNew")
public void testDeleteDashboardNew() throws MalformedURLException,
XPathExpressionException, RemoteException,
ResourceAdminServiceExceptionException {
webElement = getDriver().findElement(By.id(dashboardTitle));
webElement.findElement(By.cssSelector("i.fw-delete")).click();
getDriver().findElement(By.cssSelector("span.ladda-label")).click();
assertFalse(getDriver().isElementPresent(By.id(dashboardTitle)),
"Error occurred while deleting dashboard" + dashboardTitle);
ResourceData[] resourceData =
resourceAdminServiceClient.getResourceData(resourcePath);
assertTrue(resourceData.length == 0,"Registry resource could not
be deleted due to some errors");
}

Now it's giving me exception when there is no such registry resource after
dashboard was deleted by UI testcase.

org.apache.axis2.AxisFault: Resource does not exist at path
/_system/config/ues/dashboards/sampledashboard1

So can anyone give some suggestions on $subject? Thanks in advance.
-- 

*Thank You.*

*Rajeenthini Satkunam*

*Associate Software Engineer | WSO2*


*E:rajeenth...@wso2.com *

*M :+94770832823   *
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Is there any method which can checks the resource exists or not in registry

2015-10-06 Thread Kasun Bandara
Hi Rajeenthini,

You can invoke the *boolean resourceExists(String resorcePath)* method
through the Registry class comes with registry core. Returns true if the
resource exists in the specified path & returns false if it's not reside in
the path.

Thanks and Regards.


On Tue, Oct 6, 2015 at 3:42 PM, Kasun Bandara  wrote:

> Hi Rajeenthini,
>
> You can invoke the *boolean resourceExists(String resorcePath)* method
> through the Registry class comes with registry core. Returns true if the
> resource exists in the specified path & returns false if it's not reside in
> the path.
>
> Thanks and Regards.
>
>
> On Tue, Oct 6, 2015 at 12:35 PM, Rajeenthini Satkunam <
> rajeenth...@wso2.com> wrote:
>
>> Hi all,
>>
>> I am writing UI test cases for UES/Dashboard Server(DS).I have tried to
>> write a test class for adding and deleting dashboard for the Dashboard
>> Server.Here I need to check the resource is existing or not at the
>> registry.You can have a look for the class[1] I have wrote for adding and
>> deleting dashboard.
>> [1] -
>> https://github.com/rajeenthini/product-ues/commit/e642d50edf08cc21d2b0a2b21463e4b3aadc587a
>>
>> BTW I have modified my code in some ways .Those are I have included below
>> - Deleted deleteResource method from here
>> resourceAdminServiceClient.deleteResource(resourcePath);
>>
>> @AfterClass(alwaysRun = true)
>> public void tearDown() throws MalformedURLException, 
>> XPathExpressionException, RemoteException, 
>> ResourceAdminServiceExceptionException {
>> try{
>> UESUIIntegrationTest.logout(getDriver(), getBaseUrl(), 
>> getCurrentUsername());
>> }finally {
>> getDriver().quit();
>> }
>> }
>>
>> - Added some code segment to the method deleteDashboard
>>
>> @Test(groups = "wso2.ues.dashboard", description = "Deleting added 
>> dashboard", dependsOnMethods = "testAddDashboardNew")
>> public void testDeleteDashboardNew() throws MalformedURLException, 
>> XPathExpressionException, RemoteException, 
>> ResourceAdminServiceExceptionException {
>> webElement = getDriver().findElement(By.id(dashboardTitle));
>> webElement.findElement(By.cssSelector("i.fw-delete")).click();
>> getDriver().findElement(By.cssSelector("span.ladda-label")).click();
>> assertFalse(getDriver().isElementPresent(By.id(dashboardTitle)), "Error 
>> occurred while deleting dashboard" + dashboardTitle);
>> ResourceData[] resourceData = 
>> resourceAdminServiceClient.getResourceData(resourcePath);
>> assertTrue(resourceData.length == 0,"Registry resource could not be 
>> deleted due to some errors");
>> }
>>
>> Now it's giving me exception when there is no such registry resource
>> after dashboard was deleted by UI testcase.
>>
>> org.apache.axis2.AxisFault: Resource does not exist at path 
>> /_system/config/ues/dashboards/sampledashboard1
>>
>> So can anyone give some suggestions on $subject? Thanks in advance.
>> --
>>
>> *Thank You.*
>>
>> *Rajeenthini Satkunam*
>>
>> *Associate Software Engineer | WSO2*
>>
>>
>> *E:rajeenth...@wso2.com *
>>
>> *M :+94770832823 <%2B94770832823>   *
>>
>>
>> ___
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Kasun Bandara
> *Software Engineer*
> Mobile : +94 (0) 718 338 360
> <%2B94%20%280%29%20773%20451194>
> kas...@wso2.com 
>



-- 
Kasun Bandara
*Software Engineer*
Mobile : +94 (0) 718 338 360
<%2B94%20%280%29%20773%20451194>
kas...@wso2.com 
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Is there any method which can checks the resource exists or not in registry

2015-10-06 Thread Rajith Roshan
Hi Rajeenthini,

You can get the instance of registry as below and check if the resource
exists.

RegistryProviderUtil provider = new RegistryProviderUtil();
WSRegistryServiceClient registry = provider.getWSRegistry(automationContext);

if(registry.resourceExists(path))


Thanks,

Rajith


On Tue, Oct 6, 2015 at 3:43 PM, Kasun Bandara  wrote:

> Hi Rajeenthini,
>
> You can invoke the *boolean resourceExists(String resorcePath)* method
> through the Registry class comes with registry core. Returns true if the
> resource exists in the specified path & returns false if it's not reside in
> the path.
>
> Thanks and Regards.
>
>
> On Tue, Oct 6, 2015 at 3:42 PM, Kasun Bandara  wrote:
>
>> Hi Rajeenthini,
>>
>> You can invoke the *boolean resourceExists(String resorcePath)* method
>> through the Registry class comes with registry core. Returns true if the
>> resource exists in the specified path & returns false if it's not reside in
>> the path.
>>
>> Thanks and Regards.
>>
>>
>> On Tue, Oct 6, 2015 at 12:35 PM, Rajeenthini Satkunam <
>> rajeenth...@wso2.com> wrote:
>>
>>> Hi all,
>>>
>>> I am writing UI test cases for UES/Dashboard Server(DS).I have tried to
>>> write a test class for adding and deleting dashboard for the Dashboard
>>> Server.Here I need to check the resource is existing or not at the
>>> registry.You can have a look for the class[1] I have wrote for adding and
>>> deleting dashboard.
>>> [1] -
>>> https://github.com/rajeenthini/product-ues/commit/e642d50edf08cc21d2b0a2b21463e4b3aadc587a
>>>
>>> BTW I have modified my code in some ways .Those are I have included below
>>> - Deleted deleteResource method from here
>>> resourceAdminServiceClient.deleteResource(resourcePath);
>>>
>>> @AfterClass(alwaysRun = true)
>>> public void tearDown() throws MalformedURLException, 
>>> XPathExpressionException, RemoteException, 
>>> ResourceAdminServiceExceptionException {
>>> try{
>>> UESUIIntegrationTest.logout(getDriver(), getBaseUrl(), 
>>> getCurrentUsername());
>>> }finally {
>>> getDriver().quit();
>>> }
>>> }
>>>
>>> - Added some code segment to the method deleteDashboard
>>>
>>> @Test(groups = "wso2.ues.dashboard", description = "Deleting added 
>>> dashboard", dependsOnMethods = "testAddDashboardNew")
>>> public void testDeleteDashboardNew() throws MalformedURLException, 
>>> XPathExpressionException, RemoteException, 
>>> ResourceAdminServiceExceptionException {
>>> webElement = getDriver().findElement(By.id(dashboardTitle));
>>> webElement.findElement(By.cssSelector("i.fw-delete")).click();
>>> getDriver().findElement(By.cssSelector("span.ladda-label")).click();
>>> assertFalse(getDriver().isElementPresent(By.id(dashboardTitle)), "Error 
>>> occurred while deleting dashboard" + dashboardTitle);
>>> ResourceData[] resourceData = 
>>> resourceAdminServiceClient.getResourceData(resourcePath);
>>> assertTrue(resourceData.length == 0,"Registry resource could not be 
>>> deleted due to some errors");
>>> }
>>>
>>> Now it's giving me exception when there is no such registry resource
>>> after dashboard was deleted by UI testcase.
>>>
>>> org.apache.axis2.AxisFault: Resource does not exist at path 
>>> /_system/config/ues/dashboards/sampledashboard1
>>>
>>> So can anyone give some suggestions on $subject? Thanks in advance.
>>> --
>>>
>>> *Thank You.*
>>>
>>> *Rajeenthini Satkunam*
>>>
>>> *Associate Software Engineer | WSO2*
>>>
>>>
>>> *E:rajeenth...@wso2.com *
>>>
>>> *M :+94770832823 <%2B94770832823>   *
>>>
>>>
>>> ___
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> Kasun Bandara
>> *Software Engineer*
>> Mobile : +94 (0) 718 338 360
>> <%2B94%20%280%29%20773%20451194>
>> kas...@wso2.com 
>>
>
>
>
> --
> Kasun Bandara
> *Software Engineer*
> Mobile : +94 (0) 718 338 360
> <%2B94%20%280%29%20773%20451194>
> kas...@wso2.com 
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Rajith Roshan
Software Engineer, WSO2 Inc.
Mobile: +94-72-642-8350 <%2B94-71-554-8430>
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Is there any method which can checks the resource exists or not in registry

2015-10-06 Thread Rajeenthini Satkunam
Hi rajith,

I have tried the way you mentioned.When I use like this

RegistryProviderUtil provider = new RegistryProviderUtil();
WSRegistryServiceClient registry = provider.getWSRegistry(getUesContext());
assertFalse(registry.resourceExists(resourcePath),"Registry resource
could not be deleted due to some errors");

It says like cannot resolve the method getWSRegistry(getUesContext())

But I have tried this way too

WSRegistryServiceClient registry =
provider.getWSRegistry(getCurrentUsername(),getCurrentPassword(),
UESIntegrationTestConstants.UES_PRODUCT_NAME);

But when I run the test cases it is giving me a null pointer exception
at the point when I created registry instance.Could you please advice
me on how can I resolve this issue?




On Tue, Oct 6, 2015 at 4:35 PM, Rajith Roshan  wrote:

> Hi Rajeenthini,
>
> You can get the instance of registry as below and check if the resource
> exists.
>
> RegistryProviderUtil provider = new RegistryProviderUtil();
> WSRegistryServiceClient registry = provider.getWSRegistry(automationContext);
>
> if(registry.resourceExists(path))
>
>
> Thanks,
>
> Rajith
>
>
> On Tue, Oct 6, 2015 at 3:43 PM, Kasun Bandara  wrote:
>
>> Hi Rajeenthini,
>>
>> You can invoke the *boolean resourceExists(String resorcePath)* method
>> through the Registry class comes with registry core. Returns true if the
>> resource exists in the specified path & returns false if it's not reside in
>> the path.
>>
>> Thanks and Regards.
>>
>>
>> On Tue, Oct 6, 2015 at 3:42 PM, Kasun Bandara  wrote:
>>
>>> Hi Rajeenthini,
>>>
>>> You can invoke the *boolean resourceExists(String resorcePath)* method
>>> through the Registry class comes with registry core. Returns true if the
>>> resource exists in the specified path & returns false if it's not reside in
>>> the path.
>>>
>>> Thanks and Regards.
>>>
>>>
>>> On Tue, Oct 6, 2015 at 12:35 PM, Rajeenthini Satkunam <
>>> rajeenth...@wso2.com> wrote:
>>>
 Hi all,

 I am writing UI test cases for UES/Dashboard Server(DS).I have tried to
 write a test class for adding and deleting dashboard for the Dashboard
 Server.Here I need to check the resource is existing or not at the
 registry.You can have a look for the class[1] I have wrote for adding and
 deleting dashboard.
 [1] -
 https://github.com/rajeenthini/product-ues/commit/e642d50edf08cc21d2b0a2b21463e4b3aadc587a

 BTW I have modified my code in some ways .Those are I have included
 below
 - Deleted deleteResource method from here
 resourceAdminServiceClient.deleteResource(resourcePath);

 @AfterClass(alwaysRun = true)
 public void tearDown() throws MalformedURLException, 
 XPathExpressionException, RemoteException, 
 ResourceAdminServiceExceptionException {
 try{
 UESUIIntegrationTest.logout(getDriver(), getBaseUrl(), 
 getCurrentUsername());
 }finally {
 getDriver().quit();
 }
 }

 - Added some code segment to the method deleteDashboard

 @Test(groups = "wso2.ues.dashboard", description = "Deleting added 
 dashboard", dependsOnMethods = "testAddDashboardNew")
 public void testDeleteDashboardNew() throws MalformedURLException, 
 XPathExpressionException, RemoteException, 
 ResourceAdminServiceExceptionException {
 webElement = getDriver().findElement(By.id(dashboardTitle));
 webElement.findElement(By.cssSelector("i.fw-delete")).click();
 getDriver().findElement(By.cssSelector("span.ladda-label")).click();
 assertFalse(getDriver().isElementPresent(By.id(dashboardTitle)), 
 "Error occurred while deleting dashboard" + dashboardTitle);
 ResourceData[] resourceData = 
 resourceAdminServiceClient.getResourceData(resourcePath);
 assertTrue(resourceData.length == 0,"Registry resource could not be 
 deleted due to some errors");
 }

 Now it's giving me exception when there is no such registry resource
 after dashboard was deleted by UI testcase.

 org.apache.axis2.AxisFault: Resource does not exist at path 
 /_system/config/ues/dashboards/sampledashboard1

 So can anyone give some suggestions on $subject? Thanks in advance.
 --

 *Thank You.*

 *Rajeenthini Satkunam*

 *Associate Software Engineer | WSO2*


 *E:rajeenth...@wso2.com *

 *M :+94770832823 <%2B94770832823>   *


 ___
 Dev mailing list
 Dev@wso2.org
 http://wso2.org/cgi-bin/mailman/listinfo/dev


>>>
>>>
>>> --
>>> Kasun Bandara
>>> *Software Engineer*
>>> Mobile : +94 (0) 718 338 360
>>> <%2B94%20%280%29%20773%20451194>
>>> kas...@wso2.com 
>>>
>>
>>
>>
>> --
>> Kasun Bandara
>> *Software Engineer*
>> Mobile : +94 (0) 718 338 360
>> <%2B94%20%280%29%20773%20451194>
>> kas...@wso2.com 
>>
>> ___
>> Dev mailing list
>> Dev@wso2.org
>

Re: [Dev] Is there any method which can checks the resource exists or not in registry

2015-10-06 Thread Denuwanthi De Silva
Hi Rajeenthini,

You need to pass an 'AutomationContext' object to 'getWSRegistry' method.
Can you verify the method 'getUesContext' returns a proper
AutomationContext?

Ex of defining an automation context fro greg product
AutomationContext context = new AutomationContext("GREG",
TestUserMode.SUPER_TENANT_ADMIN);


Thanks,

On Tue, Oct 6, 2015 at 5:28 PM, Rajeenthini Satkunam 
wrote:

> Hi rajith,
>
> I have tried the way you mentioned.When I use like this
>
> RegistryProviderUtil provider = new RegistryProviderUtil();
> WSRegistryServiceClient registry = provider.getWSRegistry(getUesContext());
> assertFalse(registry.resourceExists(resourcePath),"Registry resource could 
> not be deleted due to some errors");
>
> It says like cannot resolve the method getWSRegistry(getUesContext())
>
> But I have tried this way too
>
> WSRegistryServiceClient registry = 
> provider.getWSRegistry(getCurrentUsername(),getCurrentPassword(), 
> UESIntegrationTestConstants.UES_PRODUCT_NAME);
>
> But when I run the test cases it is giving me a null pointer exception at the 
> point when I created registry instance.Could you please advice me on how can 
> I resolve this issue?
>
>
>
>
> On Tue, Oct 6, 2015 at 4:35 PM, Rajith Roshan  wrote:
>
>> Hi Rajeenthini,
>>
>> You can get the instance of registry as below and check if the resource
>> exists.
>>
>> RegistryProviderUtil provider = new RegistryProviderUtil();
>> WSRegistryServiceClient registry = provider.getWSRegistry(automationContext);
>>
>> if(registry.resourceExists(path))
>>
>>
>> Thanks,
>>
>> Rajith
>>
>>
>> On Tue, Oct 6, 2015 at 3:43 PM, Kasun Bandara  wrote:
>>
>>> Hi Rajeenthini,
>>>
>>> You can invoke the *boolean resourceExists(String resorcePath)* method
>>> through the Registry class comes with registry core. Returns true if the
>>> resource exists in the specified path & returns false if it's not reside in
>>> the path.
>>>
>>> Thanks and Regards.
>>>
>>>
>>> On Tue, Oct 6, 2015 at 3:42 PM, Kasun Bandara  wrote:
>>>
 Hi Rajeenthini,

 You can invoke the *boolean resourceExists(String resorcePath)* method
 through the Registry class comes with registry core. Returns true if the
 resource exists in the specified path & returns false if it's not reside in
 the path.

 Thanks and Regards.


 On Tue, Oct 6, 2015 at 12:35 PM, Rajeenthini Satkunam <
 rajeenth...@wso2.com> wrote:

> Hi all,
>
> I am writing UI test cases for UES/Dashboard Server(DS).I have tried
> to write a test class for adding and deleting dashboard for the Dashboard
> Server.Here I need to check the resource is existing or not at the
> registry.You can have a look for the class[1] I have wrote for adding and
> deleting dashboard.
> [1] -
> https://github.com/rajeenthini/product-ues/commit/e642d50edf08cc21d2b0a2b21463e4b3aadc587a
>
> BTW I have modified my code in some ways .Those are I have included
> below
> - Deleted deleteResource method from here
> resourceAdminServiceClient.deleteResource(resourcePath);
>
> @AfterClass(alwaysRun = true)
> public void tearDown() throws MalformedURLException, 
> XPathExpressionException, RemoteException, 
> ResourceAdminServiceExceptionException {
> try{
> UESUIIntegrationTest.logout(getDriver(), getBaseUrl(), 
> getCurrentUsername());
> }finally {
> getDriver().quit();
> }
> }
>
> - Added some code segment to the method deleteDashboard
>
> @Test(groups = "wso2.ues.dashboard", description = "Deleting added 
> dashboard", dependsOnMethods = "testAddDashboardNew")
> public void testDeleteDashboardNew() throws MalformedURLException, 
> XPathExpressionException, RemoteException, 
> ResourceAdminServiceExceptionException {
> webElement = getDriver().findElement(By.id(dashboardTitle));
> webElement.findElement(By.cssSelector("i.fw-delete")).click();
> getDriver().findElement(By.cssSelector("span.ladda-label")).click();
> assertFalse(getDriver().isElementPresent(By.id(dashboardTitle)), 
> "Error occurred while deleting dashboard" + dashboardTitle);
> ResourceData[] resourceData = 
> resourceAdminServiceClient.getResourceData(resourcePath);
> assertTrue(resourceData.length == 0,"Registry resource could not be 
> deleted due to some errors");
> }
>
> Now it's giving me exception when there is no such registry resource
> after dashboard was deleted by UI testcase.
>
> org.apache.axis2.AxisFault: Resource does not exist at path 
> /_system/config/ues/dashboards/sampledashboard1
>
> So can anyone give some suggestions on $subject? Thanks in advance.
> --
>
> *Thank You.*
>
> *Rajeenthini Satkunam*
>
> *Associate Software Engineer | WSO2*
>
>
> *E:rajeenth...@wso2.com *
>
> *M :+94770832823 <%2B94770832823>   *
>
>

Re: [Dev] Is there any method which can checks the resource exists or not in registry

2015-10-06 Thread Isuruwan Herath
Also if you're using ResourceAdminServiceClient, this [1] is an example how
resource exists is checked in G-Reg tests.

[1]
https://github.com/wso2/product-greg/blob/master/modules/integration/tests-integration/tests-metadata/tests-metadata-content/src/test/java/org/wso2/carbon/registry/metadata/test/util/TestUtils.java#L171

On Wed, Oct 7, 2015 at 11:49 AM, Denuwanthi De Silva 
wrote:

> Hi Rajeenthini,
>
> You need to pass an 'AutomationContext' object to 'getWSRegistry' method.
> Can you verify the method 'getUesContext' returns a proper
> AutomationContext?
>
> Ex of defining an automation context fro greg product
> AutomationContext context = new AutomationContext("GREG",
> TestUserMode.SUPER_TENANT_ADMIN);
>
>
> Thanks,
>
> On Tue, Oct 6, 2015 at 5:28 PM, Rajeenthini Satkunam  > wrote:
>
>> Hi rajith,
>>
>> I have tried the way you mentioned.When I use like this
>>
>> RegistryProviderUtil provider = new RegistryProviderUtil();
>> WSRegistryServiceClient registry = provider.getWSRegistry(getUesContext());
>> assertFalse(registry.resourceExists(resourcePath),"Registry resource could 
>> not be deleted due to some errors");
>>
>> It says like cannot resolve the method getWSRegistry(getUesContext())
>>
>> But I have tried this way too
>>
>> WSRegistryServiceClient registry = 
>> provider.getWSRegistry(getCurrentUsername(),getCurrentPassword(), 
>> UESIntegrationTestConstants.UES_PRODUCT_NAME);
>>
>> But when I run the test cases it is giving me a null pointer exception at 
>> the point when I created registry instance.Could you please advice me on how 
>> can I resolve this issue?
>>
>>
>>
>>
>> On Tue, Oct 6, 2015 at 4:35 PM, Rajith Roshan  wrote:
>>
>>> Hi Rajeenthini,
>>>
>>> You can get the instance of registry as below and check if the resource
>>> exists.
>>>
>>> RegistryProviderUtil provider = new RegistryProviderUtil();
>>> WSRegistryServiceClient registry = 
>>> provider.getWSRegistry(automationContext);
>>>
>>> if(registry.resourceExists(path))
>>>
>>>
>>> Thanks,
>>>
>>> Rajith
>>>
>>>
>>> On Tue, Oct 6, 2015 at 3:43 PM, Kasun Bandara  wrote:
>>>
 Hi Rajeenthini,

 You can invoke the *boolean resourceExists(String resorcePath)* method
 through the Registry class comes with registry core. Returns true if the
 resource exists in the specified path & returns false if it's not reside in
 the path.

 Thanks and Regards.


 On Tue, Oct 6, 2015 at 3:42 PM, Kasun Bandara  wrote:

> Hi Rajeenthini,
>
> You can invoke the *boolean resourceExists(String resorcePath)*
> method through the Registry class comes with registry core. Returns true 
> if
> the resource exists in the specified path & returns false if it's not
> reside in the path.
>
> Thanks and Regards.
>
>
> On Tue, Oct 6, 2015 at 12:35 PM, Rajeenthini Satkunam <
> rajeenth...@wso2.com> wrote:
>
>> Hi all,
>>
>> I am writing UI test cases for UES/Dashboard Server(DS).I have tried
>> to write a test class for adding and deleting dashboard for the Dashboard
>> Server.Here I need to check the resource is existing or not at the
>> registry.You can have a look for the class[1] I have wrote for adding and
>> deleting dashboard.
>> [1] -
>> https://github.com/rajeenthini/product-ues/commit/e642d50edf08cc21d2b0a2b21463e4b3aadc587a
>>
>> BTW I have modified my code in some ways .Those are I have included
>> below
>> - Deleted deleteResource method from here
>> resourceAdminServiceClient.deleteResource(resourcePath);
>>
>> @AfterClass(alwaysRun = true)
>> public void tearDown() throws MalformedURLException, 
>> XPathExpressionException, RemoteException, 
>> ResourceAdminServiceExceptionException {
>> try{
>> UESUIIntegrationTest.logout(getDriver(), getBaseUrl(), 
>> getCurrentUsername());
>> }finally {
>> getDriver().quit();
>> }
>> }
>>
>> - Added some code segment to the method deleteDashboard
>>
>> @Test(groups = "wso2.ues.dashboard", description = "Deleting added 
>> dashboard", dependsOnMethods = "testAddDashboardNew")
>> public void testDeleteDashboardNew() throws MalformedURLException, 
>> XPathExpressionException, RemoteException, 
>> ResourceAdminServiceExceptionException {
>> webElement = getDriver().findElement(By.id(dashboardTitle));
>> webElement.findElement(By.cssSelector("i.fw-delete")).click();
>> getDriver().findElement(By.cssSelector("span.ladda-label")).click();
>> assertFalse(getDriver().isElementPresent(By.id(dashboardTitle)), 
>> "Error occurred while deleting dashboard" + dashboardTitle);
>> ResourceData[] resourceData = 
>> resourceAdminServiceClient.getResourceData(resourcePath);
>> assertTrue(resourceData.length == 0,"Registry resource could not be 
>> deleted due to some errors");
>> }
>>
>> No

Re: [Dev] Is there any method which can checks the resource exists or not in registry

2015-10-07 Thread Rajeenthini Satkunam
Hi,

@kasun @rajith @denuwanthi @isuruwan Thanks you for your prompt reply.I
have tried the way which isuruwan mentiond above.It is working fine now.

On Wed, Oct 7, 2015 at 11:52 AM, Isuruwan Herath  wrote:

> Also if you're using ResourceAdminServiceClient, this [1] is an example
> how resource exists is checked in G-Reg tests.
>
> [1]
> https://github.com/wso2/product-greg/blob/master/modules/integration/tests-integration/tests-metadata/tests-metadata-content/src/test/java/org/wso2/carbon/registry/metadata/test/util/TestUtils.java#L171
>
> On Wed, Oct 7, 2015 at 11:49 AM, Denuwanthi De Silva 
> wrote:
>
>> Hi Rajeenthini,
>>
>> You need to pass an 'AutomationContext' object to 'getWSRegistry' method.
>> Can you verify the method 'getUesContext' returns a proper
>> AutomationContext?
>>
>> Ex of defining an automation context fro greg product
>> AutomationContext context = new AutomationContext("GREG",
>> TestUserMode.SUPER_TENANT_ADMIN);
>>
>>
>> Thanks,
>>
>> On Tue, Oct 6, 2015 at 5:28 PM, Rajeenthini Satkunam <
>> rajeenth...@wso2.com> wrote:
>>
>>> Hi rajith,
>>>
>>> I have tried the way you mentioned.When I use like this
>>>
>>> RegistryProviderUtil provider = new RegistryProviderUtil();
>>> WSRegistryServiceClient registry = provider.getWSRegistry(getUesContext());
>>> assertFalse(registry.resourceExists(resourcePath),"Registry resource could 
>>> not be deleted due to some errors");
>>>
>>> It says like cannot resolve the method getWSRegistry(getUesContext())
>>>
>>> But I have tried this way too
>>>
>>> WSRegistryServiceClient registry = 
>>> provider.getWSRegistry(getCurrentUsername(),getCurrentPassword(), 
>>> UESIntegrationTestConstants.UES_PRODUCT_NAME);
>>>
>>> But when I run the test cases it is giving me a null pointer exception at 
>>> the point when I created registry instance.Could you please advice me on 
>>> how can I resolve this issue?
>>>
>>>
>>>
>>>
>>> On Tue, Oct 6, 2015 at 4:35 PM, Rajith Roshan  wrote:
>>>
 Hi Rajeenthini,

 You can get the instance of registry as below and check if the resource
 exists.

 RegistryProviderUtil provider = new RegistryProviderUtil();
 WSRegistryServiceClient registry = 
 provider.getWSRegistry(automationContext);

 if(registry.resourceExists(path))


 Thanks,

 Rajith


 On Tue, Oct 6, 2015 at 3:43 PM, Kasun Bandara  wrote:

> Hi Rajeenthini,
>
> You can invoke the *boolean resourceExists(String resorcePath)*
> method through the Registry class comes with registry core. Returns true 
> if
> the resource exists in the specified path & returns false if it's not
> reside in the path.
>
> Thanks and Regards.
>
>
> On Tue, Oct 6, 2015 at 3:42 PM, Kasun Bandara  wrote:
>
>> Hi Rajeenthini,
>>
>> You can invoke the *boolean resourceExists(String resorcePath)*
>> method through the Registry class comes with registry core. Returns true 
>> if
>> the resource exists in the specified path & returns false if it's not
>> reside in the path.
>>
>> Thanks and Regards.
>>
>>
>> On Tue, Oct 6, 2015 at 12:35 PM, Rajeenthini Satkunam <
>> rajeenth...@wso2.com> wrote:
>>
>>> Hi all,
>>>
>>> I am writing UI test cases for UES/Dashboard Server(DS).I have tried
>>> to write a test class for adding and deleting dashboard for the 
>>> Dashboard
>>> Server.Here I need to check the resource is existing or not at the
>>> registry.You can have a look for the class[1] I have wrote for adding 
>>> and
>>> deleting dashboard.
>>> [1] -
>>> https://github.com/rajeenthini/product-ues/commit/e642d50edf08cc21d2b0a2b21463e4b3aadc587a
>>>
>>> BTW I have modified my code in some ways .Those are I have included
>>> below
>>> - Deleted deleteResource method from here
>>> resourceAdminServiceClient.deleteResource(resourcePath);
>>>
>>> @AfterClass(alwaysRun = true)
>>> public void tearDown() throws MalformedURLException, 
>>> XPathExpressionException, RemoteException, 
>>> ResourceAdminServiceExceptionException {
>>> try{
>>> UESUIIntegrationTest.logout(getDriver(), getBaseUrl(), 
>>> getCurrentUsername());
>>> }finally {
>>> getDriver().quit();
>>> }
>>> }
>>>
>>> - Added some code segment to the method deleteDashboard
>>>
>>> @Test(groups = "wso2.ues.dashboard", description = "Deleting added 
>>> dashboard", dependsOnMethods = "testAddDashboardNew")
>>> public void testDeleteDashboardNew() throws MalformedURLException, 
>>> XPathExpressionException, RemoteException, 
>>> ResourceAdminServiceExceptionException {
>>> webElement = getDriver().findElement(By.id(dashboardTitle));
>>> webElement.findElement(By.cssSelector("i.fw-delete")).click();
>>> getDriver().findElement(By.cssSelector("span.ladda-label")).click()