// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/chb/PassengerStopAssignmentLoader.java
// public class PassengerStopAssignmentLoader {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(PassengerStopAssignmentLoader.class);
// 
//     public static Map<String, String> load() {
//         Map<String, String> mapping = new HashMap<>();
//         File chbFile = getFile();
//         if (chbFile == null) {
//             return null;
//         }
// 
//         try (FileInputStream fis = new FileInputStream(chbFile);
//              GZIPInputStream input = new GZIPInputStream(fis)) {
//             Export export = (Export) JAXBContext.newInstance(Export.class).createUnmarshaller().unmarshal(input);
//             if (export != null) {
//                 int count = handleExport(mapping, export);
//                 MetricStore.getInstance().storeMetric("chb.mappings", count);
//                 LOGGER.info("Got export, with {} entries", count);
//             }
//         } catch (JAXBException | IOException e) {
//             LOGGER.info("Got exception reading CHB file", e);
//         }
//         return mapping;
//     }
// 
//     private static File getFile() {
//         File path = new File(Configuration.getChbPath());
//         File[] fs = path.listFiles();
//         if (fs == null || fs.length == 0) {
//             return null;
//         }
//         File chbFile = null;
//         for (File f : fs) {
//             if (chbFile == null && f.getName().startsWith("PassengerStopAssignmentExportCHB") && f.getName().endsWith("xml.gz")) {
//                 chbFile = f;
//             }
//         }
//         if (chbFile != null) {
//             LOGGER.info("File to match {}", chbFile.getName());
//         } else {
//             return null;
//         }
//         return chbFile;
//     }
// 
//     private static int handleExport(Map<String, String> mapping, Export export) {
//         int i[] = {0};
//         export.getQuays().getQuay().forEach(q -> {
//             q.getUserstopcodes().getUserstopcodedata().forEach(usc -> {
//                 mapping.put(usc.getDataownercode()+"|"+usc.getUserstopcode(), q.getQuaycode());
// 
//                 i[0] += 1;
//             });
//         });
//         return i[0];
//     }
// 
// }
// 
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/chb/StopStore.java
// public class StopStore {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(StopStore.class);
// 
//     private static Map<String, String> store = new HashMap<>();
//     private static Set<String> missing = new HashSet<>();
// 
//     public static Optional<String> getQuayFromCode(String dataOwner, String stopCode) {
//         String key = dataOwner+"|"+stopCode;
//         if (store.containsKey(key)) {
//             return Optional.of(store.get(key));
//         }
//         missing.add(key);
//         return Optional.empty();
//     }
// 
//     public static boolean stopExists(String quayOrStopCode) {
//         return store.values().contains(quayOrStopCode);
//     }
// 
//     public static Map<String, String> getStore() {
//         return store;
//     }
// 
//     public static Set<String> getMissing() {
//         return missing;
//     }
// 
//     public static void setStore(Map<String, String> storeData) {
//         store = storeData;
//     }
// }


import nl.crowndov.displaydirect.distribution.chb.PassengerStopAssignmentLoader;
import nl.crowndov.displaydirect.distribution.chb.StopStore;
import com.netflix.config.ConfigurationManager;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.util.Map;
package nl.crowndov.displaydirect.distribution.kv78;



/**
 * Copyright 2017 CROW-NDOV
 *
 * This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
 */
public class PlanningLoaderTest {

    @Before
    public void setup() {
        try {
            ConfigurationManager.loadCascadedPropertiesFromResources("configuration");
        } catch (IOException ignored) {}
    }

    @Test
    @Ignore
    public void testPlanningLoader() {
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/chb/PassengerStopAssignmentLoader.java
// public class PassengerStopAssignmentLoader {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(PassengerStopAssignmentLoader.class);
// 
//     public static Map<String, String> load() {
//         Map<String, String> mapping = new HashMap<>();
//         File chbFile = getFile();
//         if (chbFile == null) {
//             return null;
//         }
// 
//         try (FileInputStream fis = new FileInputStream(chbFile);
//              GZIPInputStream input = new GZIPInputStream(fis)) {
//             Export export = (Export) JAXBContext.newInstance(Export.class).createUnmarshaller().unmarshal(input);
//             if (export != null) {
//                 int count = handleExport(mapping, export);
//                 MetricStore.getInstance().storeMetric("chb.mappings", count);
//                 LOGGER.info("Got export, with {} entries", count);
//             }
//         } catch (JAXBException | IOException e) {
//             LOGGER.info("Got exception reading CHB file", e);
//         }
//         return mapping;
//     }
// 
//     private static File getFile() {
//         File path = new File(Configuration.getChbPath());
//         File[] fs = path.listFiles();
//         if (fs == null || fs.length == 0) {
//             return null;
//         }
//         File chbFile = null;
//         for (File f : fs) {
//             if (chbFile == null && f.getName().startsWith("PassengerStopAssignmentExportCHB") && f.getName().endsWith("xml.gz")) {
//                 chbFile = f;
//             }
//         }
//         if (chbFile != null) {
//             LOGGER.info("File to match {}", chbFile.getName());
//         } else {
//             return null;
//         }
//         return chbFile;
//     }
// 
//     private static int handleExport(Map<String, String> mapping, Export export) {
//         int i[] = {0};
//         export.getQuays().getQuay().forEach(q -> {
//             q.getUserstopcodes().getUserstopcodedata().forEach(usc -> {
//                 mapping.put(usc.getDataownercode()+"|"+usc.getUserstopcode(), q.getQuaycode());
// 
//                 i[0] += 1;
//             });
//         });
//         return i[0];
//     }
// 
// }
// 
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/chb/StopStore.java
// public class StopStore {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(StopStore.class);
// 
//     private static Map<String, String> store = new HashMap<>();
//     private static Set<String> missing = new HashSet<>();
// 
//     public static Optional<String> getQuayFromCode(String dataOwner, String stopCode) {
//         String key = dataOwner+"|"+stopCode;
//         if (store.containsKey(key)) {
//             return Optional.of(store.get(key));
//         }
//         missing.add(key);
//         return Optional.empty();
//     }
// 
//     public static boolean stopExists(String quayOrStopCode) {
//         return store.values().contains(quayOrStopCode);
//     }
// 
//     public static Map<String, String> getStore() {
//         return store;
//     }
// 
//     public static Set<String> getMissing() {
//         return missing;
//     }
// 
//     public static void setStore(Map<String, String> storeData) {
//         store = storeData;
//     }
// }


// Path: distribution/src/test/java/nl/crowndov/displaydirect/distribution/kv78/PlanningLoaderTest.java
import nl.crowndov.displaydirect.distribution.chb.PassengerStopAssignmentLoader;
import nl.crowndov.displaydirect.distribution.chb.StopStore;
import com.netflix.config.ConfigurationManager;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.util.Map;

package nl.crowndov.displaydirect.distribution.kv78;



/**
 * Copyright 2017 CROW-NDOV
 *
 * This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
 */
public class PlanningLoaderTest {

    @Before
    public void setup() {
        try {
            ConfigurationManager.loadCascadedPropertiesFromResources("configuration");
        } catch (IOException ignored) {}
    }

    @Test
    @Ignore
    public void testPlanningLoader() {
        Map<String,String> result = PassengerStopAssignmentLoader.load();