package dk.statsbiblioteket.newspaper.processmonitor.backend;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class Converter {
    static List<Batch> convertBatchList(List<dk.statsbiblioteket.newspaper.processmonitor.datasources.Batch> batches) {
        List<Batch> result = new ArrayList<>(batches.size());
        for (dk.statsbiblioteket.newspaper.processmonitor.datasources.Batch batch : batches) {
            result.add(convert(batch));
        }
        return result;
    }

    static Batch convert(dk.statsbiblioteket.newspaper.processmonitor.datasources.Batch batch) {
        Batch result = new Batch();
        result.setBatchID(batch.getBatchID());
        result.setEvents(convert(batch.getEventList()));
        return result;
    }

    private static Map<String, Event> convert(List<dk.statsbiblioteket.newspaper.processmonitor.datasources.Event> eventList) {
        Map<String, Event> result = new HashMap<>(eventList.size());
        for (dk.statsbiblioteket.newspaper.processmonitor.datasources.Event event : eventList) {
            result.put(event.getEventID(), convert(event));
        }
        return result;
    }

    static Event convert(dk.statsbiblioteket.newspaper.processmonitor.datasources.Event batchEvent) {
        Event result = new Event();
        result.setDetails(batchEvent.getDetails());
        result.setSuccess(batchEvent.isSuccess());
        return result;
    }
}

@@ -294,32 +294,98 @@
 tch%3E batches) %7B%0A
+        if (batches == null) %7B%0A            return null;%0A        %7D%0A
         List%3CBat
@@ -422,32 +422,32 @@
 atches.size());%0A
-
         for (dk.
@@ -698,24 +698,88 @@
 ch batch) %7B%0A
+        if (batch == null) %7B%0A            return null;%0A        %7D%0A
         Batc
@@ -1056,32 +1056,100 @@
 t%3E eventList) %7B%0A
+        if (eventList == null) %7B%0A            return null;%0A        %7D%0A
         Map%3CStri
@@ -1390,32 +1390,32 @@
  result;%0A    %7D%0A%0A
-
     static Event
@@ -1496,24 +1496,93 @@
 tchEvent) %7B%0A
+        if (batchEvent == null) %7B%0A            return null;%0A        %7D%0A
         Even

Check for null in the converter