diff --git a/build/libs/web-api-commander.jar b/build/libs/web-api-commander.jar index 19f99be..d3f6d07 100644 Binary files a/build/libs/web-api-commander.jar and b/build/libs/web-api-commander.jar differ diff --git a/src/main/java/org/reso/certification/features/web-api/web-api-server-1.0.2.feature b/src/main/java/org/reso/certification/features/web-api/web-api-server-1.0.2.feature index 7a6b290..4f7cc73 100644 --- a/src/main/java/org/reso/certification/features/web-api/web-api-server-1.0.2.feature +++ b/src/main/java/org/reso/certification/features/web-api/web-api-server-1.0.2.feature @@ -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 diff --git a/src/main/java/org/reso/certification/stepdefs/WebAPIServer_1_0_2.java b/src/main/java/org/reso/certification/stepdefs/WebAPIServer_1_0_2.java index f43984e..83f1308 100644 --- a/src/main/java/org/reso/certification/stepdefs/WebAPIServer_1_0_2.java +++ b/src/main/java/org/reso/certification/stepdefs/WebAPIServer_1_0_2.java @@ -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()); }); } diff --git a/src/main/java/org/reso/commander/certfication/containers/WebAPITestContainer.java b/src/main/java/org/reso/commander/certfication/containers/WebAPITestContainer.java index 69e17d9..bc8cc72 100644 --- a/src/main/java/org/reso/commander/certfication/containers/WebAPITestContainer.java +++ b/src/main/java/org/reso/commander/certfication/containers/WebAPITestContainer.java @@ -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)); diff --git a/src/test/java/org/reso/commander/test/stepdefs/TestWebAPITestContainer.java b/src/test/java/org/reso/commander/test/stepdefs/TestWebAPITestContainer.java index 588cdfe..236c581 100644 --- a/src/test/java/org/reso/commander/test/stepdefs/TestWebAPITestContainer.java +++ b/src/test/java/org/reso/commander/test/stepdefs/TestWebAPITestContainer.java @@ -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()); }); diff --git a/src/test/java/org/reso/commander/test/stepdefs/TestXMLAndMetadataValidation.java b/src/test/java/org/reso/commander/test/stepdefs/TestXMLAndMetadataValidation.java index 7c1385b..cf4223d 100644 --- a/src/test/java/org/reso/commander/test/stepdefs/TestXMLAndMetadataValidation.java +++ b/src/test/java/org/reso/commander/test/stepdefs/TestXMLAndMetadataValidation.java @@ -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 xmlMetadataString = new AtomicReference<>();