Moved exception handling for metadata validation to .feature file rather than helper class

This commit is contained in:
Joshua Darnell 2020-03-08 12:26:33 -07:00
parent 4ce389e493
commit 16c34664d0
4 changed files with 15 additions and 29 deletions

View File

@ -452,9 +452,9 @@ Please feel free to suggest additional tags that might be useful.
A sample of the runtime terminal output follows: A sample of the runtime terminal output follows:
```gherkin ```gherkin
> Task :testWebApiServer_1_0_2_Platinum > Task :testWebApiServer_1_0_2_Platinum
@REQ-WA103-END3 @core @x.y.z @core-endorsement @metadata @REQ-WA103-END3 @core @2.4.1 @core-endorsement @metadata
Scenario: Request and Validate Server Metadata Scenario: Request and Validate Server Metadata
Using RESOScript: /path/to/your.resoscript Using RESOScript: /path/to/your.resoscript
@ -471,16 +471,16 @@ A sample of the runtime terminal output follows:
Found Default Entity Container: 'Default' Found Default Entity Container: 'Default'
When a default entity container exists for the service root in "ClientSettings_WebAPIURI" When a default entity container exists for the service root in "ClientSettings_WebAPIURI"
Fetching XMLMetadata with OData Client from: https://api.server.com/$metadata
XML Metadata retrieved from: https://api.server.com
And XML Metadata are requested from the service root in "ClientSettings_WebAPIURI"
Asserted Response Code: 200, Server Response Code: 200 Asserted Response Code: 200, Server Response Code: 200
Then the server responds with a status code of 200 Then the server responds with a status code of 200
Edm Metadata is valid! Edm Metadata is valid!
And the Edm metadata returned by the server are valid And the Edm metadata returned by the server are valid
Fetching XMLMetadata with OData Client from: https://api.server.com/$metadata
XML Metadata retrieved from: https://api.server.com
And XML Metadata are requested from the service root in "ClientSettings_WebAPIURI"
XML Metadata is valid! XML Metadata is valid!
And the XML metadata returned by the server are valid And the XML metadata returned by the server are valid
@ -501,7 +501,7 @@ A sample of the runtime terminal output follows:
1 Scenarios (1 passed) 1 Scenarios (1 passed)
10 Steps (10 passed) 10 Steps (10 passed)
0m3.177s 0m3.071s
``` ```

Binary file not shown.

View File

@ -835,6 +835,7 @@ public class WebAPIServer_1_0_2 implements En {
ODataRetrieveResponse<Edm> oDataRetrieveResponse = commander.get().getODataRetrieveEdmResponse(); ODataRetrieveResponse<Edm> oDataRetrieveResponse = commander.get().getODataRetrieveEdmResponse();
responseCode.set(oDataRetrieveResponse.getStatusCode()); responseCode.set(oDataRetrieveResponse.getStatusCode());
edm.set(oDataRetrieveResponse.getBody()); edm.set(oDataRetrieveResponse.getBody());
assertNotNull("ERROR: could not find default entity container for given service root: " + serviceRoot, edm.get().getEntityContainer()); assertNotNull("ERROR: could not find default entity container for given service root: " + serviceRoot, edm.get().getEntityContainer());
LOG.info("Found Default Entity Container: '" + edm.get().getEntityContainer().getNamespace() + "'"); LOG.info("Found Default Entity Container: '" + edm.get().getEntityContainer().getNamespace() + "'");
} catch (ODataClientErrorException cex) { } catch (ODataClientErrorException cex) {

View File

@ -199,18 +199,9 @@ public class Commander {
* @return XMLMetadata representation of the server metadata. * @return XMLMetadata representation of the server metadata.
*/ */
public XMLMetadata getXMLMetadata() { public XMLMetadata getXMLMetadata() {
if (xmlMetadata == null) {
try {
EdmMetadataRequest metadataRequest = client.getRetrieveRequestFactory().getMetadataRequest(serviceRoot); EdmMetadataRequest metadataRequest = client.getRetrieveRequestFactory().getMetadataRequest(serviceRoot);
LOG.info("Fetching XMLMetadata with OData Client from: " + metadataRequest.getURI().toString()); LOG.info("Fetching XMLMetadata with OData Client from: " + metadataRequest.getURI().toString());
return metadataRequest.getXMLMetadata(); return metadataRequest.getXMLMetadata();
} catch (ODataClientErrorException cex) {
LOG.error("ERROR: could not retrieve Metadata for the given service root!");
LOG.error(cex.getStatusLine().toString());
throw cex;
}
}
return null;
} }
/** /**
@ -218,15 +209,9 @@ public class Commander {
* @return the OData response retrieved from the server when making the request. * @return the OData response retrieved from the server when making the request.
*/ */
public ODataRetrieveResponse<Edm> getODataRetrieveEdmResponse() { public ODataRetrieveResponse<Edm> getODataRetrieveEdmResponse() {
try {
EdmMetadataRequest metadataRequest = client.getRetrieveRequestFactory().getMetadataRequest(serviceRoot); EdmMetadataRequest metadataRequest = client.getRetrieveRequestFactory().getMetadataRequest(serviceRoot);
LOG.info("Fetching Edm with OData Client from: " + metadataRequest.getURI().toString()); LOG.info("Fetching Edm with OData Client from: " + metadataRequest.getURI().toString());
return metadataRequest.execute(); return metadataRequest.execute();
} catch (ODataClientErrorException cex) {
LOG.error("ERROR: could not retrieve Metadata for the given service root!");
LOG.error(cex.getStatusLine().toString());
throw cex;
}
} }
/** /**