Cleaned up metadata checking and removed extra Edm metadata fetch, favoring deserialization from the XML Response payload instead
This commit is contained in:
parent
4da68de5c3
commit
5274dd8557
Binary file not shown.
|
@ -21,9 +21,7 @@ Feature: Web API Server 1.0.2 Certification
|
|||
And the server has an OData-Version header value of "4.0" or "4.01"
|
||||
And the XML Metadata response is valid XML
|
||||
And the XML Metadata returned by the server are valid
|
||||
And Edm metadata are requested from the service root in "ClientSettings_WebAPIURI"
|
||||
Then the server responds with a status code of 200
|
||||
And the server has an OData-Version header value of "4.0" or "4.01"
|
||||
And the XML Metadata returned by the server contains Edm metadata
|
||||
And the Edm metadata returned by the server are valid
|
||||
And the metadata contains a valid service document
|
||||
And the given "Parameter_EndpointResource" resource exists within "Parameter_DD17_WellKnownResourceList"
|
||||
|
@ -304,14 +302,16 @@ Feature: Web API Server 1.0.2 Certification
|
|||
Given valid metadata have been retrieved
|
||||
When a GET request is made to the resolved Url in "REQ-WA103-RC5"
|
||||
Then the server responds with a status code of 400
|
||||
And the server has an OData-Version header value of "4.0" or "4.01"
|
||||
# Disable this check for now until Olingo-1380 is fixed - see: https://issues.apache.org/jira/browse/OLINGO-1380
|
||||
# And the server has an OData-Version header value of "4.0" or "4.01"
|
||||
|
||||
@REQ-WA103-RC07 @core @2.5.2 @core-endorsement
|
||||
Scenario: REQ-WA103-RC07 - 404 Not Found Request
|
||||
Given valid metadata have been retrieved
|
||||
When a GET request is made to the resolved Url in "REQ-WA103-RC07"
|
||||
Then the server responds with a status code of 404
|
||||
And the server has an OData-Version header value of "4.0" or "4.01"
|
||||
# Disable this check for now until Olingo-1380 is fixed - see: https://issues.apache.org/jira/browse/OLINGO-1380
|
||||
# And the server has an OData-Version header value of "4.0" or "4.01"
|
||||
|
||||
#######################################
|
||||
# Bronze Tests
|
||||
|
|
|
@ -68,6 +68,13 @@ public class WebAPIServer_1_0_2 implements En {
|
|||
*/
|
||||
And("^the results match the expected DataSystem JSON schema$", getTestContainer()::validateDataSystem);
|
||||
|
||||
|
||||
And("^the XML Metadata returned by the server contains Edm metadata$", () -> {
|
||||
getTestContainer().setEdm(
|
||||
Commander.deserializeEdm(getTestContainer().getXMLResponseData(), getTestContainer().getCommander().getClient())
|
||||
);
|
||||
});
|
||||
|
||||
/*
|
||||
* Edm Metadata Validator
|
||||
*/
|
||||
|
@ -737,25 +744,6 @@ public class WebAPIServer_1_0_2 implements En {
|
|||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Edm Metadata getter
|
||||
*/
|
||||
And("^Edm metadata are requested from the service root in \"([^\"]*)\"$", (String clientSettingsServiceRoot) -> {
|
||||
final String serviceRoot = Settings.resolveParametersString(clientSettingsServiceRoot, getTestContainer().getSettings());
|
||||
assertEquals("ERROR: given service root doesn't match the one configured in the Commander", serviceRoot, getTestContainer().getCommander().getServiceRoot());
|
||||
|
||||
LOG.info("Requesting Edm Metadata from: " + serviceRoot);
|
||||
try {
|
||||
assertNotNull("ERROR: could not find valid Edm Metadata for given service root: " + serviceRoot, getTestContainer().getEdm());
|
||||
if (showResponses) LOG.info(Commander.getMetadataReport(getTestContainer().getEdm()));
|
||||
} catch (ODataClientErrorException cex) {
|
||||
getTestContainer().setResponseCode(cex.getStatusLine().getStatusCode());
|
||||
fail(cex.toString());
|
||||
} catch (Exception ex) {
|
||||
fail(getDefaultErrorMessage(ex));
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Tests whether a navigation property can be found in the given resource name.
|
||||
*/
|
||||
|
@ -954,17 +942,11 @@ public class WebAPIServer_1_0_2 implements En {
|
|||
* Ensures valid metadata have been retrieved from the server
|
||||
*/
|
||||
Given("^valid metadata have been retrieved$", () -> {
|
||||
if (getTestContainer().hasNotFetchedMetadata()) {
|
||||
getTestContainer().setIsValidXMLMetadata(getTestContainer().getCommander().validateMetadata(getTestContainer().getXMLMetadata()));
|
||||
getTestContainer().setIsXMLMetadataValidXML(Commander.validateXML(getTestContainer().getXMLResponseData()));
|
||||
|
||||
if (getTestContainer().getIsValidXMLMetadata() && getTestContainer().getIsXMLMetadataValidXML()) {
|
||||
getTestContainer().setIsValidEdm(getTestContainer().getCommander().validateMetadata(getTestContainer().getEdm()));
|
||||
}
|
||||
if (!getTestContainer().haveMetadataBeenRequested()) {
|
||||
getTestContainer().validateMetadata();
|
||||
}
|
||||
|
||||
assertTrue(getDefaultErrorMessage("Valid metadata could not be retrieved from the server! Please check the log for more information."),
|
||||
getTestContainer().getIsMetadataValid());
|
||||
getTestContainer().hasValidMetadata());
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
@ -557,17 +557,27 @@ public final class WebAPITestContainer implements TestContainer {
|
|||
setODataServerErrorException(exception);
|
||||
}
|
||||
|
||||
public boolean getIsMetadataValid() {
|
||||
public final boolean hasValidMetadata() {
|
||||
return xmlMetadata.get() != null && getIsValidXMLMetadata()
|
||||
&& xmlResponseData.get() != null && getIsXMLMetadataValidXML()
|
||||
&& edm.get() != null && getIsValidEdm();
|
||||
}
|
||||
|
||||
public final void validateMetadata() {
|
||||
validateXMLMetadataXML();
|
||||
|
||||
setXMLMetadata(Commander.deserializeXMLMetadata(getXMLResponseData(), getCommander().getClient()));
|
||||
validateXMLMetadata();
|
||||
|
||||
setEdm(Commander.deserializeEdm(getXMLResponseData(), getCommander().getClient()));
|
||||
validateEdm();
|
||||
}
|
||||
|
||||
public boolean getIsValidXMLMetadata() {
|
||||
return isValidXMLMetadata.get();
|
||||
}
|
||||
|
||||
public void setIsValidXMLMetadata(boolean isValid) {
|
||||
private void setIsValidXMLMetadata(boolean isValid) {
|
||||
isValidXMLMetadata.set(isValid);
|
||||
}
|
||||
|
||||
|
@ -575,7 +585,7 @@ public final class WebAPITestContainer implements TestContainer {
|
|||
return isValidEdm.get();
|
||||
}
|
||||
|
||||
public void setIsValidEdm(boolean isValid) {
|
||||
private void setIsValidEdm(boolean isValid) {
|
||||
isValidEdm.set(isValid);
|
||||
}
|
||||
|
||||
|
@ -583,12 +593,12 @@ public final class WebAPITestContainer implements TestContainer {
|
|||
return isXMLMetadataValidXML.get();
|
||||
}
|
||||
|
||||
public void setIsXMLMetadataValidXML(boolean isValid) {
|
||||
private void setAreXMLMetadataValidXML(boolean isValid) {
|
||||
isXMLMetadataValidXML.set(isValid);
|
||||
}
|
||||
|
||||
public boolean hasNotFetchedMetadata() {
|
||||
return !hasXMLMetadataBeenRequested.get() && !hasEdmBeenRequested.get();
|
||||
public boolean haveMetadataBeenRequested() {
|
||||
return hasXMLMetadataBeenRequested.get() && hasEdmBeenRequested.get();
|
||||
}
|
||||
|
||||
public boolean getShowResponses() {
|
||||
|
@ -655,7 +665,7 @@ public final class WebAPITestContainer implements TestContainer {
|
|||
|
||||
try {
|
||||
boolean isValid = Commander.validateXML(getXMLResponseData());
|
||||
setIsXMLMetadataValidXML(isValid);
|
||||
setAreXMLMetadataValidXML(isValid);
|
||||
LOG.info("XMLMetadata string is " + (isValid ? "valid" : "invalid") + " XML!");
|
||||
} catch (Exception ex) {
|
||||
fail(getDefaultErrorMessage(ex));
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.reso.commander.test.stepdefs;
|
||||
|
||||
import io.cucumber.java8.En;
|
||||
import org.reso.commander.Commander;
|
||||
import org.reso.commander.certfication.containers.WebAPITestContainer;
|
||||
import org.reso.commander.common.TestUtils;
|
||||
import org.reso.models.Settings;
|
||||
|
@ -45,14 +44,6 @@ public class TestWebAPITestContainer implements En {
|
|||
getTestContainer().setResponseCode(200);
|
||||
|
||||
getTestContainer().setXMLResponseData(xmlMetadataString);
|
||||
getTestContainer().validateXMLMetadataXML();
|
||||
|
||||
getTestContainer().setXMLMetadata(Commander.deserializeXMLMetadata(xmlMetadataString, getTestContainer().getCommander().getClient()));
|
||||
getTestContainer().validateXMLMetadata();
|
||||
|
||||
getTestContainer().setEdm(Commander.deserializeEdm(xmlMetadataString, getTestContainer().getCommander().getClient()));
|
||||
getTestContainer().validateEdm();
|
||||
|
||||
} catch (Exception ex) {
|
||||
fail(getDefaultErrorMessage(ex));
|
||||
}
|
||||
|
@ -91,12 +82,14 @@ public class TestWebAPITestContainer implements En {
|
|||
getTestContainer().getSettings());
|
||||
});
|
||||
Then("^metadata are valid$", () -> {
|
||||
getTestContainer().validateMetadata();
|
||||
assertTrue(getDefaultErrorMessage("getIsMetadataValid() returned false when true was expected!"),
|
||||
getTestContainer().getIsMetadataValid());
|
||||
getTestContainer().hasValidMetadata());
|
||||
});
|
||||
Then("^metadata are invalid$", () -> {
|
||||
getTestContainer().validateMetadata();
|
||||
assertFalse(getDefaultErrorMessage("getIsMetadataValid() returned true when false was expected!"),
|
||||
getTestContainer().getIsMetadataValid());
|
||||
getTestContainer().hasValidMetadata());
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
import static org.junit.Assert.*;
|
||||
import static org.reso.commander.common.ErrorMsg.getDefaultErrorMessage;
|
||||
|
||||
/**
|
||||
* Tests metadata validation methods
|
||||
*/
|
||||
public class TestXMLAndMetadataValidation implements En {
|
||||
private static final Logger LOG = LogManager.getLogger(TestXMLAndMetadataValidation.class);
|
||||
AtomicReference<String> xmlMetadataString = new AtomicReference<>();
|
||||
|
|
Loading…
Reference in New Issue