Added better Metadata Reporting. Further fixes to RESOScripts
This commit is contained in:
parent
a47e03d91e
commit
4b84bc5ead
Binary file not shown.
|
@ -521,19 +521,19 @@
|
||||||
<Request
|
<Request
|
||||||
RequestId="REQ-WA103-QO29.1"
|
RequestId="REQ-WA103-QO29.1"
|
||||||
OutputFile="REQ-WA103-QO29.1.json"
|
OutputFile="REQ-WA103-QO29.1.json"
|
||||||
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_TopCount*&$select=*Parameter_ExpandField*&$expand=*Parameter_ExpandField*"
|
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_TopCount*&$select=*Parameter_KeyOrKeyNumericField*,*Parameter_ExpandField*&$expand=*Parameter_ExpandField*"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Request
|
<Request
|
||||||
RequestId="REQ-WA103-QO29.2"
|
RequestId="REQ-WA103-QO29.2"
|
||||||
OutputFile="REQ-WA103-QO29.2.json"
|
OutputFile="REQ-WA103-QO29.2.json"
|
||||||
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_TopCount*&$select=*Parameter_ExpandField*&$expand=*Parameter_ExpandField*&$filter=PhotosCount gt 0"
|
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_TopCount*&$select=*Parameter_KeyOrKeyNumericField*,*Parameter_ExpandField*&$expand=*Parameter_ExpandField*&$filter=PhotosCount gt 0"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Request
|
<Request
|
||||||
RequestId="REQ-WA103-QO29.3"
|
RequestId="REQ-WA103-QO29.3"
|
||||||
OutputFile="REQ-WA103-QO29.3.json"
|
OutputFile="REQ-WA103-QO29.3.json"
|
||||||
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_TopCount*&$select=*Parameter_ExpandField*&$expand=*Parameter_ExpandField**Parameter_RequiredParametersFilter*"
|
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_TopCount*&$select=*Parameter_KeyOrKeyNumericField*,*Parameter_ExpandField*&$expand=*Parameter_ExpandField**Parameter_RequiredParametersFilter*"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Request
|
<Request
|
||||||
|
|
|
@ -7,8 +7,8 @@ Feature: Web API Server 1.0.2 Certification
|
||||||
Background:
|
Background:
|
||||||
Given a RESOScript file was provided
|
Given a RESOScript file was provided
|
||||||
And Client Settings and Parameters were read from the file
|
And Client Settings and Parameters were read from the file
|
||||||
And a test environment was successfully created from the given RESOScript
|
And a test container was successfully created from the given RESOScript
|
||||||
And the test environment uses an authorization_code or client_credentials for authentication
|
And the test container uses an authorization_code or client_credentials for authentication
|
||||||
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
|
|
|
@ -80,14 +80,14 @@ public class WebAPIServer_1_0_2 implements En {
|
||||||
LOG.info("RESOScript loaded successfully!");
|
LOG.info("RESOScript loaded successfully!");
|
||||||
});
|
});
|
||||||
|
|
||||||
Given("^a test environment was successfully created from the given RESOScript$", () -> {
|
Given("^a test container was successfully created from the given RESOScript$", () -> {
|
||||||
getTestContainer().initialize();
|
getTestContainer().initialize();
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensures that the client either uses Authorization Codes or Client Credentials
|
* Ensures that the client either uses Authorization Codes or Client Credentials
|
||||||
*/
|
*/
|
||||||
And("^the test environment uses an authorization_code or client_credentials for authentication$", () -> {
|
And("^the test container uses an authorization_code or client_credentials for authentication$", () -> {
|
||||||
assertNotNull(getTestContainer().getCommander());
|
assertNotNull(getTestContainer().getCommander());
|
||||||
assertTrue("ERROR: Commander must either have a valid Authorization Code or Client Credentials configuration.",
|
assertTrue("ERROR: Commander must either have a valid Authorization Code or Client Credentials configuration.",
|
||||||
getTestContainer().getCommander().isTokenClient() || (getTestContainer().getCommander().isOAuthClient() && getTestContainer().getCommander().hasValidAuthConfig()));
|
getTestContainer().getCommander().isTokenClient() || (getTestContainer().getCommander().isOAuthClient() && getTestContainer().getCommander().hasValidAuthConfig()));
|
||||||
|
@ -289,7 +289,7 @@ public class WebAPIServer_1_0_2 implements En {
|
||||||
//TODO: convert to OData filter factory
|
//TODO: convert to OData filter factory
|
||||||
getTestContainer().setRequestUri(Commander.prepareURI(
|
getTestContainer().setRequestUri(Commander.prepareURI(
|
||||||
Settings.resolveParameters(getTestContainer().getSettings().getRequest(requestId), getTestContainer().getSettings()).getUrl()
|
Settings.resolveParameters(getTestContainer().getSettings().getRequest(requestId), getTestContainer().getSettings()).getUrl()
|
||||||
+ AMPERSAND + DOLLAR_SIGN + QueryOption.SKIP.toString() + EQUALS + skipCount));
|
+ AMPERSAND + ODATA_QUERY_PARAMS.SKIP + EQUALS + skipCount));
|
||||||
getTestContainer().executePreparedGetRequest();
|
getTestContainer().executePreparedGetRequest();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
fail(ex.toString());
|
fail(ex.toString());
|
||||||
|
@ -816,6 +816,7 @@ public class WebAPIServer_1_0_2 implements En {
|
||||||
final String serviceRoot = Settings.resolveParametersString(clientSettingsServiceRoot, getTestContainer().getSettings());
|
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());
|
assertEquals("ERROR: given service root doesn't match the one configured in the Commander", serviceRoot, getTestContainer().getCommander().getServiceRoot());
|
||||||
|
|
||||||
|
LOG.info("Requesting XML Metadata from: " + serviceRoot);
|
||||||
try {
|
try {
|
||||||
assertNotNull("ERROR: could not find valid XML Metadata for given service root: " + serviceRoot, getTestContainer().getXMLMetadata());
|
assertNotNull("ERROR: could not find valid XML Metadata for given service root: " + serviceRoot, getTestContainer().getXMLMetadata());
|
||||||
} catch (ODataClientErrorException cex) {
|
} catch (ODataClientErrorException cex) {
|
||||||
|
@ -833,8 +834,10 @@ public class WebAPIServer_1_0_2 implements En {
|
||||||
final String serviceRoot = Settings.resolveParametersString(clientSettingsServiceRoot, getTestContainer().getSettings());
|
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());
|
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 {
|
try {
|
||||||
assertNotNull("ERROR: could not find valid Edm Metadata for given service root: " + serviceRoot, getTestContainer().getEdm());
|
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) {
|
} catch (ODataClientErrorException cex) {
|
||||||
getTestContainer().setResponseCode(cex.getStatusLine().getStatusCode());
|
getTestContainer().setResponseCode(cex.getStatusLine().getStatusCode());
|
||||||
fail(cex.toString());
|
fail(cex.toString());
|
||||||
|
@ -881,27 +884,32 @@ public class WebAPIServer_1_0_2 implements En {
|
||||||
|
|
||||||
clientEntity.getProperties().forEach(clientProperty -> {
|
clientEntity.getProperties().forEach(clientProperty -> {
|
||||||
assertNotNull("ERROR: field name cannot be null!", clientProperty.getName());
|
assertNotNull("ERROR: field name cannot be null!", clientProperty.getName());
|
||||||
|
assertNotNull("ERROR: data type could not be found for " + clientProperty.getName() + "! "
|
||||||
|
+ "\nCheck the NavigationProperty for your $expand field.", clientProperty.getValue().getTypeName());
|
||||||
if (clientProperty.getName().equals(expandField)) {
|
if (clientProperty.getName().equals(expandField)) {
|
||||||
assertNotNull("ERROR: '" + parameterExpandField + "' contains no data!", clientProperty.getValue());
|
assertNotNull("ERROR: '" + parameterExpandField + "' contains no data!", clientProperty.getValue());
|
||||||
|
|
||||||
LOG.info("\tExpanded Field Name: " + expandField);
|
LOG.info("\tExpanded Field Name: " + expandField);
|
||||||
clientProperty.getValue().asComplex().forEach(expandedClientProperty -> {
|
clientProperty.getValue().asComplex().forEach(expandedClientProperty -> {
|
||||||
assertNotNull("ERROR: field name cannot be null!", expandedClientProperty.getName());
|
assertNotNull("ERROR: field name cannot be null!", expandedClientProperty.getName());
|
||||||
assertNotNull("ERROR: data type could not be found for " + expandedClientProperty.getName(), expandedClientProperty.getValue().getTypeName());
|
assertNotNull("ERROR: data type could not be found for: " + expandedClientProperty.getName(),
|
||||||
LOG.info("\t\tField Name: " + expandedClientProperty.getName());
|
expandedClientProperty.getValue().getTypeName());
|
||||||
LOG.info("\t\tField Value: " + expandedClientProperty.getValue().toString());
|
|
||||||
LOG.info("\t\tType Name: " + expandedClientProperty.getValue().getTypeName());
|
if (expandedClientProperty.getValue().asPrimitive().toValue() != null) {
|
||||||
LOG.info("\t\t" + REPORT_DIVIDER_SMALL);
|
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 {
|
} else {
|
||||||
|
|
||||||
LOG.info("\tField Name: " + clientProperty.getName());
|
LOG.info("\tField Name: " + clientProperty.getName());
|
||||||
LOG.info("\tField Value: " + clientProperty.getValue().toString());
|
LOG.info("\tField Value: " + clientProperty.getValue().toString());
|
||||||
LOG.info("\tType Name: " + clientProperty.getValue().getTypeName());
|
LOG.info("\tType Name: " + clientProperty.getValue().getTypeName());
|
||||||
LOG.info("\t" + REPORT_DIVIDER);
|
LOG.info("\t" + REPORT_DIVIDER);
|
||||||
}
|
}
|
||||||
assertNotNull("ERROR: data type could not be found for " + clientProperty.getName(), clientProperty.getValue().getTypeName());
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -251,28 +251,44 @@ public class Commander {
|
||||||
reportBuilder.append("\n" + REPORT_DIVIDER_SMALL);
|
reportBuilder.append("\n" + REPORT_DIVIDER_SMALL);
|
||||||
|
|
||||||
schema.getTypeDefinitions().forEach(a ->
|
schema.getTypeDefinitions().forEach(a ->
|
||||||
reportBuilder.append("\n\n\tType Definition:").append(a.getName()));
|
reportBuilder.append("\nType Definition:").append(a.getName()));
|
||||||
|
|
||||||
schema.getEntityTypes().forEach(a -> {
|
schema.getEntityTypes().forEach(a -> {
|
||||||
reportBuilder.append("\n\n\tEntity Type: ").append(a.getName());
|
reportBuilder.append("\nEntity Type: ").append(a.getName());
|
||||||
a.getKeyPropertyRefs().forEach(ref ->
|
a.getKeyPropertyRefs().forEach(ref ->
|
||||||
reportBuilder.append("\n\t\tKey Field: ").append(ref.getName()));
|
reportBuilder.append("\n\tKey Field: ").append(ref.getName()));
|
||||||
a.getPropertyNames().forEach(n -> reportBuilder.append("\n\t\tName: ").append(n));
|
a.getPropertyNames().forEach(n -> reportBuilder.append("\n\tName: ").append(n));
|
||||||
});
|
});
|
||||||
|
|
||||||
schema.getEnumTypes().forEach(a -> {
|
schema.getEnumTypes().forEach(edmEnumType -> {
|
||||||
reportBuilder.append("\n\n\tEnum Type: ").append(a.getName());
|
reportBuilder.append("\nEnum Type: ")
|
||||||
a.getMemberNames().forEach(n -> reportBuilder.append("\n\t\tName: ").append(n));
|
.append(edmEnumType.getName())
|
||||||
|
.append(" (").append(schema.getNamespace()).append(", ")
|
||||||
|
.append(edmEnumType.getUnderlyingType().getFullQualifiedName().getFullQualifiedNameAsString())
|
||||||
|
.append(")");
|
||||||
|
|
||||||
|
edmEnumType.getMemberNames().forEach(n -> {
|
||||||
|
reportBuilder
|
||||||
|
.append("\n\tName: ").append(n);
|
||||||
|
|
||||||
|
if (edmEnumType.getMember(n).getAnnotations().size() > 0) {
|
||||||
|
reportBuilder
|
||||||
|
.append("\n\tAnnotations: ")
|
||||||
|
.append(edmEnumType.getMember(n).getAnnotations().toString())
|
||||||
|
.append("\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
schema.getComplexTypes().forEach(a ->
|
schema.getComplexTypes().forEach(a ->
|
||||||
reportBuilder.append("\n\n\tComplex Entity Type: ").append(a.getFullQualifiedName().getFullQualifiedNameAsString()));
|
reportBuilder.append("\nComplex Entity Type: ").append(a.getFullQualifiedName().getFullQualifiedNameAsString()));
|
||||||
|
|
||||||
schema.getAnnotationGroups().forEach(a ->
|
schema.getAnnotationGroups().forEach(a ->
|
||||||
reportBuilder.append("\n\n\tAnnotation: ").append(a.getQualifier()).append(", Target Path: ").append(a.getTargetPath()));
|
reportBuilder.append("\nAnnotation: ").append(a.getQualifier()).append(", Target Path: ").append(a.getTargetPath()));
|
||||||
|
|
||||||
schema.getTerms().forEach(a ->
|
schema.getTerms().forEach(a ->
|
||||||
reportBuilder.append("\n\n\tTerm: ").append(a.getFullQualifiedName().getFullQualifiedNameAsString()));
|
reportBuilder.append("\nTerm: ").append(a.getFullQualifiedName().getFullQualifiedNameAsString()));
|
||||||
});
|
});
|
||||||
|
|
||||||
return reportBuilder.toString();
|
return reportBuilder.toString();
|
||||||
|
|
|
@ -44,6 +44,21 @@ public final class WebApiTestContainer implements TestContainer {
|
||||||
public static final String DOLLAR_SIGN = "$";
|
public static final String DOLLAR_SIGN = "$";
|
||||||
public static final String PRETTY_FIELD_SEPARATOR = FIELD_SEPARATOR + SINGLE_SPACE;
|
public static final String PRETTY_FIELD_SEPARATOR = FIELD_SEPARATOR + SINGLE_SPACE;
|
||||||
|
|
||||||
|
public static final class ODATA_QUERY_PARAMS {
|
||||||
|
private static String format = DOLLAR_SIGN + "%s";
|
||||||
|
|
||||||
|
//TODO: add additional items as needed, and see if there's a lib for this in Olingo
|
||||||
|
public static final String
|
||||||
|
COUNT = String.format(format, QueryOption.COUNT),
|
||||||
|
EXPAND = String.format(format, QueryOption.EXPAND),
|
||||||
|
FILTER = String.format(format, QueryOption.FILTER),
|
||||||
|
ORDERBY = String.format(format, QueryOption.ORDERBY),
|
||||||
|
SELECT = String.format(format, QueryOption.SELECT),
|
||||||
|
SEARCH = String.format(format, QueryOption.SEARCH),
|
||||||
|
SKIP = String.format(format, QueryOption.SKIP),
|
||||||
|
TOP = String.format(format, QueryOption.TOP);
|
||||||
|
}
|
||||||
|
|
||||||
private AtomicReference<Commander> commander = new AtomicReference<>();
|
private AtomicReference<Commander> commander = new AtomicReference<>();
|
||||||
private AtomicReference<XMLMetadata> xmlMetadata = new AtomicReference<>();
|
private AtomicReference<XMLMetadata> xmlMetadata = new AtomicReference<>();
|
||||||
private AtomicReference<Edm> edm = new AtomicReference<>();
|
private AtomicReference<Edm> edm = new AtomicReference<>();
|
||||||
|
@ -198,10 +213,9 @@ public final class WebApiTestContainer implements TestContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> getSelectList() {
|
public Collection<String> getSelectList() {
|
||||||
final String SELECT_OPERATOR = DOLLAR_SIGN + QueryOption.SELECT.toString();
|
|
||||||
Arrays.stream(getRequestUri().getQuery().split(AMPERSAND)).forEach(fragment -> {
|
Arrays.stream(getRequestUri().getQuery().split(AMPERSAND)).forEach(fragment -> {
|
||||||
if (fragment.contains(QueryOption.SELECT.toString())) {
|
if (fragment.contains(QueryOption.SELECT.toString())) {
|
||||||
selectList.set(fragment.replace(SELECT_OPERATOR, EMPTY_STRING).replace(EQUALS, EMPTY_STRING));
|
selectList.set(fragment.replace(ODATA_QUERY_PARAMS.SELECT, EMPTY_STRING).replace(EQUALS, EMPTY_STRING));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue