Skip to content

Commit

Permalink
Merge pull request #995 from catenax-ng/feature/416-get-report-data-f…
Browse files Browse the repository at this point in the history
…rom-import

Feature/416 Feedback from review
  • Loading branch information
ds-lcapellino authored Feb 19, 2024
2 parents 1607d08 + ca19c8e commit 53b49f2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
public class ImportJobResponseMapper {
public static ImportReportResponse from(ImportJob importJob) {

ImportReportResponse.ImportJobResponse importJobResponse =
new ImportReportResponse.ImportJobResponse(
ImportReportResponse.ImportJob importJobResponse =
new ImportReportResponse.ImportJob(
importJob.getId().toString(),
importJob.getStartedOn().toString(),
importJob.getCompletedOn().toString(),
ImportJobStatusResponse.valueOf(importJob.getStatus().toString()));

List<ImportReportResponse.ImportedAssetResponse> importedAssets =
List<ImportReportResponse.ImportedAsset> importedAssets =
Stream.concat(importJob.getAssetAsBuilt().stream(), importJob.getAssetAsPlanned().stream())
.map(
asset -> new ImportReportResponse.ImportedAssetResponse(
asset -> new ImportReportResponse.ImportedAsset(
asset.getId(),
ImportStateResponse.valueOf(asset.getImportState().toString()),
importJob.getStartedOn().toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

public enum ImportJobStatus {

INITIALIZING, RUNNING, CANCELLED, COMPLETED
INITIALIZING, RUNNING, ERROR, COMPLETED

}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void completeJob(ImportJob importJob) {
public void cancelJob(ImportJob importJob) {
ImportJobEntity importJobEntity = ImportJobEntity.from(importJob);
importJobEntity.setCompletedOn(Instant.now());
importJobEntity.setImportJobStatus(ImportJobStatus.CANCELLED);
importJobEntity.setImportJobStatus(ImportJobStatus.ERROR);
importJobRepository.save(importJobEntity);
log.info("Cancelling import job {}", importJob.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ void givenValidFile_whenImportData_thenReportShouldBeReturned() throws JoseExcep
.extract().as(ImportReportResponse.class);

// then
assertEquals(result.jobId(), importReportResponse.importJobResponse().importId());
assertEquals(18, importReportResponse.importedAssetResponse().size());
assertEquals(result.jobId(), importReportResponse.importJob().importId());
assertEquals(18, importReportResponse.importedAsset().size());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

@Schema
public record ImportReportResponse(
ImportJobResponse importJobResponse,
List<ImportedAssetResponse> importedAssetResponse) {
ImportJob importJob,
List<ImportedAsset> importedAsset) {

@Schema
public record ImportJobResponse(
public record ImportJob(
@Schema(example = "456a952e-05eb-40dc-a6f2-9c2cb9c1387f")
String importId,
@Schema(example = "2099-02-21T21:27:10.734950Z", maxLength = 50)
Expand All @@ -41,7 +41,7 @@ public record ImportJobResponse(
}

@Schema
public record ImportedAssetResponse(
public record ImportedAsset(
@Schema(example = "urn:uuid:7eeeac86-7b69-444d-81e6-655d0f1513bd}")
String catenaxId,
@Schema
Expand Down

0 comments on commit 53b49f2

Please sign in to comment.