Skip to content

Commit

Permalink
XXX-HPCC4J Add WsResources test cases
Browse files Browse the repository at this point in the history
- Adds test cases to account for all wsresources methods
- Adds logic to create HPCCQueueType based on string representation
- Adds all available methods to HPCCWsResourcesClient

Signed-off-by: Rodrigo Pastrana <[email protected]>
  • Loading branch information
rpastrana committed Mar 27, 2024
1 parent 9f245d2 commit 63369bc
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
import org.apache.logging.log4j.Logger;
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.ArrayOfEspException;
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.ServiceQueryResponse;
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.TargetQueryResponse;
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.WsResourcesPingRequest;
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.WsResourcesStub;
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.WebLinksQueryResponse;
import org.hpccsystems.ws.client.utils.Connection;
import org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryRequestWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryResponseWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryRequestWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryResponseWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryRequestWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryResponseWrapper;


/**
* Facilitates discovery of containerized HPCC Systems resources.
Expand All @@ -48,7 +55,7 @@ public class HPCCWsResourcesClient extends BaseHPCCWsClient

/**
* Load WSDLURL.
*/
*/
private static void loadWSDLURL()
{
try
Expand All @@ -67,7 +74,7 @@ private static void loadWSDLURL()
* Gets the service URI.
*
* @return the service URI
*/
*/
public String getServiceURI()
{
return WSRESOURCESURI;
Expand Down Expand Up @@ -116,10 +123,10 @@ public Stub getDefaultStub() throws AxisFault
}

/**
* Gets the.
* Gets the Ws Resources client
*
* @param connection
* the connection
* the connection
* @return the HPCC HPCCWsResources client
*/
public static HPCCWsResourcesClient get(Connection connection)
Expand All @@ -128,7 +135,7 @@ public static HPCCWsResourcesClient get(Connection connection)
}

/**
* Gets the.
* Gets the Ws Resources client
*
* @param protocol
* the protocol
Expand All @@ -150,7 +157,7 @@ public static HPCCWsResourcesClient get(String protocol, String targetHost, Stri
}

/**
* Gets the.
* Gets the Ws Resources client
*
* @param protocol
* the protocol
Expand Down Expand Up @@ -188,7 +195,8 @@ protected HPCCWsResourcesClient(Connection baseConnection)
}

/**
* Initializes the service's underlying stub Should only be used by constructors.
* Initializes the service's underlying stub Should only be used by
* constructors.
*
* @param conn
* -- All connection settings included
Expand Down Expand Up @@ -219,14 +227,19 @@ protected void initWsResourcesClientStub(Connection conn)
/**
* Submit service query request
*
* @param req a {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryRequestWrapper} object.
* @param req a
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryRequestWrapper}
* object.
* @throws Exception a {@link java.lang.Exception} object.
* @return a {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryResponseWrapper} object.
* @return a
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryResponseWrapper}
* object.
*/
public ServiceQueryResponseWrapper serviceQuery(ServiceQueryRequestWrapper req) throws Exception
{
if (req == null)
throw new Exception("");
throw new Exception("ServiceQueryRequestWrapper must be provided!");

verifyStub();

ServiceQueryResponse resp = null;
Expand All @@ -249,6 +262,82 @@ public ServiceQueryResponseWrapper serviceQuery(ServiceQueryRequestWrapper req)
return new ServiceQueryResponseWrapper(resp);
}

/**
* Submit target query request
*
* @param req a
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryRequestWrapper}
* object.
* @throws Exception a {@link java.lang.Exception} object.
* @return a
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryResponseWrapper}
* object.
*/
public TargetQueryResponseWrapper targetQuery(TargetQueryRequestWrapper req) throws Exception
{
if (req == null)
throw new Exception("TargetQueryRequestWrapper must be provided!");

verifyStub();

TargetQueryResponse resp = null;

try
{
resp = ((WsResourcesStub) stub).targetQuery(req.getRaw());
}
catch (RemoteException e)
{
throw new Exception("HPCCWSRESOURCESClient.targetQuery(TargetQueryRequestWrapper) encountered RemoteException.", e);
}

if (resp.getExceptions() != null)
{
ArrayOfEspException exceptions = resp.getExceptions();
handleEspExceptions(new ArrayOfEspExceptionWrapper(exceptions), "Error processing service query");
}

return new TargetQueryResponseWrapper(resp);
}

/**
* Submit WebLinks query request
*
* @param req a
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksRequestWrapper}
* object.
* @throws Exception a {@link java.lang.Exception} object.
* @return a
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksResponseWrapper}
* object.
*/
public WebLinksQueryResponseWrapper webLinks(WebLinksQueryRequestWrapper req) throws Exception
{
if (req == null)
throw new Exception("WebLinksQueryRequestWrapper must be provided!");

verifyStub();

WebLinksQueryResponse resp = null;

try
{
resp = ((WsResourcesStub) stub).webLinksQuery(req.getRaw());
}
catch (RemoteException e)
{
throw new Exception("HPCCWSRESOURCESClient.webLinksQuery(WebLinksQueryRequestWrapper) encountered RemoteException.", e);
}

if (resp.getExceptions() != null)
{
ArrayOfEspException exceptions = resp.getExceptions();
handleEspExceptions(new ArrayOfEspExceptionWrapper(exceptions), "Error processing service query");
}

return new WebLinksQueryResponseWrapper(resp);
}

/**
* Ping.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hpccsystems.ws.client.wrappers.gen.wsresources;

import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType;

/*******************************************************************************
* HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems.
*
Expand Down Expand Up @@ -54,9 +56,16 @@ public String toString()
}
public org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType getRaw()
{
org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType raw = null;
if (local_hPCCQueueType.equalsIgnoreCase("ALL"))
return org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType.All;
else if (local_hPCCQueueType.equalsIgnoreCase("Thor"))
return org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType.Thor;
else if (local_hPCCQueueType.equalsIgnoreCase("HThor"))
return org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType.HThor;
else if (local_hPCCQueueType.equalsIgnoreCase("Roxie"))
return org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType.Roxie;
//WARNING base class does not provide expected default constructor//Warning raw class doe not provide expected method: setHPCCQueueType(hPCCQueueType);
return raw;
return null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
import java.util.List;

import org.apache.axis2.AxisFault;
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType;
import org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.HPCCQueueTypeWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.HPCCServiceWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryRequestWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryResponseWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryRequestWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryResponseWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryRequestWrapper;
import org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryResponseWrapper;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
Expand All @@ -36,13 +42,13 @@ HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class WSResroucesClientTest extends BaseRemoteTest
{
private static HPCCWsResourcesClient client;
private static HPCCWsResourcesClient wsResourcesClient;
private boolean iscontainerized = false;

static
{
client = HPCCWsResourcesClient.get(connection);
Assert.assertNotNull(client);
wsResourcesClient = HPCCWsResourcesClient.get(connection);
Assert.assertNotNull(wsResourcesClient);
}

@Before
Expand All @@ -65,7 +71,7 @@ public void serviceQueryTest()
try
{
System.out.println("Querying all HPCC Services...");
ServiceQueryResponseWrapper resp = client.serviceQuery(new ServiceQueryRequestWrapper());
ServiceQueryResponseWrapper resp = wsResourcesClient.serviceQuery(new ServiceQueryRequestWrapper());
Assert.assertNotNull(resp);
Assert.assertNotNull(resp.getServices());
List<HPCCServiceWrapper> services = resp.getServices().getService();
Expand All @@ -88,7 +94,60 @@ public void serviceQueryTest()
public void getContainerizedModeTest() throws Exception
{
System.out.println("Fetching isTargetHPCCContainerized...");
assertNotNull(client.isTargetHPCCContainerized());
assertNotNull(wsResourcesClient.isTargetHPCCContainerized());
}

@Test
public void testTargetQueryNullType() throws Exception
{
// Create a target query request
TargetQueryRequestWrapper request = new TargetQueryRequestWrapper();
// Set the request parameters
request.setType(null);

// Call the targetQuery method
TargetQueryResponseWrapper response = wsResourcesClient.targetQuery(request);

Assert.assertNotNull(response);
}

@Test
public void testTargetQueryAllType() throws Exception
{
// Create a target query request
TargetQueryRequestWrapper request = new TargetQueryRequestWrapper();
request.setType(new HPCCQueueTypeWrapper(HPCCQueueType._All));

// Call the targetQuery method
TargetQueryResponseWrapper response = wsResourcesClient.targetQuery(request);

Assert.assertNotNull(response);
}

@Test
public void testTargetQueryRoxieType() throws Exception
{
// Create a target query request
TargetQueryRequestWrapper request = new TargetQueryRequestWrapper();
request.setType(new HPCCQueueTypeWrapper(HPCCQueueType._Roxie));

// Call the targetQuery method
TargetQueryResponseWrapper response = wsResourcesClient.targetQuery(request);

Assert.assertNotNull(response);
}

@Test
public void testWebLinksQuery() throws Exception
{
// Create a web links query request
WebLinksQueryRequestWrapper request = new WebLinksQueryRequestWrapper();
// Call the webLinksQuery method
WebLinksQueryResponseWrapper response = wsResourcesClient.webLinks(request);

// Assert the response
Assert.assertNotNull(response);
// Add more assertions as needed
}

@Test
Expand All @@ -97,7 +156,7 @@ public void ping() throws Exception
Assume.assumeTrue("Target HPCC does not seem to be containerized", iscontainerized);
try
{
Assert.assertTrue(client.ping());
Assert.assertTrue(wsResourcesClient.ping());
}
catch (AxisFault e)
{
Expand Down

0 comments on commit 63369bc

Please sign in to comment.