diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index fef9ec8..82214da 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -10,7 +10,7 @@ on:
branches: [ master ]
jobs:
- test:
+ build:
runs-on: ubuntu-latest
@@ -22,5 +22,5 @@ jobs:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- - name: Run acceptance tests
- run: ./gradlew test
+ - name: Build and Run acceptance tests
+ run: ./gradlew build
diff --git a/src/main/java/org/reso/commander/Commander.java b/src/main/java/org/reso/commander/Commander.java
index 7076f90..45e7ff1 100644
--- a/src/main/java/org/reso/commander/Commander.java
+++ b/src/main/java/org/reso/commander/Commander.java
@@ -249,58 +249,6 @@ public class Commander {
return reportBuilder.toString();
}
- /**
- * Static version of the metadata validator that can work with a given client
- *
- * @param metadata the XML Metadata to validate
- * @param client the OData client to use for validation
- * @return true if the given XML metadata is valid, false otherwise
- */
- public static boolean validateMetadata(XMLMetadata metadata, ODataClient client) {
- try {
- // call the probably-useless metadata validator. can't hurt though
- // SEE: https://github.com/apache/olingo-odata4/blob/master/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java#L77-L116
- client.metadataValidation().validateMetadata(metadata);
-
- // also check whether metadata contains a valid service document in OData v4 format
- return client.metadataValidation().isServiceDocument(metadata)
- && client.metadataValidation().isV4Metadata(metadata);
- } catch (NullPointerException nex) {
- LOG.error("ERROR: Validation Failed! Null pointer exception while trying to validate metadata.");
- } catch (Exception ex) {
- LOG.error("ERROR: Validation Failed! General error occurred when validating metadata.\n" + ex.getMessage());
- if (ex.getCause() != null) {
- LOG.error("Caused by: " + ex.getCause().getMessage());
- }
- }
- return false;
- }
-
- /**
- * Static version of the metadata validator that can work with a given client
- *
- * @param edm the Edm to validate
- * @param client the OData client to use for validation
- * @return true if the given XML metadata is valid, false otherwise
- */
- public static boolean validateMetadata(Edm edm, ODataClient client) {
- try {
- // call the probably-useless metadata validator. can't hurt though
- // SEE: https://github.com/apache/olingo-odata4/blob/master/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java#L77-L116
- client.metadataValidation().validateMetadata(edm);
- //if Edm metadata are invalid, the previous line will throw an exception and this line won't be reached.
- return true;
- } catch (NullPointerException nex) {
- LOG.error("ERROR: Validation Failed! Null pointer exception while trying to validate metadata.");
- } catch (Exception ex) {
- LOG.error("ERROR: Validation Failed! General error occurred when validating metadata.\n" + ex.getMessage());
- if (ex.getCause() != null) {
- LOG.error("Caused by: " + ex.getCause().getMessage());
- }
- }
- return false;
- }
-
/**
* Deserializes XML Metadata from a string
*
@@ -432,6 +380,59 @@ public class Commander {
client.getSerializer(ContentType.APPLICATION_XML).write(writer, metadata);
}
+
+ /**
+ * Static version of the metadata validator that can work with a given client
+ *
+ * @param metadata the XML Metadata to validate
+ * @param client the OData client to use for validation
+ * @return true if the given XML metadata is valid, false otherwise
+ */
+ public static boolean validateMetadata(XMLMetadata metadata, ODataClient client) {
+ try {
+ // call the probably-useless metadata validator. can't hurt though
+ // SEE: https://github.com/apache/olingo-odata4/blob/master/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java#L77-L116
+ client.metadataValidation().validateMetadata(metadata);
+
+ // also check whether metadata contains a valid service document in OData v4 format
+ return client.metadataValidation().isServiceDocument(metadata)
+ && client.metadataValidation().isV4Metadata(metadata);
+ } catch (NullPointerException nex) {
+ LOG.error("ERROR: Validation Failed! Null pointer exception while trying to validate metadata.");
+ } catch (Exception ex) {
+ LOG.error("ERROR: Validation Failed! General error occurred when validating metadata.\n" + ex.getMessage());
+ if (ex.getCause() != null) {
+ LOG.error("Caused by: " + ex.getCause().getMessage());
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Static version of the metadata validator that can work with a given client
+ *
+ * @param edm the Edm to validate
+ * @param client the OData client to use for validation
+ * @return true if the given XML metadata is valid, false otherwise
+ */
+ public static boolean validateMetadata(Edm edm, ODataClient client) {
+ try {
+ // call the probably-useless metadata validator. can't hurt though
+ // SEE: https://github.com/apache/olingo-odata4/blob/master/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java#L77-L116
+ client.metadataValidation().validateMetadata(edm);
+ //if Edm metadata are invalid, the previous line will throw an exception and this line won't be reached.
+ return true;
+ } catch (NullPointerException nex) {
+ LOG.error("ERROR: Validation Failed! Null pointer exception while trying to validate metadata.");
+ } catch (Exception ex) {
+ LOG.error("ERROR: Validation Failed! General error occurred when validating metadata.\n" + ex.getMessage());
+ if (ex.getCause() != null) {
+ LOG.error("Caused by: " + ex.getCause().getMessage());
+ }
+ }
+ return false;
+ }
+
/**
* Validates given XMLMetadata
*
diff --git a/src/test/java/org/reso/commander/test/features/test-web-api-test-container.feature b/src/test/java/org/reso/commander/test/features/test-web-api-test-container.feature
index bf6d725..fab2552 100644
--- a/src/test/java/org/reso/commander/test/features/test-web-api-test-container.feature
+++ b/src/test/java/org/reso/commander/test/features/test-web-api-test-container.feature
@@ -1,13 +1,15 @@
Feature: Commander Platinum Web API Test Container
Background:
- Given a Web API test container was created using the RESOScript "mock.platinum.resoscript"
- And metadata were loaded from the sample resource "good.edmx-and-edm.xml"
+ Given a Web API test container was created using the RESOScript "mock-platinum.resoscript"
+ And metadata were loaded from the sample resource "good-edmx-and-edm.xml"
Scenario: Test Container is using Token-Based Authentication
Given a Commander instance exists within the test container
+ And Settings are present in the test container
And an auth token is provided in "ClientSettings_BearerToken"
Then the Commander is created using auth token client mode
And the auth token has a value of "testTokenValue"
But the Commander is not created using client credentials mode
+ Scenario: Test that the container can validate known-good metadata
diff --git a/src/test/java/org/reso/commander/test/features/test-xml-and-metadata-validation.feature b/src/test/java/org/reso/commander/test/features/test-xml-and-metadata-validation.feature
index 0df26ab..8dbfd58 100644
--- a/src/test/java/org/reso/commander/test/features/test-xml-and-metadata-validation.feature
+++ b/src/test/java/org/reso/commander/test/features/test-xml-and-metadata-validation.feature
@@ -8,12 +8,12 @@ Feature: Commander XML and Metadata Validation
# XML Validation Tests
#######################################
Scenario: XML Validation using OASIS reference XSDs
- Given metadata were loaded from the sample resource "good.edmx-and-edm.xml"
+ Given metadata were loaded from the sample resource "good-edmx-and-edm.xml"
When XML validation is performed on the resource data
Then XML validation succeeds
Scenario: XML Validation fails when XML are malformed
- Given metadata were loaded from the sample resource "bad.edmx-unparsable-xml.xml"
+ Given metadata were loaded from the sample resource "bad-edmx-unparsable-xml.xml"
When XML validation is performed on the resource data
Then XML validation fails
@@ -22,12 +22,12 @@ Feature: Commander XML and Metadata Validation
# XML Metadata Validation Tests
#######################################
Scenario: XML Metadata validation succeeds when XML Metadata are valid
- Given metadata were loaded from the sample resource "good.edmx-and-edm.xml"
+ Given metadata were loaded from the sample resource "good-edmx-and-edm.xml"
When XML Metadata validation is performed on the resource data
Then XML Metadata validation succeeds
Scenario: XML Validation fails when XML Metadata are missing Key element in EntityType definition
- Given metadata were loaded from the sample resource "bad.edmx-no-keyfield.xml"
+ Given metadata were loaded from the sample resource "bad-edmx-no-keyfield.xml"
When XML Metadata validation is performed on the resource data
Then XML Metadata validation fails
@@ -36,11 +36,11 @@ Feature: Commander XML and Metadata Validation
# Edm Validation Tests
#######################################
Scenario: Edm validation succeeds when XML Metadata contain a valid Edm
- Given metadata were loaded from the sample resource "good.edmx-and-edm.xml"
+ Given metadata were loaded from the sample resource "good-edmx-and-edm.xml"
When Edm validation is performed on the resource data
Then Edm Metadata validation succeeds
Scenario: Edm validation fails when XML Metadata don't contain a valid service document
- Given metadata were loaded from the sample resource "bad.edmx-wrong-edm-binding-target.xml"
+ Given metadata were loaded from the sample resource "bad-edmx-wrong-edm-binding-target.xml"
When Edm validation is performed on the resource data
Then Edm Metadata validation fails
\ No newline at end of file
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 3ce9647..a9bc85d 100644
--- a/src/test/java/org/reso/commander/test/stepdefs/TestWebAPITestContainer.java
+++ b/src/test/java/org/reso/commander/test/stepdefs/TestWebAPITestContainer.java
@@ -26,11 +26,11 @@ public class TestWebAPITestContainer implements En {
URL resource = getClass().getClassLoader().getResource(fileName);
assertNotNull(getDefaultErrorMessage("was unable to find the given RESOScript:", fileName), resource);
- testContainer.set(new WebAPITestContainer());
- testContainer.get().setSettings(Settings.loadFromRESOScript(new File(resource.getFile())));
- assertNotNull(getDefaultErrorMessage("could not load mock RESOScript: " + resource.getFile()), testContainer.get().getSettings());
+ setTestContainer(new WebAPITestContainer());
+ getTestContainer().setSettings(Settings.loadFromRESOScript(new File(resource.getFile())));
+ assertNotNull(getDefaultErrorMessage("could not load mock RESOScript: " + resource.getFile()), getTestContainer().getSettings());
- testContainer.get().initialize();
+ getTestContainer().initialize();
} catch (Exception ex) {
fail(getDefaultErrorMessage(ex));
}
@@ -41,28 +41,41 @@ public class TestWebAPITestContainer implements En {
* auth settings validation
*/
When("^an auth token is provided in \"([^\"]*)\"$", (String clientSettingsAuthToken) -> {
- String token = Settings.resolveParametersString(clientSettingsAuthToken, testContainer.get().getSettings());
+ String token = Settings.resolveParametersString(clientSettingsAuthToken, getTestContainer().getSettings());
assertNotNull(getDefaultErrorMessage("BearerToken is null in the ClientSettings section!"), token);
});
Then("^the Commander is created using auth token client mode$", () -> {
assertTrue(getDefaultErrorMessage("expected auth token Commander client!"),
- testContainer.get().getCommander().isAuthTokenClient());
+ getTestContainer().getCommander().isAuthTokenClient());
});
And("^the auth token has a value of \"([^\"]*)\"$", (String assertedTokenValue) -> {
assertEquals(getDefaultErrorMessage("asserted token value is not equal to the one provided in the container!"),
- assertedTokenValue, testContainer.get().getAuthToken());
+ assertedTokenValue, getTestContainer().getAuthToken());
});
And("^a Commander instance exists within the test container$", () -> {
assertNotNull(getDefaultErrorMessage("Commander instance is null in the container!"),
- testContainer.get().getCommander());
+ getTestContainer().getCommander());
});
But("^the Commander is not created using client credentials mode$", () -> {
assertFalse(getDefaultErrorMessage("expected that the Commander was not using client credentials"),
- testContainer.get().getCommander().isOAuth2Client());
+ getTestContainer().getCommander().isOAuth2Client());
+ });
+
+ And("^Settings are present in the test container$", () -> {
+ assertNotNull(getDefaultErrorMessage("settings were not found in the Web API test container!"),
+ getTestContainer().getSettings());
});
}
+
+ private WebAPITestContainer getTestContainer() {
+ return testContainer.get();
+ }
+
+ private void setTestContainer(WebAPITestContainer testContainer) {
+ this.testContainer.set(testContainer);
+ }
}
diff --git a/src/test/resources/bad.edmx-no-keyfield.xml b/src/test/resources/bad-edmx-no-keyfield.xml
similarity index 77%
rename from src/test/resources/bad.edmx-no-keyfield.xml
rename to src/test/resources/bad-edmx-no-keyfield.xml
index 11b94a0..9060221 100644
--- a/src/test/resources/bad.edmx-no-keyfield.xml
+++ b/src/test/resources/bad-edmx-no-keyfield.xml
@@ -10,6 +10,12 @@
+
+
+
+
+
+
diff --git a/src/test/resources/bad.edmx-unparsable-xml.xml b/src/test/resources/bad-edmx-unparsable-xml.xml
similarity index 100%
rename from src/test/resources/bad.edmx-unparsable-xml.xml
rename to src/test/resources/bad-edmx-unparsable-xml.xml
diff --git a/src/test/resources/bad.edmx-wrong-edm-binding-target.xml b/src/test/resources/bad-edmx-wrong-edm-binding-target.xml
similarity index 100%
rename from src/test/resources/bad.edmx-wrong-edm-binding-target.xml
rename to src/test/resources/bad-edmx-wrong-edm-binding-target.xml
diff --git a/src/test/resources/good.edmx-and-edm.xml b/src/test/resources/good-edmx-and-edm.xml
similarity index 100%
rename from src/test/resources/good.edmx-and-edm.xml
rename to src/test/resources/good-edmx-and-edm.xml
diff --git a/src/test/resources/mock.platinum.resoscript b/src/test/resources/mock-platinum.resoscript
similarity index 100%
rename from src/test/resources/mock.platinum.resoscript
rename to src/test/resources/mock-platinum.resoscript