adobe / aio-lib-java-cloudmanager

Java wrapper to the Adobe Cloud Manager API.
https://opensource.adobe.com/aio-lib-java-cloudmanager/
Apache License 2.0
3 stars 9 forks source link

Use Java8 date classes #27

Closed kwin closed 3 years ago

kwin commented 3 years ago

This closes #26

Motivation and Context

Reduce number of dependencies

How Has This Been Tested?

Currently the PR fails, because getEnvironmentLogs (https://github.com/AdobeDocs/cloudmanager-api-docs/blob/f6be183a5669b7f126669b159d736aa7f8c9e4ee/swagger-specs/api.yaml#L1020) returns a non-compliant date 2019-09-8 instead of 2019-09-08 as required by the spec (https://swagger.io/docs/specification/data-models/data-types/#string) for format date (https://github.com/AdobeDocs/cloudmanager-api-docs/blob/f6be183a5669b7f126669b159d736aa7f8c9e4ee/swagger-specs/api.yaml#L2101)

Types of changes

Checklist:

kwin commented 3 years ago

The following errors in the test are emitted

[INFO] Running io.adobe.cloudmanager.impl.EnvironmentsTest
[ERROR] Tests run: 32, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 3.995 s <<< FAILURE! - in io.adobe.cloudmanager.impl.EnvironmentsTest
[ERROR] downloadLogs_successEnvironment  Time elapsed: 0.074 s  <<< ERROR!
javax.ws.rs.ProcessingException: Error reading entity from input stream.
    at io.adobe.cloudmanager.impl.EnvironmentsTest.downloadLogs_successEnvironment(EnvironmentsTest.java:398)
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException:
Cannot deserialize value of type `java.time.LocalDate` from String "2019-09-8": Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException) Text '2019-09-8' could not be parsed at index 8
 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 31, column: 16] (through reference chain: io.adobe.cloudmanager.swagger.model.EnvironmentLogs["_embedded"]->io.adobe.cloudmanager.swagger.model.EnvironmentLogsEmbedded["downloads"]->java.util.ArrayList[0]->io.adobe.cloudmanager.swagger.model.EnvironmentLog["date"])
    at io.adobe.cloudmanager.impl.EnvironmentsTest.downloadLogs_successEnvironment(EnvironmentsTest.java:398)
Caused by: java.time.format.DateTimeParseException: Text '2019-09-8' could not be parsed at index 8
    at io.adobe.cloudmanager.impl.EnvironmentsTest.downloadLogs_successEnvironment(EnvironmentsTest.java:398)

[ERROR] downloadLogs_via_environment  Time elapsed: 0.025 s  <<< ERROR!
javax.ws.rs.ProcessingException: Error reading entity from input stream.
    at io.adobe.cloudmanager.impl.EnvironmentsTest.downloadLogs_via_environment(EnvironmentsTest.java:411)
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException:
Cannot deserialize value of type `java.time.LocalDate` from String "2019-09-8": Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException) Text '2019-09-8' could not be parsed at index 8
 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 31, column: 16] (through reference chain: io.adobe.cloudmanager.swagger.model.EnvironmentLogs["_embedded"]->io.adobe.cloudmanager.swagger.model.EnvironmentLogsEmbedded["downloads"]->java.util.ArrayList[0]->io.adobe.cloudmanager.swagger.model.EnvironmentLog["date"])
    at io.adobe.cloudmanager.impl.EnvironmentsTest.downloadLogs_via_environment(EnvironmentsTest.java:411)
Caused by: java.time.format.DateTimeParseException: Text '2019-09-8' could not be parsed at index 8
    at io.adobe.cloudmanager.impl.EnvironmentsTest.downloadLogs_via_environment(EnvironmentsTest.java:411)

[ERROR] downloadLogs_success  Time elapsed: 0.022 s  <<< ERROR!
javax.ws.rs.ProcessingException: Error reading entity from input stream.
    at io.adobe.cloudmanager.impl.EnvironmentsTest.downloadLogs_success(EnvironmentsTest.java:385)
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException:
Cannot deserialize value of type `java.time.LocalDate` from String "2019-09-8": Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException) Text '2019-09-8' could not be parsed at index 8
 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 31, column: 16] (through reference chain: io.adobe.cloudmanager.swagger.model.EnvironmentLogs["_embedded"]->io.adobe.cloudmanager.swagger.model.EnvironmentLogsEmbedded["downloads"]->java.util.ArrayList[0]->io.adobe.cloudmanager.swagger.model.EnvironmentLog["date"])
    at io.adobe.cloudmanager.impl.EnvironmentsTest.downloadLogs_success(EnvironmentsTest.java:385)
Caused by: java.time.format.DateTimeParseException: Text '2019-09-8' could not be parsed at index 8
    at io.adobe.cloudmanager.impl.EnvironmentsTest.downloadLogs_success(EnvironmentsTest.java:385)

As outlined above this is an issue with the server not behaving spec compliant!

The expected format is also described in https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_LOCAL_DATE:

Two digits for the day-of-month. This is pre-padded by zero to ensure two digits.

This is in line with https://tools.ietf.org/html/rfc3339#section-5.6

date-mday = 2DIGIT

bstopp commented 3 years ago

Is this just a test data issue, or is the underlying API not conforming to a Date format?

kwin commented 3 years ago

invalid test data, fixed with https://github.com/adobe/aio-lib-java-cloudmanager/pull/27/commits/3574ac50917483a1b9c41a332c183f854d0a5090

codecov[bot] commented 3 years ago

Codecov Report

Merging #27 (3574ac5) into main (98e4de5) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main      #27   +/-   ##
=========================================
  Coverage     88.92%   88.92%           
  Complexity      166      166           
=========================================
  Files            14       14           
  Lines           551      551           
  Branches         48       48           
=========================================
  Hits            490      490           
  Misses           43       43           
  Partials         18       18           
Flag Coverage Δ Complexity Δ
unittests 88.92% <ø> (ø) 0.00 <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...ain/java/io/adobe/cloudmanager/model/Pipeline.java 100.00% <0.00%> (ø) 7.00% <0.00%> (ø%)
...ain/java/io/adobe/cloudmanager/model/Variable.java 100.00% <0.00%> (ø) 2.00% <0.00%> (ø%)
.../java/io/adobe/cloudmanager/model/Environment.java 84.61% <0.00%> (ø) 6.00% <0.00%> (ø%)
...va/io/adobe/cloudmanager/model/EnvironmentLog.java 100.00% <0.00%> (ø) 1.00% <0.00%> (ø%)
...a/io/adobe/cloudmanager/model/EmbeddedProgram.java 100.00% <0.00%> (ø) 3.00% <0.00%> (ø%)
...io/adobe/cloudmanager/model/PipelineExecution.java 87.50% <0.00%> (ø) 17.00% <0.00%> (ø%)
...cloudmanager/model/PipelineExecutionStepState.java 100.00% <0.00%> (ø) 3.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8ad4eab...3574ac5. Read the comment docs.