PushReportMapper { public static PushReport mapFromImportSummaryToPushReport(ImportSummary importSummary, String importSummaryKey) { PushReport pushReport = new PushReport(); List<PushConflict> conflictList = new ArrayList<>(); if (importSummary.getConflicts() != null) { for (Conflict conflict : importSummary.getConflicts()) { conflictList.add( new PushConflict(conflict.getObject(), conflict.getValue())); } } pushReport.setPushConflicts(conflictList); pushReport.setDescription(importSummary.getDescription()); pushReport.setHref(importSummary.getHref()); ImportCount importCount = importSummary.getImportCount(); if(importCount!=null) { pushReport.setPushedValuesCount( new PushedValuesCount(importCount.getImported(), importCount.getUpdated(), importCount.getIgnored(), importCount.getDeleted())); } pushReport.setReference(importSummary.getReference()); if (importSummary.getStatus() == ImportSummary.Status.ERROR) { pushReport.setStatus(PushReport.Status.ERROR); } if (importSummary.getStatus() == ImportSummary.Status.OK) { pushReport.setStatus(PushReport.Status.OK); } if (importSummary.getStatus() == ImportSummary.Status.SUCCESS) { pushReport.setStatus(PushReport.Status.SUCCESS); } pushReport.setEventUid(importSummaryKey); return pushReport; }  static Map<String, PushReport> mapFromImportSummariesToPushReports(
            Map<java.lang.String, ImportSummary> mapEventsImportSummary); static PushReport mapFromImportSummaryToPushReport(ImportSummary importSummary,
            String importSummaryKey);  }
@Test public void test_conversion_of_success_import_summary() throws IOException { ImportSummary importSummary = givenAImportSummary(IMPORT_SUMMARY_SUCCESS_RESPONSE); PushReport pushReport = PushReportMapper.mapFromImportSummaryToPushReport(importSummary, EVENT_UID_KEY); assertThat(pushReport.getDescription().equals(importSummary.getDescription()), is(true)); assertThat(pushReport.getEventUid().equals(importSummary.getReference()), is(true)); assertThat(pushReport.getHref().equals(importSummary.getHref()), is(true)); assertThat((pushReport.getStatus().equals(PushReport.Status.SUCCESS)), is(true)); assertThat((importSummary.getStatus().equals(ImportSummary.Status.SUCCESS)), is(true)); assertThat(pushReport.getPushedValues().getImported() == (importSummary.getImportCount() .getImported()), is(true)); assertThat(pushReport.getPushedValues().getDeleted() == (importSummary.getImportCount() .getDeleted()), is(true)); assertThat(pushReport.getPushedValues().getIgnored() == (importSummary.getImportCount() .getIgnored()), is(true)); assertThat(pushReport.getPushedValues().getUpdated() == (importSummary.getImportCount() .getUpdated()), is(true)); assertThat(pushReport.getPushConflicts().isEmpty(), is(true)); }
@Test public void test_conversion_of_success_import_summary_with_conflicts() throws IOException { ImportSummary importSummary = givenAImportSummary(IMPORT_SUMMARY_CONFLICT_RESPONSE); PushReport pushReport = PushReportMapper.mapFromImportSummaryToPushReport(importSummary, EVENT_UID_KEY); assertThat(pushReport.getEventUid().equals(importSummary.getReference()), is(true)); assertThat(pushReport.getHref().equals(importSummary.getHref()), is(true)); assertThat((pushReport.getStatus().equals(PushReport.Status.SUCCESS)), is(true)); assertThat((importSummary.getStatus().equals(ImportSummary.Status.SUCCESS)), is(true)); assertThat(pushReport.getPushedValues().getImported() == (importSummary.getImportCount() .getImported()), is(true)); assertThat(pushReport.getPushedValues().getDeleted() == (importSummary.getImportCount() .getDeleted()), is(true)); assertThat(pushReport.getPushedValues().getIgnored() == (importSummary.getImportCount() .getIgnored()), is(true)); assertThat(pushReport.getPushedValues().getUpdated() == (importSummary.getImportCount() .getUpdated()), is(true)); assertThat(pushReport.getPushConflicts().get(0).getUid().equals( importSummary.getConflicts().get(0).getObject()), is(true)); assertThat(pushReport.getPushConflicts().get(0).getValue().equals( importSummary.getConflicts().get(0).getValue()), is(true)); }