diff --git a/build/libs/web-api-commander.jar b/build/libs/web-api-commander.jar index 747e048..616af4a 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 c29316a..021d2b1 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 @@ -50,7 +50,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results - And data are present in fields contained within "Parameter_SelectList" + And data are present for fields contained within the given "Parameter_SelectList" @REQ-WA103-QR4 @core @2.4.2 @client-paging-endorsement Scenario: REQ-WA103-QR4 - Query Support: $top @@ -58,6 +58,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And the number of results is less than or equal to "Parameter_TopCount" @REQ-WA103-QR5 @core @2.4.2 @query-support-endorsement @@ -66,10 +67,12 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And a GET request is made to the resolved Url in "REQ-WA103-QR5" with $skip="Parameter_TopCount" Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And data in the "Parameter_KeyOrKeyNumeric" fields are different in the second request than in the first @REQ-WA103-QO1.1 @core @2.4.4 @core-endorsement @OData-4.0 @@ -98,6 +101,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Integer data in "Parameter_FilterIntegerField" "eq" "Parameter_FilterIntegerValueLow" @REQ-WA103-QO3 @core @2.4.4 @filterability-endorsement @@ -106,6 +110,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Integer data in "Parameter_FilterIntegerField" "ne" "Parameter_FilterIntegerValueLow" @REQ-WA103-QO4 @core @2.4.4 @filterability-endorsement @@ -114,6 +119,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Integer data in "Parameter_FilterIntegerField" "gt" "Parameter_FilterIntegerValueLow" @REQ-WA103-QO5 @core @2.4.4 @filterability-endorsement @@ -122,6 +128,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Integer data in "Parameter_FilterIntegerField" "ge" "Parameter_FilterIntegerValueLow" @REQ-WA103-QO6 @core @2.4.4 @filterability-endorsement @@ -130,6 +137,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Integer data in "Parameter_FilterIntegerField" "lt" "Parameter_FilterIntegerValueLow" @REQ-WA103-QO7 @core @2.4.4 @filterability-endorsement @@ -138,6 +146,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Integer data in "Parameter_FilterIntegerField" "le" "Parameter_FilterIntegerValueLow" @REQ-WA103-QO9 @core @2.4.4 @filterability-endorsement @@ -146,6 +155,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Integer data in "Parameter_FilterIntegerField" "gt" "Parameter_FilterIntegerValueLow" "and" "lt" "Parameter_FilterIntegerValueHigh" @REQ-WA103-QO10 @core @2.4.4 @filterability-endorsement @@ -154,6 +164,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Integer data in "Parameter_FilterIntegerField" "gt" "Parameter_FilterIntegerValueLow" "or" "lt" "Parameter_FilterIntegerValueHigh" @REQ-WA103-QO11 @core @2.4.4 @filterability-endorsement @@ -162,6 +173,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Integer data in "Parameter_FilterNotField" "ne" "Parameter_FilterNotValue" @REQ-WA103-QO25 @core @2.4.4 @filterability-endorsement @@ -170,6 +182,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Date data in "Parameter_TimestampField" "gt" "Parameter_DateValue" @REQ-WA103-QO26 @core @2.4.4 @filterability-endorsement @@ -178,6 +191,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And TimeOfDay data in "Parameter_TimestampField" "lt" "Parameter_TimeValue" @REQ-WA103-QO26.2 @core @2.4.4 @filterability-endorsement @@ -186,6 +200,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And DateTimeOffset data in "Parameter_TimestampField" "lt" "Parameter_DateTimeValue" @REQ-WA103-QO27 @core @2.4.4 @filterability-endorsement @@ -194,6 +209,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And DateTimeOffset data in "Parameter_TimestampField" "le" now() @@ -242,6 +258,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Single Valued Enumeration Data in "Parameter_SingleValueLookupField" has "Parameter_SingleLookupValue" @REQ-WA103-QM8 @bronze @2.4.10 @filterability-endorsement @@ -250,6 +267,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Multiple Valued Enumeration Data in "Parameter_MultipleValueLookupField" has "Parameter_MultipleLookupValue1" @REQ-WA103-QM8.2 @bronze @2.4.10 @filterability-endorsement @@ -258,6 +276,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Multiple Valued Enumeration Data in "Parameter_MultipleValueLookupField" has "Parameter_MultipleLookupValue1" And Multiple Valued Enumeration Data in "Parameter_MultipleValueLookupField" has "Parameter_MultipleLookupValue2" @@ -267,6 +286,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And Single Valued Enumeration Data in "Parameter_FilterHasField" has "Parameter_FilterHasLookupValue" @REQ-WA103-QO28.1 @bronze @2.4.4 @sortability-endorsement @@ -275,6 +295,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And DateTimeOffset data in "Parameter_TimestampField" is sorted in "asc" order @REQ-WA103-QO28.2 @bronze @2.4.4 @sortability-endorsement @@ -283,6 +304,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And DateTimeOffset data in "Parameter_TimestampField" is sorted in "asc" order @REQ-WA103-QO28.3 @bronze @2.4.4 @sortability-endorsement @@ -291,6 +313,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And DateTimeOffset data in "Parameter_TimestampField" is sorted in "desc" order @REQ-WA103-QO28.4 @bronze @2.4.4 @sortability-endorsement @@ -299,6 +322,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And DateTimeOffset data in "Parameter_TimestampField" is sorted in "desc" order @@ -312,6 +336,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "year" data in Date Field "Parameter_DateField" "eq" "Parameter_YearValue" @REQ-WA103-QO18.2 @gold @2.4.4 @filterability-endorsement @@ -320,6 +345,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "year" data in Timestamp Field "Parameter_TimestampField" "eq" "Parameter_YearValue" @REQ-WA103-QO19.1 @gold @2.4.4 @filterability-endorsement @@ -328,6 +354,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "month" data in Date Field "Parameter_DateField" "eq" "Parameter_MonthValue" @REQ-WA103-QO19.2 @gold @2.4.4 @filterability-endorsement @@ -336,6 +363,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "month" data in Timestamp Field "Parameter_TimestampField" "eq" "Parameter_MonthValue" @REQ-WA103-QO20.1 @gold @2.4.4 @filterability-endorsement @@ -344,6 +372,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "day" data in Date Field "Parameter_DateField" "eq" "Parameter_DayValue" @REQ-WA103-QO20.2 @gold @2.4.4 @filterability-endorsement @@ -352,6 +381,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "day" data in Timestamp Field "Parameter_TimestampField" "eq" "Parameter_DayValue" @REQ-WA103-QO21 @gold @2.4.4 @filterability-endorsement @@ -360,6 +390,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "hour" data in Timestamp Field "Parameter_TimestampField" "eq" "Parameter_HourValue" @REQ-WA103-QO22 @gold @2.4.4 @filterability-endorsement @@ -368,6 +399,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "minute" data in Timestamp Field "Parameter_TimestampField" "gt" "Parameter_MinuteValue" @REQ-WA103-QO23 @gold @2.4.4 @filterability-endorsement @@ -376,6 +408,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "second" data in Timestamp Field "Parameter_TimestampField" "lt" "Parameter_SecondValue" @REQ-WA103-QO24 @gold @2.4.4 @filterability-endorsement @@ -384,6 +417,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And "fractional" data in Timestamp Field "Parameter_TimestampField" "lt" "Parameter_FractionalValue" ####################################### @@ -396,6 +430,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And String data in "Parameter_ContainsField" "contains" "Parameter_ContainsValue" @REQ-WA103-QO14 @platinum @2.4.4 @filterability-endorsement @@ -404,6 +439,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And String data in "Parameter_EndsWithField" "endswith" "Parameter_EndsWithValue" @REQ-WA103-QO15 @platinum @2.4.4 @filterability-endorsement @@ -412,6 +448,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And String data in "Parameter_StartsWithField" "startswith" "Parameter_StartsWithValue" @REQ-WA103-QO16 @platinum @2.4.4 @filterability-endorsement @@ -420,6 +457,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And String data in "Parameter_ToLowerField" "tolower" "Parameter_ToLowerValue" @REQ-WA103-QO17 @platinum @2.4.4 @filterability-endorsement @@ -428,6 +466,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" And String data in "Parameter_ToUpperField" "toupper" "Parameter_ToUpperValue" @REQ-WA103-QO29.1 @platinum @2.4.4 @expandability-endorsement @@ -436,8 +475,8 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results - And data are present in fields contained within "Parameter_SelectList" - And data are present within the expanded field "Parameter_ExpandField" + And data are present for fields contained within the given "Parameter_SelectList" + And data and type information exist in the results and within the given "Parameter_ExpandField" And an OData NavigationProperty exists for the given "Parameter_EndpointResource" And the expanded data were found in the related resource @@ -447,6 +486,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" @REQ-WA103-QO29.3 @platinum @2.4.4 @expandability-endorsement @todo Scenario: REQ-WA103-QO29.3 - Query Support: $expand required field (TODO) @@ -454,6 +494,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" @REQ-WA103-QM3 @platinum @2.4.6 @queryability-endorsement @todo Scenario: REQ-WA103-QM3 - Support Literals: any() Lambda Expression (TODO) @@ -461,6 +502,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" @REQ-WA103-QM4 @platinum @2.4.6 @queryability-endorsement @todo Scenario: REQ-WA103-QM4 - Query Support Literals: all() Lambda Operator (TODO) @@ -468,6 +510,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" @REQ-WA103-QM5.1 @platinum @2.4.7 @queryability-endorsement @geospatial @todo Scenario: REQ-WA103-QM5.1 - Query Support: GeoSpatial Search Implementation (TODO) @@ -475,6 +518,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" @REQ-WA103-QM5.2 @platinum @2.4.7 @queryability-endorsement @geospatial @todo Scenario: REQ-WA103-QM5.2 - Query Support: GeoSpatial Search Implementation (TODO) @@ -482,6 +526,7 @@ Feature: Web API Server 1.0.2 Certification Then the server responds with a status code of 200 And the response is valid JSON And the response has results + And data are present for fields contained within the given "Parameter_SelectList" @REQ-WA103-QO12 @platinum @2.4.4 @filterability-endorsement @filterability-endorsement Scenario: REQ-WA103-QO12 - Query Support: $filter - Grouping: filter (ge, le) and (gt, lt) and expect (gt, lt) 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 674ef1b..5f56008 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 @@ -29,6 +29,7 @@ import java.io.File; import java.io.InputStream; import java.sql.Time; import java.sql.Timestamp; +import java.text.DecimalFormat; import java.time.Instant; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; @@ -37,6 +38,8 @@ import java.util.concurrent.atomic.AtomicReference; import static io.restassured.path.json.JsonPath.from; import static org.junit.Assert.*; +import static org.reso.commander.Commander.REPORT_DIVIDER; +import static org.reso.commander.Commander.REPORT_DIVIDER_SMALL; import static org.reso.commander.TestUtils.*; import static org.reso.commander.TestUtils.Operators.*; @@ -209,11 +212,15 @@ public class WebAPIServer_1_0_2 implements En { /* * REQ-WA103-QR3 - $select */ - And("^data are present in fields contained within \"([^\"]*)\"$", (String parameterSelectList) -> { + And("^data are present for fields contained within the given \"([^\"]*)\"$", (String parameterSelectList) -> { try { AtomicInteger numFieldsWithData = new AtomicInteger(); List fieldList = new ArrayList<>(Arrays.asList(Settings.resolveParametersString(parameterSelectList, getTestContainer().getSettings()).split(FIELD_SEPARATOR))); + DecimalFormat df = new DecimalFormat(); + df.setMaximumFractionDigits(1); + double fill = 0; + AtomicInteger numResults = new AtomicInteger(); //iterate over the items and count the number of fields with data to determine whether there are data present from(getTestContainer().getResponseData()).getList(JSON_VALUE_PATH, HashMap.class).forEach(item -> { @@ -230,8 +237,10 @@ public class WebAPIServer_1_0_2 implements En { LOG.info("Number of Results: " + numResults.get()); LOG.info("Number of Fields: " + fieldList.size()); LOG.info("Fields with Data: " + numFieldsWithData.get()); - if (numFieldsWithData.get() > 0) { - LOG.info("Percent Fill: " + ((numResults.get() * fieldList.size()) / (1.0 * numFieldsWithData.get()) * 100) + "%"); + + if (numResults.get() > 0 && fieldList.size() > 0) { + fill = ((100.0 * numFieldsWithData.get()) / (numResults.get() * fieldList.size())); + LOG.info("Percent Fill: " + df.format(fill) + "%"); } else { LOG.info("Percent Fill: 0% - no fields with data found!"); } @@ -282,6 +291,7 @@ public class WebAPIServer_1_0_2 implements En { fail(ex.toString()); } }); + And("^data in the \"([^\"]*)\" fields are different in the second request than in the first$", (String parameterUniqueId) -> { try { List l1 = from(getTestContainer().getInitialResponseData()).getJsonObject(JSON_VALUE_PATH); @@ -310,19 +320,9 @@ public class WebAPIServer_1_0_2 implements En { /* * GET request by requirementId (see generic.resoscript) */ - When("^a GET request is made to the resolved Url in \"([^\"]*)\"$", (String requestId) -> { - try { - //reset local state each time a get request is run - getTestContainer().resetState(); + When("^a GET request is made to the resolved Url in \"([^\"]*)\"$", (String requirementId) -> executeGetRequest(requirementId)); - LOG.info("Request ID: " + requestId); - getTestContainer().setRequestUri(Commander.prepareURI(Settings.resolveParameters( - getTestContainer().getSettings().getRequestById(requestId), getTestContainer().getSettings()).getUrl())); - LOG.info("Request URI: " + getTestContainer().getRequestUri().toString()); - getTestContainer().executePreparedGetRequest(); - } catch (Exception ex) { - LOG.debug("Exception was thrown in " + this.getClass() + ": " + ex.toString()); - } + When("^a GET request is made to the resolved Url in \"([^\"]*)\" without service root validation$", (String requirementId) -> { }); /* @@ -871,26 +871,41 @@ public class WebAPIServer_1_0_2 implements En { /* * Checks to see whether the expanded field has data */ - And("^data are present within the expanded field \"([^\"]*)\"$", (String parameterExpandField) -> { + And("^data and type information exist in the results and within the given \"([^\"]*)\"$", (String parameterExpandField) -> { String expandField = Settings.resolveParametersString(parameterExpandField, getTestContainer().getSettings()); assertFalse("ERROR: no expand field found for " + parameterExpandField, expandField.isEmpty()); - ClientEntitySet results = getTestContainer().getCommander().getClient().getRetrieveRequestFactory().getEntitySetRequest(getTestContainer().getRequestUri()).execute().getBody(); + ClientEntitySet results = getTestContainer().getCommander().getClient().getRetrieveRequestFactory() + .getEntitySetRequest(getTestContainer().getRequestUri()).execute().getBody(); LOG.info("Results count is: " + results.getEntities().size()); AtomicInteger counter = new AtomicInteger(); results.getEntities().forEach(clientEntity -> { - if (showResponses) LOG.info("\nItem #" + counter.getAndIncrement()); + //counter is only used for display and not logic + if (showResponses) LOG.info("\nRecord #" + counter.getAndIncrement()); clientEntity.getProperties().forEach(clientProperty -> { - if (showResponses) { + assertNotNull("ERROR: field name cannot be null!", clientProperty.getName()); + + if (clientProperty.getName().equals(expandField)) { + assertNotNull("ERROR: '" + parameterExpandField + "' contains no data!", clientProperty.getValue()); + + LOG.info("\tExpanded Field Name: " + expandField); + clientProperty.getValue().asComplex().forEach(expandedClientProperty -> { + assertNotNull("ERROR: field name cannot be null!", expandedClientProperty.getName()); + assertNotNull("ERROR: data type could not be found for " + expandedClientProperty.getName(), expandedClientProperty.getValue().getTypeName()); + LOG.info("\t\tField Name: " + expandedClientProperty.getName()); + LOG.info("\t\tField Value: " + expandedClientProperty.getValue().toString()); + LOG.info("\t\tType Name: " + expandedClientProperty.getValue().getTypeName()); + LOG.info("\t\t" + REPORT_DIVIDER_SMALL); + }); + } else { + LOG.info("\tField Name: " + clientProperty.getName()); LOG.info("\tField Value: " + clientProperty.getValue().toString()); LOG.info("\tType Name: " + clientProperty.getValue().getTypeName()); - LOG.info("\n"); + LOG.info("\t" + REPORT_DIVIDER); } - assertNotNull("ERROR: '" + parameterExpandField + "' not found in results!", clientProperty.getName()); - assertNotNull("ERROR: '" + parameterExpandField + "' contains no data!", clientProperty.getValue()); assertNotNull("ERROR: data type could not be found for " + clientProperty.getName(), clientProperty.getValue().getTypeName()); }); }); @@ -995,6 +1010,24 @@ public class WebAPIServer_1_0_2 implements En { }); } + /* + * Execute Get Request Wrapper + */ + void executeGetRequest(String requestId) { + try { + //reset local state each time a get request is run + getTestContainer().resetState(); + + LOG.info("Request ID: " + requestId); + getTestContainer().setRequestUri(Commander.prepareURI(Settings.resolveParameters( + getTestContainer().getSettings().getRequestById(requestId), getTestContainer().getSettings()).getUrl())); + LOG.info("Request URI: " + getTestContainer().getRequestUri().toString()); + getTestContainer().executePreparedGetRequest(); + } catch (Exception ex) { + LOG.debug("Exception was thrown in " + this.getClass() + ": " + ex.toString()); + } + } + static WebApiTestContainer getTestContainer() { return container.get(); } diff --git a/src/main/java/org/reso/commander/App.java b/src/main/java/org/reso/commander/App.java index 81a0cd1..33f2ab5 100644 --- a/src/main/java/org/reso/commander/App.java +++ b/src/main/java/org/reso/commander/App.java @@ -89,7 +89,7 @@ public class App { settings = Settings.loadFromRESOScript(new File(inputFilename)); LOG.debug("RESOScript loaded successfully!"); - serviceRoot = settings.getClientSettings().get(ClientSettings.WEB_API_URI); + serviceRoot = settings.getClientSettings().get(ClientSettings.SERVICE_ROOT); LOG.debug("Service Root is:" + serviceRoot); //TODO: add base64 un-encode when applicable diff --git a/src/main/java/org/reso/commander/Commander.java b/src/main/java/org/reso/commander/Commander.java index 6b56eb0..b5749d1 100644 --- a/src/main/java/org/reso/commander/Commander.java +++ b/src/main/java/org/reso/commander/Commander.java @@ -167,7 +167,12 @@ public class Commander { JSON_FULL_METADATA = "JSON_FULL_METADATA", XML = "XML"; - ContentType type = ContentType.JSON; + final ContentType DEFAULT_CONTENT_TYPE = ContentType.JSON; + ContentType type = DEFAULT_CONTENT_TYPE; + + if (contentType == null) { + return type; + } if (contentType.matches(JSON)) { type = ContentType.JSON; 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 0d3365d..5f2e615 100644 --- a/src/main/java/org/reso/commander/certfication/containers/WebApiTestContainer.java +++ b/src/main/java/org/reso/commander/certfication/containers/WebApiTestContainer.java @@ -12,15 +12,18 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse import org.apache.olingo.client.api.domain.ClientEntitySet; import org.apache.olingo.client.api.edm.xml.XMLMetadata; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.format.ContentType; import org.reso.commander.Commander; import org.reso.commander.TestUtils; import org.reso.models.ClientSettings; +import org.reso.models.Parameters; import org.reso.models.Request; import org.reso.models.Settings; import java.net.URI; import java.util.concurrent.atomic.AtomicReference; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import static org.reso.commander.TestUtils.HEADER_ODATA_VERSION; @@ -60,7 +63,7 @@ public final class WebApiTestContainer implements TestContainer { public void initialize() { - setServiceRoot(getSettings().getClientSettings().get(ClientSettings.WEB_API_URI)); + setServiceRoot(getSettings().getClientSettings().get(ClientSettings.SERVICE_ROOT)); //TODO: add base64 un-encode when applicable setBearerToken(getSettings().getClientSettings().get(ClientSettings.BEARER_TOKEN)); @@ -86,11 +89,28 @@ public final class WebApiTestContainer implements TestContainer { .scope(getScope()) .serviceRoot(getServiceRoot()) .bearerToken(getBearerToken()) - .useEdmEnabledClient(true) + .useEdmEnabledClient(shouldUseEdmClient()) .build()); } } + /** + * If the server is using a DataSystem endpoint that's not rooted at the Service Root, the EDM client + * will fail the request. Cannot use the Edm client for those that do. + * + * @return true if the Olingo Edm client should be used, false otherwise. + */ + private boolean shouldUseEdmClient() { + /* Cannot use EdmEnabled client with a server that has a DataSystem endpoint that's not rooted at the Service Root */ + String dataSystemEndpoint = getSettings().getParameters().getValue(Parameters.WELL_KNOWN.DATASYSTEM_ENDPOINT), + serviceRoot = getSettings().getClientSettings().get(ClientSettings.SERVICE_ROOT); + + assertNotNull("ERROR: " + Parameters.WELL_KNOWN.DATASYSTEM_ENDPOINT + " cannot be null!", dataSystemEndpoint); + assertNotNull("ERROR: " + ClientSettings.SERVICE_ROOT + " cannot be null!", serviceRoot); + + return dataSystemEndpoint.startsWith(serviceRoot); + } + /** * Resets the state of the test container */ @@ -114,6 +134,7 @@ public final class WebApiTestContainer implements TestContainer { public void executePreparedGetRequest() { try { setRawRequest(getCommander().getClient().getRetrieveRequestFactory().getRawRequest(getRequestUri())); + getRawRequest().setFormat(ContentType.JSON.toContentTypeString()); setODataRawResponse(getRawRequest().execute()); setResponseData(TestUtils.convertInputStreamToString(getODataRawResponse().getRawResponse())); setServerODataHeaderVersion(getODataRawResponse().getHeader(HEADER_ODATA_VERSION).toString()); diff --git a/src/main/java/org/reso/models/ClientSettings.java b/src/main/java/org/reso/models/ClientSettings.java index 0a8e707..cdf74f9 100644 --- a/src/main/java/org/reso/models/ClientSettings.java +++ b/src/main/java/org/reso/models/ClientSettings.java @@ -22,7 +22,7 @@ public class ClientSettings { SERVER_NAME = "ServerName", VENDOR_NAME = "VendorName", LAST_MODIFIED_TIMESTAMP = "LastModifiedTimestamp", - WEB_API_URI = "WebAPIURI", + SERVICE_ROOT = "WebAPIURI", AUTHORIZATION_URI = "AuthorizationURI", TOKEN_URI = "TokenURI", REDIRECT_URI = "RedirectURI", @@ -40,7 +40,7 @@ public class ClientSettings { public static final String[] supportedClientSettings = { SERVER_ID, SERVER_NAME, VENDOR_NAME, LAST_MODIFIED_TIMESTAMP, - WEB_API_URI, AUTHORIZATION_URI, TOKEN_URI, REDIRECT_URI, + SERVICE_ROOT, AUTHORIZATION_URI, TOKEN_URI, REDIRECT_URI, AUTHENTICATION_TYPE, BEARER_TOKEN, CLIENT_IDENTIFICATION, CLIENT_SECRET, USERNAME, PASSWORD, CLIENT_SCOPE, VERSION, PRE_AUTHENTICATE, SERVER_NAME, RESULTS_DIRECTORY, SCRIPT_FILE}; diff --git a/src/main/java/org/reso/models/Parameters.java b/src/main/java/org/reso/models/Parameters.java index ad40dea..cf31966 100644 --- a/src/main/java/org/reso/models/Parameters.java +++ b/src/main/java/org/reso/models/Parameters.java @@ -70,4 +70,10 @@ public class Parameters { public void putParameter(String name, String value) { this.parameters.put(name, value); } + + public static final class WELL_KNOWN { + public static final String + RESOURCE_ENDPOINT = "EndpointResource", + DATASYSTEM_ENDPOINT = "EndpointDataSystem"; + } } \ No newline at end of file diff --git a/src/main/resources/datasystem.schema.4.json b/src/main/resources/datasystem.schema.4.json index 5ae6466..5d05e1b 100644 --- a/src/main/resources/datasystem.schema.4.json +++ b/src/main/resources/datasystem.schema.4.json @@ -4,7 +4,6 @@ "title": "The Root Schema of the DataSystem resource", "description": "The root schema comprises the entire JSON document.", "required": [ - "@odata.context", "value" ], "properties": { diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index c62dc07..840230a 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -3,7 +3,7 @@ [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%level] [%c{1}] - %msg%n %msg%n - ./commander.debug.log + ./commander.log