diff --git a/Dockerfile b/Dockerfile index e0d6f58..cc4ab1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /home/gradle/project ADD . ./ -RUN gradle copyJarToOut +RUN gradle jar RUN ls @@ -13,7 +13,7 @@ FROM alpine:latest RUN apk add --update bash ca-certificates openjdk8-jre-base nss && \ rm -rf /var/cache/apk/* -COPY --from=builder /home/gradle/project/out/web-api-commander.jar ./ +COPY --from=builder /home/gradle/project/build/libs/web-api-commander.jar ./ ENTRYPOINT ["java","-jar","/web-api-commander.jar"] CMD ["--help"] diff --git a/README.md b/README.md index d99e202..edc7642 100644 --- a/README.md +++ b/README.md @@ -296,7 +296,6 @@ The XML DTD for this schema is as follows: diff --git a/src/main/java/org/reso/commander/App.java b/src/main/java/org/reso/commander/App.java index 820ee4d..214836b 100644 --- a/src/main/java/org/reso/commander/App.java +++ b/src/main/java/org/reso/commander/App.java @@ -170,12 +170,12 @@ public class App { //TODO: create dynamic JUnit (or similar) test runner LOG.info(SMALL_DIVIDER); - LOG.info("Assertion: #" + (i + 1)); + LOG.info("Request: #" + (i + 1)); LOG.info(SMALL_DIVIDER); - LOG.info("Assertion Name: " + request.getName()); + LOG.info("Request Name: " + request.getName()); //TODO: function-ize the property test - LOG.info("Assertion Description: " + (request.getTestDescription().length() > 0 ? request.getTestDescription() : "Not Specified")); + LOG.info("Description: " + (request.getTestDescription().length() > 0 ? request.getTestDescription() : "Not Specified")); LOG.info("Requirement Id: " + (request.getRequirementId().length() > 0 ? request.getRequirementId() : "Not Specified")); LOG.info("Metallic Level: " + (request.getMetallicLevel().length() > 0 ? request.getMetallicLevel() : "Not Specified")); LOG.info("Capability: " + (request.getCapability().length() > 0 ? request.getCapability() : "Not Specified")); @@ -200,6 +200,8 @@ public class App { if (responseCode == HttpStatus.SC_OK) { STATS.updateRequest(request, Request.Status.SUCCEEDED); + } else { + STATS.updateRequest(request, Request.Status.FAILED); } if (request.getOutputFile().toLowerCase().contains(EDMX_EXTENSION.toLowerCase())) { @@ -210,16 +212,9 @@ public class App { LOG.error("Error: Invalid metadata retrieved. Cannot continue!!"); System.exit(NOT_OK); } - } else if (responseCode != null && request.getAssertResponseCode() != null) { - if (responseCode == Integer.parseInt(request.getAssertResponseCode())) { - LOG.info("Assert Response Code " + request.getAssertResponseCode() + " passed!"); - } else { - LOG.error("Request " + request.getName() + " Failed!"); - STATS.updateRequest(request, Request.Status.FAILED); - } } - } else { + LOG.info("Request " + request.getRequirementId() + " has an empty URL. Skipping..."); STATS.updateRequest(request, Request.Status.SKIPPED); } } catch (Exception ex) { @@ -228,10 +223,6 @@ public class App { LOG.error("Stack trace:"); Arrays.stream(ex.getStackTrace()).forEach(stackTraceElement -> LOG.error(stackTraceElement.toString())); } finally { - if (request != null && STATS.getRequests().size() > 0) { - LOG.info("Request " + STATS.getRequests().get(request).getStatus().toString().toLowerCase() + "!"); - } - if (resolvedUrl != null && resolvedUrl.length() > 0) { LOG.info("Elapsed Time: " + String.format("%.2f", (STATS.getRequests().get(request).getElapsedTimeMillis() / 1000.0)) + "s"); } @@ -443,7 +434,7 @@ public class App { numIncomplete = stats.getRequestCount(Request.Status.STARTED); reportBuilder.append("\n\n" + DIVIDER); - reportBuilder.append("\nAssertion Statistics"); + reportBuilder.append("\nRequest Statistics"); reportBuilder.append("\n" + DIVIDER); reportBuilder.append(generateTotalsReport(stats.totalRequestCount(), numSucceeded, numFailed, numSkipped, numIncomplete)); @@ -462,7 +453,7 @@ public class App { numSkipped = stats.filterByMetallicCertification(metallicKey, stats.filterByStatus(Request.Status.SKIPPED)).size(); numIncomplete = stats.filterByMetallicCertification(metallicKey, stats.filterByStatus(Request.Status.STARTED)).size(); - reportBuilder.append("\n\n").append(metallicKey).append(numSucceeded > 0 && numSucceeded == (requestCount - numSkipped) ? " - REQUESTS SUCCEEDED!" : ""); + reportBuilder.append("\n\n").append(metallicKey).append(numSucceeded > 0 && numSucceeded == (requestCount - numSkipped) ? " - ALL REQUESTS SUCCEEDED!" : ""); reportBuilder.append(generateTotalsReport(requestCount, numSucceeded, numFailed, numSkipped, numIncomplete)); } @@ -477,7 +468,7 @@ public class App { numSkipped = stats.filterByCapability(capabilityKey, stats.filterByStatus(Request.Status.SKIPPED)).size(); numIncomplete = stats.filterByCapability(capabilityKey, stats.filterByStatus(Request.Status.STARTED)).size(); - reportBuilder.append("\n\n").append(capabilityKey).append(numSucceeded > 0 && numSucceeded == (requestCount - numSkipped) ? " - REQUESTS SUCCEEDED!" : ""); + reportBuilder.append("\n\n").append(capabilityKey).append(numSucceeded > 0 && numSucceeded == (requestCount - numSkipped) ? " - ALL REQUESTS SUCCEEDED!" : ""); reportBuilder.append(generateTotalsReport(requestCount, numSucceeded, numFailed, numSkipped, numIncomplete)); } reportBuilder.append("\n" + DIVIDER + "\n"); diff --git a/src/main/java/org/reso/models/Request.java b/src/main/java/org/reso/models/Request.java index 3747b35..44fd6d2 100644 --- a/src/main/java/org/reso/models/Request.java +++ b/src/main/java/org/reso/models/Request.java @@ -24,7 +24,6 @@ public class Request { private String metallicLevel; private String capability; private String webApiReference; - private String assertResponseCode; private Request request; private Status status; @@ -41,7 +40,7 @@ public class Request { * @param url */ public Request(String requirementId, String outputFile, String url, String testDescription, String metallicLevel, - String capability, String webApiReference, String assertResponseCode) { + String capability, String webApiReference) { //TODO: add Builder setRequirementId(requirementId); @@ -51,7 +50,6 @@ public class Request { setMetallicLevel(metallicLevel); setCapability(capability); setWebApiReference(webApiReference); - setAssertResponseCode(assertResponseCode); } @@ -123,8 +121,7 @@ public class Request { String expression = "/OutputScript/" + REQUESTS_KEY + "/node()"; NodeList nodes = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET); Node node; - String name, outputFile, url, testDescription, requirementId, metallicLevel, capability, webApiReference, - assertResponseCode; + String name, outputFile, url, testDescription, requirementId, metallicLevel, capability, webApiReference; Request request; for (int i = 0; i < nodes.getLength(); i++) { @@ -138,9 +135,8 @@ public class Request { metallicLevel = safeGetNamedItem(FIELDS.METALLIC_LEVEL, node); capability = safeGetNamedItem(FIELDS.CAPABILITY, node); webApiReference = safeGetNamedItem(FIELDS.WEB_API_REFERENCE, node); - assertResponseCode = safeGetNamedItem(FIELDS.ASSERT_RESPONSE_CODE, node); - request = new Request(requirementId, outputFile, url, testDescription, metallicLevel, capability, webApiReference, assertResponseCode); + request = new Request(requirementId, outputFile, url, testDescription, metallicLevel, capability, webApiReference); name = safeGetNamedItem(FIELDS.NAME, node); request.setName(name == null ? outputFile : name); @@ -249,14 +245,6 @@ public class Request { this.webApiReference = webApiReference; } - public String getAssertResponseCode() { - return assertResponseCode; - } - - public void setAssertResponseCode(String assertResponseCode) { - this.assertResponseCode = assertResponseCode; - } - private static final class FIELDS { static final String NAME = "Name"; static final String OUTPUT_FILE = "OutputFile"; @@ -266,6 +254,5 @@ public class Request { static final String METALLIC_LEVEL = "MetallicLevel"; static final String CAPABILITY = "Capability"; static final String WEB_API_REFERENCE = "WebAPIReference"; - static final String ASSERT_RESPONSE_CODE = "AssertResponseCode"; } } diff --git a/src/main/java/org/reso/models/Settings.java b/src/main/java/org/reso/models/Settings.java index a0361be..bdc1fce 100644 --- a/src/main/java/org/reso/models/Settings.java +++ b/src/main/java/org/reso/models/Settings.java @@ -59,7 +59,7 @@ public class Settings { public static Request resolveParameters(Request request, Settings settings) { //calls to resolve nested parameters return new Request(request.getRequirementId(), request.getOutputFile(), resolveParametersString(request.getUrl(), settings), request.getTestDescription(), - request.getMetallicLevel(), request.getCapability(), request.getWebApiReference(), request.getAssertResponseCode()); + request.getMetallicLevel(), request.getCapability(), request.getWebApiReference()); } /** diff --git a/src/test/java/org/reso/commander/AppTest.java b/src/test/java/org/reso/commander/AppTest.java index 450de80..086d567 100644 --- a/src/test/java/org/reso/commander/AppTest.java +++ b/src/test/java/org/reso/commander/AppTest.java @@ -6,8 +6,7 @@ package org.reso.commander; import org.junit.Test; public class AppTest { - @Test public void testAppHasAGreeting() { - App classUnderTest = new App(); - //assertNotNull("app should have a greeting", classUnderTest.getGreeting()); + @Test public void testParameterDeserialization() { + //TODO } }