Skip to content

Commit 9e974c9

Browse files
authoredApr 4, 2024··
XXX-HPCC4J Add WsResources test cases (#699)
- 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 <rodrigo.pastrana@lexisnexisrisk.com>
1 parent 32985ac commit 9e974c9

File tree

3 files changed

+188
-18
lines changed

3 files changed

+188
-18
lines changed
 

‎wsclient/src/main/java/org/hpccsystems/ws/client/HPCCWsResourcesClient.java

+99-10
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
2727
import org.apache.logging.log4j.Logger;
2828
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.ArrayOfEspException;
2929
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.ServiceQueryResponse;
30+
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.TargetQueryResponse;
3031
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.WsResourcesPingRequest;
3132
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.WsResourcesStub;
33+
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.WebLinksQueryResponse;
3234
import org.hpccsystems.ws.client.utils.Connection;
3335
import org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper;
3436
import org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryRequestWrapper;
3537
import org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryResponseWrapper;
38+
import org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryRequestWrapper;
39+
import org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryResponseWrapper;
40+
import org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryRequestWrapper;
41+
import org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryResponseWrapper;
42+
3643

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

4956
/**
5057
* Load WSDLURL.
51-
*/
58+
*/
5259
private static void loadWSDLURL()
5360
{
5461
try
@@ -67,7 +74,7 @@ private static void loadWSDLURL()
6774
* Gets the service URI.
6875
*
6976
* @return the service URI
70-
*/
77+
*/
7178
public String getServiceURI()
7279
{
7380
return WSRESOURCESURI;
@@ -116,10 +123,10 @@ public Stub getDefaultStub() throws AxisFault
116123
}
117124

118125
/**
119-
* Gets the.
126+
* Gets the Ws Resources client
120127
*
121128
* @param connection
122-
* the connection
129+
* the connection
123130
* @return the HPCC HPCCWsResources client
124131
*/
125132
public static HPCCWsResourcesClient get(Connection connection)
@@ -128,7 +135,7 @@ public static HPCCWsResourcesClient get(Connection connection)
128135
}
129136

130137
/**
131-
* Gets the.
138+
* Gets the Ws Resources client
132139
*
133140
* @param protocol
134141
* the protocol
@@ -150,7 +157,7 @@ public static HPCCWsResourcesClient get(String protocol, String targetHost, Stri
150157
}
151158

152159
/**
153-
* Gets the.
160+
* Gets the Ws Resources client
154161
*
155162
* @param protocol
156163
* the protocol
@@ -188,7 +195,8 @@ protected HPCCWsResourcesClient(Connection baseConnection)
188195
}
189196

190197
/**
191-
* Initializes the service's underlying stub Should only be used by constructors.
198+
* Initializes the service's underlying stub Should only be used by
199+
* constructors.
192200
*
193201
* @param conn
194202
* -- All connection settings included
@@ -219,14 +227,19 @@ protected void initWsResourcesClientStub(Connection conn)
219227
/**
220228
* Submit service query request
221229
*
222-
* @param req a {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryRequestWrapper} object.
230+
* @param req a
231+
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryRequestWrapper}
232+
* object.
223233
* @throws Exception a {@link java.lang.Exception} object.
224-
* @return a {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryResponseWrapper} object.
234+
* @return a
235+
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryResponseWrapper}
236+
* object.
225237
*/
226238
public ServiceQueryResponseWrapper serviceQuery(ServiceQueryRequestWrapper req) throws Exception
227239
{
228240
if (req == null)
229-
throw new Exception("");
241+
throw new Exception("ServiceQueryRequestWrapper must be provided!");
242+
230243
verifyStub();
231244

232245
ServiceQueryResponse resp = null;
@@ -249,6 +262,82 @@ public ServiceQueryResponseWrapper serviceQuery(ServiceQueryRequestWrapper req)
249262
return new ServiceQueryResponseWrapper(resp);
250263
}
251264

265+
/**
266+
* Submit target query request
267+
*
268+
* @param req a
269+
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryRequestWrapper}
270+
* object.
271+
* @throws Exception a {@link java.lang.Exception} object.
272+
* @return a
273+
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryResponseWrapper}
274+
* object.
275+
*/
276+
public TargetQueryResponseWrapper targetQuery(TargetQueryRequestWrapper req) throws Exception
277+
{
278+
if (req == null)
279+
throw new Exception("TargetQueryRequestWrapper must be provided!");
280+
281+
verifyStub();
282+
283+
TargetQueryResponse resp = null;
284+
285+
try
286+
{
287+
resp = ((WsResourcesStub) stub).targetQuery(req.getRaw());
288+
}
289+
catch (RemoteException e)
290+
{
291+
throw new Exception("HPCCWSRESOURCESClient.targetQuery(TargetQueryRequestWrapper) encountered RemoteException.", e);
292+
}
293+
294+
if (resp.getExceptions() != null)
295+
{
296+
ArrayOfEspException exceptions = resp.getExceptions();
297+
handleEspExceptions(new ArrayOfEspExceptionWrapper(exceptions), "Error processing service query");
298+
}
299+
300+
return new TargetQueryResponseWrapper(resp);
301+
}
302+
303+
/**
304+
* Submit WebLinks query request
305+
*
306+
* @param req a
307+
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryRequestWrapper}
308+
* object.
309+
* @throws Exception a {@link java.lang.Exception} object.
310+
* @return a
311+
* {@link org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryResponseWrapper}
312+
* object.
313+
*/
314+
public WebLinksQueryResponseWrapper webLinks(WebLinksQueryRequestWrapper req) throws Exception
315+
{
316+
if (req == null)
317+
throw new Exception("WebLinksQueryRequestWrapper must be provided!");
318+
319+
verifyStub();
320+
321+
WebLinksQueryResponse resp = null;
322+
323+
try
324+
{
325+
resp = ((WsResourcesStub) stub).webLinksQuery(req.getRaw());
326+
}
327+
catch (RemoteException e)
328+
{
329+
throw new Exception("HPCCWSRESOURCESClient.webLinksQuery(WebLinksQueryRequestWrapper) encountered RemoteException.", e);
330+
}
331+
332+
if (resp.getExceptions() != null)
333+
{
334+
ArrayOfEspException exceptions = resp.getExceptions();
335+
handleEspExceptions(new ArrayOfEspExceptionWrapper(exceptions), "Error processing service query");
336+
}
337+
338+
return new WebLinksQueryResponseWrapper(resp);
339+
}
340+
252341
/**
253342
* Ping.
254343
*

‎wsclient/src/main/java/org/hpccsystems/ws/client/wrappers/gen/wsresources/HPCCQueueTypeWrapper.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.hpccsystems.ws.client.wrappers.gen.wsresources;
22

3+
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType;
4+
35
/*******************************************************************************
46
* HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems.
57
*
@@ -54,9 +56,16 @@ public String toString()
5456
}
5557
public org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType getRaw()
5658
{
57-
org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType raw = null;
59+
if (local_hPCCQueueType.equalsIgnoreCase("ALL"))
60+
return org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType.All;
61+
else if (local_hPCCQueueType.equalsIgnoreCase("Thor"))
62+
return org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType.Thor;
63+
else if (local_hPCCQueueType.equalsIgnoreCase("HThor"))
64+
return org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType.HThor;
65+
else if (local_hPCCQueueType.equalsIgnoreCase("Roxie"))
66+
return org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType.Roxie;
5867
//WARNING base class does not provide expected default constructor//Warning raw class doe not provide expected method: setHPCCQueueType(hPCCQueueType);
59-
return raw;
68+
return null;
6069
}
6170

6271

‎wsclient/src/test/java/org/hpccsystems/ws/client/WSResroucesClientTest.java

+78-6
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
2222
import java.util.List;
2323

2424
import org.apache.axis2.AxisFault;
25+
import org.hpccsystems.ws.client.gen.axis2.wsresources.latest.HPCCQueueType;
2526
import org.hpccsystems.ws.client.wrappers.ArrayOfEspExceptionWrapper;
27+
import org.hpccsystems.ws.client.wrappers.EspExceptionWrapper;
28+
import org.hpccsystems.ws.client.wrappers.gen.wsresources.HPCCQueueTypeWrapper;
2629
import org.hpccsystems.ws.client.wrappers.gen.wsresources.HPCCServiceWrapper;
2730
import org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryRequestWrapper;
2831
import org.hpccsystems.ws.client.wrappers.gen.wsresources.ServiceQueryResponseWrapper;
32+
import org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryRequestWrapper;
33+
import org.hpccsystems.ws.client.wrappers.gen.wsresources.TargetQueryResponseWrapper;
34+
import org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryRequestWrapper;
35+
import org.hpccsystems.ws.client.wrappers.gen.wsresources.WebLinksQueryResponseWrapper;
2936
import org.junit.Assert;
3037
import org.junit.Assume;
3138
import org.junit.Before;
@@ -36,13 +43,13 @@ HPCC SYSTEMS software Copyright (C) 2021 HPCC Systems®.
3643
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
3744
public class WSResroucesClientTest extends BaseRemoteTest
3845
{
39-
private static HPCCWsResourcesClient client;
46+
private static HPCCWsResourcesClient wsResourcesClient;
4047
private boolean iscontainerized = false;
4148

4249
static
4350
{
44-
client = HPCCWsResourcesClient.get(connection);
45-
Assert.assertNotNull(client);
51+
wsResourcesClient = HPCCWsResourcesClient.get(connection);
52+
Assert.assertNotNull(wsResourcesClient);
4653
}
4754

4855
@Before
@@ -65,7 +72,7 @@ public void serviceQueryTest()
6572
try
6673
{
6774
System.out.println("Querying all HPCC Services...");
68-
ServiceQueryResponseWrapper resp = client.serviceQuery(new ServiceQueryRequestWrapper());
75+
ServiceQueryResponseWrapper resp = wsResourcesClient.serviceQuery(new ServiceQueryRequestWrapper());
6976
Assert.assertNotNull(resp);
7077
Assert.assertNotNull(resp.getServices());
7178
List<HPCCServiceWrapper> services = resp.getServices().getService();
@@ -88,7 +95,72 @@ public void serviceQueryTest()
8895
public void getContainerizedModeTest() throws Exception
8996
{
9097
System.out.println("Fetching isTargetHPCCContainerized...");
91-
assertNotNull(client.isTargetHPCCContainerized());
98+
assertNotNull(wsResourcesClient.isTargetHPCCContainerized());
99+
}
100+
101+
@Test
102+
public void testTargetQueryNullType() throws Exception
103+
{
104+
// Create a target query request
105+
TargetQueryRequestWrapper request = new TargetQueryRequestWrapper();
106+
// Set the request parameters
107+
request.setType(null);
108+
109+
try
110+
{
111+
TargetQueryResponseWrapper response = wsResourcesClient.targetQuery(request);
112+
Assert.assertNotNull(response);
113+
}
114+
catch (ArrayOfEspExceptionWrapper e)
115+
{
116+
List<EspExceptionWrapper> espexceptions = e.getEspExceptions();
117+
Assert.assertNotNull(espexceptions);
118+
Assert.assertNotNull(espexceptions.get(0));
119+
Assert.assertTrue(e.getEspExceptions().get(0).getMessage().contains("HPCCQueueType not defined."));
120+
}
121+
catch (Exception e)
122+
{
123+
Assert.fail("Unexpected Exception type");
124+
}
125+
}
126+
127+
@Test
128+
public void testTargetQueryAllType() throws Exception
129+
{
130+
// Create a target query request
131+
TargetQueryRequestWrapper request = new TargetQueryRequestWrapper();
132+
request.setType(new HPCCQueueTypeWrapper(HPCCQueueType._All));
133+
134+
// Call the targetQuery method
135+
TargetQueryResponseWrapper response = wsResourcesClient.targetQuery(request);
136+
137+
Assert.assertNotNull(response);
138+
}
139+
140+
@Test
141+
public void testTargetQueryRoxieType() throws Exception
142+
{
143+
// Create a target query request
144+
TargetQueryRequestWrapper request = new TargetQueryRequestWrapper();
145+
request.setType(new HPCCQueueTypeWrapper(HPCCQueueType._Roxie));
146+
147+
// Call the targetQuery method
148+
TargetQueryResponseWrapper response = wsResourcesClient.targetQuery(request);
149+
150+
Assert.assertNotNull(response);
151+
}
152+
153+
@Test
154+
public void testWebLinksQuery() throws Exception
155+
{
156+
// Create a web links query request
157+
WebLinksQueryRequestWrapper request = new WebLinksQueryRequestWrapper();
158+
// Call the webLinksQuery method
159+
WebLinksQueryResponseWrapper response = wsResourcesClient.webLinks(request);
160+
161+
// Assert the response
162+
Assert.assertNotNull(response);
163+
// Add more assertions as needed
92164
}
93165

94166
@Test
@@ -97,7 +169,7 @@ public void ping() throws Exception
97169
Assume.assumeTrue("Target HPCC does not seem to be containerized", iscontainerized);
98170
try
99171
{
100-
Assert.assertTrue(client.ping());
172+
Assert.assertTrue(wsResourcesClient.ping());
101173
}
102174
catch (AxisFault e)
103175
{

0 commit comments

Comments
 (0)